1
+import 'package:cake_wallet/entities/list_order_mode.dart';
2
+import 'package:cake_wallet/entities/wallet_list_order_types.dart';
3
+import 'package:cake_wallet/src/screens/settings/widgets/settings_choices_cell.dart';
4
+import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
5
+import 'package:cake_wallet/src/widgets/section_divider.dart';
6
+import 'package:cake_wallet/themes/extensions/menu_theme.dart';
7
+import 'package:cake_wallet/view_model/settings/choices_list_item.dart';
8
+import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart';
9
+import 'package:flutter/material.dart';
10
+import 'package:cake_wallet/src/widgets/picker_wrapper_widget.dart';
11
+import 'package:cake_wallet/generated/i18n.dart';
12
+import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
13
+
14
+class FilterListWidget extends StatefulWidget {
15
+ FilterListWidget({
16
+ required this.initalType,
17
+ required this.initalAscending,
18
+ required this.onClose,
19
+ });
20
+
21
+ final WalletListOrderType? initalType;
22
+ final bool initalAscending;
23
+ final Function(bool, WalletListOrderType) onClose;
24
+
25
+ @override
26
+ FilterListWidgetState createState() => FilterListWidgetState();
27
+}
28
+
29
+class FilterListWidgetState extends State<FilterListWidget> {
30
+ late bool ascending;
31
+ late WalletListOrderType? type;
32
+
33
+ @override
34
+ void initState() {
35
+ super.initState();
36
+ ascending = widget.initalAscending;
37
+ type = widget.initalType;
38
+ }
39
+
40
+ void setSelectedOrderType(WalletListOrderType? orderType) {
41
+ setState(() {
42
+ type = orderType;
43
+ });
44
+ }
45
+
46
+ @override
47
+ Widget build(BuildContext context) {
48
+ const sectionDivider = const HorizontalSectionDivider();
49
+ return PickerWrapperWidget(
50
+ onClose: () {
51
+ widget.onClose(ascending, type!);
52
+ Navigator.of(context).pop();
53
+ },
54
+ children: [
55
+ Padding(
56
+ padding: EdgeInsets.only(left: 24, right: 24, top: 24),
57
+ child: ClipRRect(
58
+ borderRadius: BorderRadius.all(Radius.circular(24)),
59
+ child: Container(
60
+ color: Theme.of(context).extension<CakeMenuTheme>()!.backgroundColor,
61
+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
62
+ Padding(
63
+ padding: EdgeInsets.all(24.0),
64
+ child: Text(
65
+ S.of(context).order_by,
66
+ style: TextStyle(
67
+ color:
68
+ Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor,
69
+ fontSize: 16,
70
+ fontFamily: 'Lato',
71
+ decoration: TextDecoration.none,
72
+ ),
73
+ ),
74
+ ),
75
+ if (type != WalletListOrderType.Custom) ...[
76
+ sectionDivider,
77
+ SettingsChoicesCell(
78
+ ChoicesListItem<ListOrderMode>(
79
+ title: "",
80
+ items: ListOrderMode.all,
81
+ selectedItem: ascending ? ListOrderMode.ascending : ListOrderMode.descending,
82
+ onItemSelected: (ListOrderMode listOrderMode) {
83
+ setState(() {
84
+ ascending = listOrderMode == ListOrderMode.ascending;
85
+ });
86
+ },
87
+ ),
88
+ ),
89
+ ],
90
+ sectionDivider,
91
+ RadioListTile(
92
+ value: WalletListOrderType.CreationDate,
93
+ groupValue: type,
94
+ title: Text(
95
+ WalletListOrderType.CreationDate.toString(),
96
+ style: TextStyle(
97
+ color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
98
+ fontSize: 16,
99
+ fontFamily: 'Lato',
100
+ fontWeight: FontWeight.bold,
101
+ decoration: TextDecoration.none),
102
+ ),
103
+ onChanged: setSelectedOrderType,
104
+ activeColor: Theme.of(context).primaryColor,
105
+ ),
106
+ RadioListTile(
107
+ value: WalletListOrderType.Alphabetical,
108
+ groupValue: type,
109
+ title: Text(
110
+ WalletListOrderType.Alphabetical.toString(),
111
+ style: TextStyle(
112
+ color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
113
+ fontSize: 16,
114
+ fontFamily: 'Lato',
115
+ fontWeight: FontWeight.bold,
116
+ decoration: TextDecoration.none),
117
+ ),
118
+ onChanged: setSelectedOrderType,
119
+ activeColor: Theme.of(context).primaryColor,
120
+ ),
121
+ RadioListTile(
122
+ value: WalletListOrderType.GroupByType,
123
+ groupValue: type,
124
+ title: Text(
125
+ WalletListOrderType.GroupByType.toString(),
126
+ style: TextStyle(
127
+ color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
128
+ fontSize: 16,
129
+ fontFamily: 'Lato',
130
+ fontWeight: FontWeight.bold,
131
+ decoration: TextDecoration.none),
132
+ ),
133
+ onChanged: setSelectedOrderType,
134
+ activeColor: Theme.of(context).primaryColor,
135
+ ),
136
+ RadioListTile(
137
+ value: WalletListOrderType.Custom,
138
+ groupValue: type,
139
+ title: Text(
140
+ WalletListOrderType.Custom.toString(),
141
+ style: TextStyle(
142
+ color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
143
+ fontSize: 16,
144
+ fontFamily: 'Lato',
145
+ fontWeight: FontWeight.bold,
146
+ decoration: TextDecoration.none),
147
+ ),
148
+ onChanged: setSelectedOrderType,
149
+ activeColor: Theme.of(context).primaryColor,
150
+ ),
151
+ ]),
152
+ ),
153
+ ),
154
+ )
155
+ ],
156
+ );
157
+ }
158
+}