mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-05 12:44:09 +01:00
CW-512 wallet sort (#1195)
* add shared preferences key and make list re-orderable * macos sonoma build fix * everything (almost) works * add translations * more translations * everything works * fixes * translation merge file fix * fix for mobile platforms * fix filter icon being invisible on bright theme * first pass of adding ascending/descending to filter widget * small fix * update ascending switch * fixes * fix * reverse creation sort * review fixes part 1 * refactor into function rather than tuple + color changes * more fixes * remove unrelated file * updated wording * cleaner callback * undo sonoma fix --------- Co-authored-by: fossephate <fosse@book.local> Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
co-authored by
fossephate
Omar Hatem
parent
049e4def27
commit
2ff81df9e7
@@ -0,0 +1,158 @@
|
||||
import 'package:cake_wallet/entities/list_order_mode.dart';
|
||||
import 'package:cake_wallet/entities/wallet_list_order_types.dart';
|
||||
import 'package:cake_wallet/src/screens/settings/widgets/settings_choices_cell.dart';
|
||||
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
|
||||
import 'package:cake_wallet/src/widgets/section_divider.dart';
|
||||
import 'package:cake_wallet/themes/extensions/menu_theme.dart';
|
||||
import 'package:cake_wallet/view_model/settings/choices_list_item.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/src/widgets/picker_wrapper_widget.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
|
||||
|
||||
class FilterListWidget extends StatefulWidget {
|
||||
FilterListWidget({
|
||||
required this.initalType,
|
||||
required this.initalAscending,
|
||||
required this.onClose,
|
||||
});
|
||||
|
||||
final WalletListOrderType? initalType;
|
||||
final bool initalAscending;
|
||||
final Function(bool, WalletListOrderType) onClose;
|
||||
|
||||
@override
|
||||
FilterListWidgetState createState() => FilterListWidgetState();
|
||||
}
|
||||
|
||||
class FilterListWidgetState extends State<FilterListWidget> {
|
||||
late bool ascending;
|
||||
late WalletListOrderType? type;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
ascending = widget.initalAscending;
|
||||
type = widget.initalType;
|
||||
}
|
||||
|
||||
void setSelectedOrderType(WalletListOrderType? orderType) {
|
||||
setState(() {
|
||||
type = orderType;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const sectionDivider = const HorizontalSectionDivider();
|
||||
return PickerWrapperWidget(
|
||||
onClose: () {
|
||||
widget.onClose(ascending, type!);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 24, right: 24, top: 24),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.all(Radius.circular(24)),
|
||||
child: Container(
|
||||
color: Theme.of(context).extension<CakeMenuTheme>()!.backgroundColor,
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(24.0),
|
||||
child: Text(
|
||||
S.of(context).order_by,
|
||||
style: TextStyle(
|
||||
color:
|
||||
Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor,
|
||||
fontSize: 16,
|
||||
fontFamily: 'Lato',
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (type != WalletListOrderType.Custom) ...[
|
||||
sectionDivider,
|
||||
SettingsChoicesCell(
|
||||
ChoicesListItem<ListOrderMode>(
|
||||
title: "",
|
||||
items: ListOrderMode.all,
|
||||
selectedItem: ascending ? ListOrderMode.ascending : ListOrderMode.descending,
|
||||
onItemSelected: (ListOrderMode listOrderMode) {
|
||||
setState(() {
|
||||
ascending = listOrderMode == ListOrderMode.ascending;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
sectionDivider,
|
||||
RadioListTile(
|
||||
value: WalletListOrderType.CreationDate,
|
||||
groupValue: type,
|
||||
title: Text(
|
||||
WalletListOrderType.CreationDate.toString(),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
||||
fontSize: 16,
|
||||
fontFamily: 'Lato',
|
||||
fontWeight: FontWeight.bold,
|
||||
decoration: TextDecoration.none),
|
||||
),
|
||||
onChanged: setSelectedOrderType,
|
||||
activeColor: Theme.of(context).primaryColor,
|
||||
),
|
||||
RadioListTile(
|
||||
value: WalletListOrderType.Alphabetical,
|
||||
groupValue: type,
|
||||
title: Text(
|
||||
WalletListOrderType.Alphabetical.toString(),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
||||
fontSize: 16,
|
||||
fontFamily: 'Lato',
|
||||
fontWeight: FontWeight.bold,
|
||||
decoration: TextDecoration.none),
|
||||
),
|
||||
onChanged: setSelectedOrderType,
|
||||
activeColor: Theme.of(context).primaryColor,
|
||||
),
|
||||
RadioListTile(
|
||||
value: WalletListOrderType.GroupByType,
|
||||
groupValue: type,
|
||||
title: Text(
|
||||
WalletListOrderType.GroupByType.toString(),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
||||
fontSize: 16,
|
||||
fontFamily: 'Lato',
|
||||
fontWeight: FontWeight.bold,
|
||||
decoration: TextDecoration.none),
|
||||
),
|
||||
onChanged: setSelectedOrderType,
|
||||
activeColor: Theme.of(context).primaryColor,
|
||||
),
|
||||
RadioListTile(
|
||||
value: WalletListOrderType.Custom,
|
||||
groupValue: type,
|
||||
title: Text(
|
||||
WalletListOrderType.Custom.toString(),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
||||
fontSize: 16,
|
||||
fontFamily: 'Lato',
|
||||
fontWeight: FontWeight.bold,
|
||||
decoration: TextDecoration.none),
|
||||
),
|
||||
onChanged: setSelectedOrderType,
|
||||
activeColor: Theme.of(context).primaryColor,
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user