align the hint with the prefix in the text field (#1571)
* Update send_card.dart * update currency amount text field widget * Update qr_widget.dart
Serhii committed
Aug 10, 2024 at 00:48 UTC
14e99daa7398791cff5dbb9134e66f86f2142043
10 files changed
+370
-649
lib/src/screens/exchange/exchange_page.dart
+15
-24
@@ -67,17 +67,6 @@ class ExchangePage extends BasePage {
67
Debounce _depositAmountDebounce = Debounce(Duration(milliseconds: 500));
68
var _isReactionsSet = false;
69
70
- final arrowBottomPurple = Image.asset(
71
- 'assets/images/arrow_bottom_purple_icon.png',
72
- color: Colors.white,
73
- height: 8,
74
- );
75
- final arrowBottomCakeGreen = Image.asset(
76
- 'assets/images/arrow_bottom_cake_green.png',
77
- color: Colors.white,
78
- height: 8,
79
- );
80
-
70
late final String? depositWalletName;
71
late final String? receiveWalletName;
72
@@ -101,11 +90,11 @@ class ExchangePage extends BasePage {
90
91
@override
92
Function(BuildContext)? get pushToNextWidget => (context) {
104
- FocusScopeNode currentFocus = FocusScope.of(context);
105
- if (!currentFocus.hasPrimaryFocus) {
106
- currentFocus.focusedChild?.unfocus();
107
- }
108
- };
93
+ FocusScopeNode currentFocus = FocusScope.of(context);
94
+ if (!currentFocus.hasPrimaryFocus) {
95
+ currentFocus.focusedChild?.unfocus();
96
+ }
97
+ };
98
99
@override
100
Widget middle(BuildContext context) => Row(
@@ -340,7 +329,6 @@ class ExchangePage extends BasePage {
329
330
void applyTemplate(
331
BuildContext context, ExchangeViewModel exchangeViewModel, ExchangeTemplate template) async {
343
-
332
final depositCryptoCurrency = CryptoCurrency.fromString(template.depositCurrency);
333
final receiveCryptoCurrency = CryptoCurrency.fromString(template.receiveCurrency);
334
@@ -354,10 +342,12 @@ class ExchangePage extends BasePage {
342
exchangeViewModel.isFixedRateMode = false;
343
344
var domain = template.depositAddress;
357
- exchangeViewModel.depositAddress = await fetchParsedAddress(context, domain, depositCryptoCurrency);
345
+ exchangeViewModel.depositAddress =
346
+ await fetchParsedAddress(context, domain, depositCryptoCurrency);
347
348
domain = template.receiveAddress;
360
- exchangeViewModel.receiveAddress = await fetchParsedAddress(context, domain, receiveCryptoCurrency);
349
+ exchangeViewModel.receiveAddress =
350
+ await fetchParsedAddress(context, domain, receiveCryptoCurrency);
351
}
352
353
void _setReactions(BuildContext context, ExchangeViewModel exchangeViewModel) {
@@ -529,14 +519,16 @@ class ExchangePage extends BasePage {
519
_depositAddressFocus.addListener(() async {
520
if (!_depositAddressFocus.hasFocus && depositAddressController.text.isNotEmpty) {
521
final domain = depositAddressController.text;
532
- exchangeViewModel.depositAddress = await fetchParsedAddress(context, domain, exchangeViewModel.depositCurrency);
522
+ exchangeViewModel.depositAddress =
523
+ await fetchParsedAddress(context, domain, exchangeViewModel.depositCurrency);
524
}
525
});
526
527
_receiveAddressFocus.addListener(() async {
528
if (!_receiveAddressFocus.hasFocus && receiveAddressController.text.isNotEmpty) {
529
final domain = receiveAddressController.text;
539
- exchangeViewModel.receiveAddress = await fetchParsedAddress(context, domain, exchangeViewModel.receiveCurrency);
530
+ exchangeViewModel.receiveAddress =
531
+ await fetchParsedAddress(context, domain, exchangeViewModel.receiveCurrency);
532
}
533
});
534
@@ -589,7 +581,8 @@ class ExchangePage extends BasePage {
581
}
582
}
583
592
- Future<String> fetchParsedAddress(BuildContext context, String domain, CryptoCurrency currency) async {
584
+ Future<String> fetchParsedAddress(
585
+ BuildContext context, String domain, CryptoCurrency currency) async {
586
final parsedAddress = await getIt.get<AddressResolver>().resolve(context, domain, currency);
587
final address = await extractAddressFromParsed(context, parsedAddress);
588
return address;
@@ -658,7 +651,6 @@ class ExchangePage extends BasePage {
651
652
exchangeViewModel.changeDepositCurrency(currency: currency);
653
},
661
- imageArrow: arrowBottomPurple,
654
currencyButtonColor: Colors.transparent,
655
addressButtonsColor:
656
Theme.of(context).extension<SendPageTheme>()!.textFieldButtonColor,
@@ -705,7 +697,6 @@ class ExchangePage extends BasePage {
697
currencies: exchangeViewModel.receiveCurrencies,
698
onCurrencySelected: (currency) =>
699
exchangeViewModel.changeReceiveCurrency(currency: currency),
708
- imageArrow: arrowBottomCakeGreen,
700
currencyButtonColor: Colors.transparent,
701
addressButtonsColor:
702
Theme.of(context).extension<SendPageTheme>()!.textFieldButtonColor,
lib/src/screens/exchange/widgets/exchange_card.dart
+15
-116
@@ -1,5 +1,6 @@
1
import 'package:cake_wallet/core/amount_validator.dart';
2
import 'package:cake_wallet/entities/contact_base.dart';
3
+import 'package:cake_wallet/src/screens/receive/widgets/currency_input_field.dart';
4
import 'package:cake_wallet/themes/extensions/qr_code_theme.dart';
5
import 'package:cake_wallet/routes.dart';
6
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
@@ -27,7 +28,7 @@ class ExchangeCard extends StatefulWidget {
28
required this.isAmountEstimated,
29
required this.currencies,
30
required this.onCurrencySelected,
30
- required this.imageArrow,
31
+ this.imageArrow,
32
this.currencyValueValidator,
33
this.addressTextFieldValidator,
34
this.title = '',
@@ -58,7 +59,7 @@ class ExchangeCard extends StatefulWidget {
59
final bool isAmountEstimated;
60
final bool hasRefundAddress;
61
final bool isMoneroWallet;
61
- final Image imageArrow;
62
+ final Image? imageArrow;
63
final Color currencyButtonColor;
64
final Color? addressButtonsColor;
65
final Color borderColor;
@@ -191,120 +192,18 @@ class ExchangeCardState extends State<ExchangeCard> {
192
)
193
],
194
),
194
- Padding(
195
- padding: EdgeInsets.only(top: 20),
196
- child: Row(
197
- children: [
198
- Container(
199
- padding: EdgeInsets.only(right: 8),
200
- height: 32,
201
- color: widget.currencyButtonColor,
202
- child: InkWell(
203
- onTap: () => _presentPicker(context),
204
- child: Row(
205
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
206
- mainAxisSize: MainAxisSize.min,
207
- children: <Widget>[
208
- Padding(
209
- padding: EdgeInsets.only(right: 5),
210
- child: widget.imageArrow,
211
- ),
212
- Text(_selectedCurrency.toString(),
213
- style: TextStyle(
214
- fontWeight: FontWeight.w600, fontSize: 16, color: Colors.white))
215
- ]),
216
- ),
217
- ),
218
- if (_selectedCurrency.tag != null)
219
- Padding(
220
- padding: const EdgeInsets.only(right: 3.0),
221
- child: Container(
222
- height: 32,
223
- decoration: BoxDecoration(
224
- color: widget.addressButtonsColor ??
225
- Theme.of(context).extension<SendPageTheme>()!.textFieldButtonColor,
226
- borderRadius: BorderRadius.all(Radius.circular(6))),
227
- child: Center(
228
- child: Padding(
229
- padding: const EdgeInsets.all(6.0),
230
- child: Text(_selectedCurrency.tag!,
231
- style: TextStyle(
232
- fontSize: 12,
233
- fontWeight: FontWeight.bold,
234
- color: Theme.of(context)
235
- .extension<SendPageTheme>()!
236
- .textFieldButtonIconColor)),
237
- ),
238
- ),
239
- ),
240
- ),
241
- Padding(
242
- padding: const EdgeInsets.only(right: 4.0),
243
- child: Text(':',
244
- style: TextStyle(
245
- fontWeight: FontWeight.w600, fontSize: 16, color: Colors.white)),
246
- ),
247
- Expanded(
248
- child: Row(
249
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
250
- children: [
251
- Flexible(
252
- child: FocusTraversalOrder(
253
- order: NumericFocusOrder(1),
254
- child: BaseTextFormField(
255
- focusNode: widget.amountFocusNode,
256
- controller: amountController,
257
- enabled: _isAmountEditable,
258
- textAlign: TextAlign.left,
259
- keyboardType:
260
- TextInputType.numberWithOptions(signed: false, decimal: true),
261
- inputFormatters: [
262
- FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]'))
263
- ],
264
- hintText: '0.0000',
265
- borderColor: Colors.transparent,
266
- //widget.borderColor,
267
- textStyle: TextStyle(
268
- fontSize: 16, fontWeight: FontWeight.w600, color: Colors.white),
269
- placeholderTextStyle: TextStyle(
270
- fontSize: 16,
271
- fontWeight: FontWeight.w600,
272
- color: Theme.of(context)
273
- .extension<ExchangePageTheme>()!
274
- .hintTextColor),
275
- validator: _isAmountEditable
276
- ? widget.currencyValueValidator
277
- : null),
278
- ),
279
- ),
280
- if (widget.hasAllAmount)
281
- Container(
282
- height: 32,
283
- width: 32,
284
- decoration: BoxDecoration(
285
- color: Theme.of(context)
286
- .extension<SendPageTheme>()!
287
- .textFieldButtonColor,
288
- borderRadius: BorderRadius.all(Radius.circular(6))),
289
- child: InkWell(
290
- onTap: () => widget.allAmount?.call(),
291
- child: Center(
292
- child: Text(S.of(context).all,
293
- textAlign: TextAlign.center,
294
- style: TextStyle(
295
- fontSize: 12,
296
- fontWeight: FontWeight.bold,
297
- color: Theme.of(context)
298
- .extension<SendPageTheme>()!
299
- .textFieldButtonIconColor)),
300
- ),
301
- ),
302
- )
303
- ],
304
- ),
305
- ),
306
- ],
307
- )),
195
+ CurrencyAmountTextField(
196
+ imageArrow: widget.imageArrow,
197
+ selectedCurrency: _selectedCurrency.toString(),
198
+ amountFocusNode: widget.amountFocusNode,
199
+ amountController: amountController,
200
+ onTapPicker: () => _presentPicker(context),
201
+ isAmountEditable: _isAmountEditable,
202
+ isPickerEnable: true,
203
+ allAmountButton: widget.hasAllAmount,
204
+ currencyValueValidator: widget.currencyValueValidator,
205
+ tag: _selectedCurrency.tag,
206
+ allAmountCallback: widget.allAmount),
207
Divider(height: 1, color: Theme.of(context).extension<SendPageTheme>()!.textFieldHintColor),
208
Padding(
209
padding: EdgeInsets.only(top: 5),
lib/src/screens/receive/widgets/currency_input_field.dart
+188
-113
@@ -1,135 +1,210 @@
1
+import 'package:cake_wallet/generated/i18n.dart';
2
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
2
-import 'package:cake_wallet/utils/responsive_layout_util.dart';
3
-import 'package:cw_core/crypto_currency.dart';
4
-import 'package:cw_core/currency.dart';
3
+import 'package:cake_wallet/themes/extensions/exchange_page_theme.dart';
4
+import 'package:cake_wallet/themes/extensions/send_page_theme.dart';
5
+import 'package:cake_wallet/themes/theme_base.dart';
6
import 'package:flutter/material.dart';
7
import 'package:flutter/services.dart';
7
-import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
8
-import 'package:cake_wallet/themes/extensions/picker_theme.dart';
9
-import 'package:cake_wallet/themes/extensions/send_page_theme.dart';
8
11
-class CurrencyInputField extends StatelessWidget {
12
- const CurrencyInputField({
13
- super.key,
14
- required this.onTapPicker,
9
+class CurrencyAmountTextField extends StatelessWidget {
10
+ const CurrencyAmountTextField({
11
required this.selectedCurrency,
16
- this.focusNode,
17
- required this.controller,
18
- required this.isLight,
12
+ required this.amountFocusNode,
13
+ required this.amountController,
14
+ required this.isAmountEditable,
15
+ this.allAmountButton = false,
16
+ this.isPickerEnable = false,
17
+ this.isSelected = false,
18
+ this.currentTheme = ThemeType.dark,
19
+ this.onTapPicker,
20
+ this.padding,
21
+ this.imageArrow,
22
+ this.hintText,
23
+ this.tag,
24
+ this.tagBackgroundColor,
25
+ this.currencyValueValidator,
26
+ this.allAmountCallback,
27
});
28
21
- final Function() onTapPicker;
22
- final Currency selectedCurrency;
23
- final FocusNode? focusNode;
24
- final TextEditingController controller;
25
- final bool isLight;
26
-
27
- String get _currencyName {
28
- if (selectedCurrency is CryptoCurrency) {
29
- return (selectedCurrency as CryptoCurrency).title.toUpperCase();
30
- }
31
- return selectedCurrency.name.toUpperCase();
32
- }
29
+ final Widget? imageArrow;
30
+ final String selectedCurrency;
31
+ final String? tag;
32
+ final String? hintText;
33
+ final Color? tagBackgroundColor;
34
+ final EdgeInsets? padding;
35
+ final FocusNode? amountFocusNode;
36
+ final TextEditingController amountController;
37
+ final bool isAmountEditable;
38
+ final FormFieldValidator<String>? currencyValueValidator;
39
+ final bool isPickerEnable;
40
+ final ThemeType currentTheme;
41
+ final bool isSelected;
42
+ final bool allAmountButton;
43
+ final VoidCallback? allAmountCallback;
44
+ final VoidCallback? onTapPicker;
45
46
@override
47
Widget build(BuildContext context) {
36
- final arrowBottomPurple = Image.asset(
37
- 'assets/images/arrow_bottom_purple_icon.png',
38
- color: Theme.of(context).extension<DashboardPageTheme>()!.textColor,
39
- height: 8,
40
- );
41
- // This magic number for wider screen sets the text input focus at center of the inputfield
42
- final _width =
43
- responsiveLayoutUtil.shouldRenderMobileUI ? MediaQuery.of(context).size.width : 500;
44
-
45
- return Column(
48
+ final textColor = currentTheme == ThemeType.light
49
+ ? Theme.of(context).appBarTheme.titleTextStyle!.color!
50
+ : Colors.white;
51
+ final _prefixContent = Row(
52
children: [
47
- Padding(
48
- padding: EdgeInsets.only(top: 20),
49
- child: SizedBox(
50
- height: 40,
51
- child: BaseTextFormField(
52
- focusNode: focusNode,
53
- controller: controller,
54
- keyboardType: TextInputType.numberWithOptions(signed: false, decimal: true),
55
- inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r'^\d+(\.|\,)?\d{0,8}'))],
56
- hintText: '0.000',
57
- placeholderTextStyle: isLight
58
- ? null
59
- : TextStyle(
60
- color: Theme.of(context).extension<SendPageTheme>()!.textFieldBorderColor,
61
- fontWeight: FontWeight.w600,
62
- ),
63
- borderColor: Theme.of(context).extension<PickerTheme>()!.dividerColor,
64
- textColor: Theme.of(context).extension<DashboardPageTheme>()!.textColor,
65
- textStyle: TextStyle(
66
- color: Theme.of(context).extension<DashboardPageTheme>()!.textColor,
67
- ),
68
- prefixIcon: Padding(
69
- padding: EdgeInsets.only(
70
- left: _width / 4,
53
+ isPickerEnable
54
+ ? Container(
55
+ height: 32,
56
+ child: InkWell(
57
+ onTap: onTapPicker,
58
+ child: Row(
59
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
60
+ mainAxisSize: MainAxisSize.min,
61
+ children: <Widget>[
62
+ Padding(
63
+ padding: const EdgeInsets.only(right: 5),
64
+ child: imageArrow ??
65
+ Image.asset('assets/images/arrow_bottom_purple_icon.png',
66
+ color: textColor, height: 8)),
67
+ Text(
68
+ selectedCurrency,
69
+ style: TextStyle(
70
+ fontWeight: FontWeight.w600,
71
+ fontSize: 16,
72
+ color: textColor,
73
+ ),
74
+ ),
75
+ ],
76
+ ),
77
),
72
- child: Container(
73
- padding: EdgeInsets.only(right: 8),
74
- child: InkWell(
75
- onTap: onTapPicker,
76
- child: Row(
77
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
78
- mainAxisSize: MainAxisSize.min,
79
- children: <Widget>[
80
- Padding(
81
- padding: EdgeInsets.only(right: 5),
82
- child: arrowBottomPurple,
83
- ),
84
- Text(
85
- _currencyName,
86
- style: TextStyle(
87
- fontWeight: FontWeight.w600,
88
- fontSize: 16,
89
- color: Theme.of(context).extension<DashboardPageTheme>()!.textColor,
90
- ),
91
- ),
92
- if (selectedCurrency.tag != null)
93
- Padding(
94
- padding: const EdgeInsets.symmetric(horizontal: 3.0),
95
- child: Container(
96
- decoration: BoxDecoration(
97
- color: Theme.of(context).extension<SendPageTheme>()!.textFieldButtonColor,
98
- borderRadius: BorderRadius.all(
99
- Radius.circular(6),
100
- ),
101
- ),
102
- child: Center(
103
- child: Text(
104
- selectedCurrency.tag!,
105
- style: TextStyle(
106
- fontSize: 12,
107
- fontWeight: FontWeight.bold,
108
- color: Theme.of(context).extension<SendPageTheme>()!.textFieldButtonIconColor,
109
- ),
110
- ),
111
- ),
112
- ),
113
- ),
114
- Padding(
115
- padding: const EdgeInsets.only(bottom: 3.0),
116
- child: Text(
117
- ':',
118
- style: TextStyle(
119
- fontWeight: FontWeight.w600,
120
- fontSize: 20,
121
- color: Theme.of(context).extension<DashboardPageTheme>()!.textColor,
122
- ),
123
- ),
124
- ),
125
- ]),
78
+ )
79
+ : Text(
80
+ selectedCurrency,
81
+ style: TextStyle(
82
+ fontWeight: FontWeight.w600,
83
+ fontSize: 16,
84
+ color: textColor,
85
+ ),
86
+ ),
87
+ if (tag != null)
88
+ Padding(
89
+ padding: const EdgeInsets.symmetric(horizontal: 3.0),
90
+ child: Container(
91
+ height: 32,
92
+ decoration: BoxDecoration(
93
+ color: tagBackgroundColor ??
94
+ Theme.of(context).extension<SendPageTheme>()!.textFieldButtonColor,
95
+ borderRadius: const BorderRadius.all(Radius.circular(6)),
96
+ ),
97
+ child: Center(
98
+ child: Padding(
99
+ padding: const EdgeInsets.all(6.0),
100
+ child: Text(
101
+ tag!,
102
+ style: TextStyle(
103
+ fontSize: 12,
104
+ fontWeight: FontWeight.bold,
105
+ color: Theme.of(context).extension<SendPageTheme>()!.textFieldButtonIconColor,
106
+ ),
107
),
108
),
109
),
110
),
111
),
112
+ Padding(
113
+ padding: EdgeInsets.only(right: 4.0),
114
+ child: Text(
115
+ ':',
116
+ style: TextStyle(
117
+ fontWeight: FontWeight.w600,
118
+ fontSize: 16,
119
+ color: textColor,
120
+ ),
121
+ ),
122
),
123
],
124
);
125
+ return Padding(
126
+ padding: padding ?? const EdgeInsets.only(top: 20),
127
+ child: Row(
128
+ children: [
129
+ isSelected
130
+ ? Container(
131
+ child: _prefixContent,
132
+ padding: EdgeInsets.symmetric(vertical: 4, horizontal: 8),
133
+ margin: const EdgeInsets.only(right: 3),
134
+ decoration: BoxDecoration(
135
+ border: Border.all(
136
+ color: textColor,
137
+ ),
138
+ borderRadius: BorderRadius.circular(26),
139
+ color: Theme.of(context).primaryColor))
140
+ : _prefixContent,
141
+ Expanded(
142
+ child: Row(
143
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
144
+ children: [
145
+ Flexible(
146
+ child: FocusTraversalOrder(
147
+ order: NumericFocusOrder(1),
148
+ child: BaseTextFormField(
149
+ focusNode: amountFocusNode,
150
+ controller: amountController,
151
+ enabled: isAmountEditable,
152
+ textAlign: TextAlign.left,
153
+ keyboardType: const TextInputType.numberWithOptions(
154
+ signed: false,
155
+ decimal: true,
156
+ ),
157
+ inputFormatters: [
158
+ FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]')),
159
+ ],
160
+ hintText: hintText ?? '0.0000',
161
+ borderColor: Colors.transparent,
162
+ textStyle: TextStyle(
163
+ fontSize: 16,
164
+ fontWeight: FontWeight.w600,
165
+ color: textColor,
166
+ ),
167
+ placeholderTextStyle: TextStyle(
168
+ fontSize: 16,
169
+ fontWeight: FontWeight.w600,
170
+ color: currentTheme == ThemeType.light
171
+ ? Theme.of(context).appBarTheme.titleTextStyle!.color!
172
+ : Theme.of(context).extension<ExchangePageTheme>()!.hintTextColor,
173
+ ),
174
+ validator: isAmountEditable ? currencyValueValidator : null,
175
+ ),
176
+ ),
177
+ ),
178
+ if (allAmountButton)
179
+ Container(
180
+ height: 32,
181
+ width: 32,
182
+ decoration: BoxDecoration(
183
+ color: Theme.of(context).extension<SendPageTheme>()!.textFieldButtonColor,
184
+ borderRadius: const BorderRadius.all(Radius.circular(6)),
185
+ ),
186
+ child: InkWell(
187
+ onTap: allAmountCallback,
188
+ child: Center(
189
+ child: Text(
190
+ S.of(context).all,
191
+ textAlign: TextAlign.center,
192
+ style: TextStyle(
193
+ fontSize: 12,
194
+ fontWeight: FontWeight.bold,
195
+ color: Theme.of(context)
196
+ .extension<SendPageTheme>()!
197
+ .textFieldButtonIconColor,
198
+ ),
199
+ ),
200
+ ),
201
+ ),
202
+ ),
203
+ ],
204
+ ),
205
+ ),
206
+ ],
207
+ ),
208
+ );
209
}
210
}
lib/src/screens/receive/widgets/qr_widget.dart
+32
-12
@@ -1,11 +1,15 @@
1
import 'package:cake_wallet/entities/qr_view_data.dart';
2
+import 'package:cake_wallet/themes/extensions/picker_theme.dart';
3
import 'package:cake_wallet/themes/extensions/qr_code_theme.dart';
4
import 'package:cake_wallet/routes.dart';
5
import 'package:cake_wallet/src/screens/exchange/widgets/currency_picker.dart';
6
import 'package:cake_wallet/src/screens/receive/widgets/currency_input_field.dart';
7
+import 'package:cake_wallet/themes/theme_base.dart';
8
import 'package:cake_wallet/utils/brightness_util.dart';
9
+import 'package:cake_wallet/utils/responsive_layout_util.dart';
10
import 'package:cake_wallet/utils/show_bar.dart';
11
import 'package:cake_wallet/utils/show_pop_up.dart';
12
+import 'package:cw_core/crypto_currency.dart';
13
import 'package:flutter/material.dart';
14
import 'package:flutter/services.dart';
15
import 'package:flutter_mobx/flutter_mobx.dart';
@@ -38,6 +42,10 @@ class QRWidget extends StatelessWidget {
42
final copyImage = Image.asset('assets/images/copy_address.png',
43
color: Theme.of(context).extension<QRCodeTheme>()!.qrWidgetCopyButtonColor);
44
45
+ // This magic number for wider screen sets the text input focus at center of the inputfield
46
+ final _width =
47
+ responsiveLayoutUtil.shouldRenderMobileUI ? MediaQuery.of(context).size.width : 500;
48
+
49
return Center(
50
child: SingleChildScrollView(
51
child: Column(
@@ -85,8 +93,9 @@ class QRWidget extends StatelessWidget {
93
decoration: BoxDecoration(
94
border: Border.all(
95
width: 3,
88
- color:
89
- Theme.of(context).extension<DashboardPageTheme>()!.textColor,
96
+ color: Theme.of(context)
97
+ .extension<DashboardPageTheme>()!
98
+ .textColor,
99
),
100
),
101
child: Container(
@@ -116,20 +125,23 @@ class QRWidget extends StatelessWidget {
125
children: <Widget>[
126
Expanded(
127
child: Form(
119
- key: formKey,
120
- child: CurrencyInputField(
121
- focusNode: amountTextFieldFocusNode,
122
- controller: amountController,
123
- onTapPicker: () => _presentPicker(context),
124
- selectedCurrency: addressListViewModel.selectedCurrency,
125
- isLight: isLight,
126
- ),
127
- ),
128
+ key: formKey,
129
+ child: CurrencyAmountTextField(
130
+ selectedCurrency: _currencyName,
131
+ amountFocusNode: amountTextFieldFocusNode,
132
+ amountController: amountController,
133
+ padding: EdgeInsets.only(top: 20, left: _width / 4),
134
+ currentTheme: isLight ? ThemeType.light : ThemeType.dark,
135
+ isAmountEditable: true,
136
+ tag: addressListViewModel.selectedCurrency.tag,
137
+ onTapPicker: () => _presentPicker(context),
138
+ isPickerEnable: true)),
139
),
140
],
141
),
142
);
143
}),
144
+ Divider(height: 1, color: Theme.of(context).extension<PickerTheme>()!.dividerColor),
145
Padding(
146
padding: EdgeInsets.only(top: 20, bottom: 8),
147
child: Builder(
@@ -150,7 +162,8 @@ class QRWidget extends StatelessWidget {
162
style: TextStyle(
163
fontSize: 15,
164
fontWeight: FontWeight.w500,
153
- color: Theme.of(context).extension<DashboardPageTheme>()!.textColor),
165
+ color:
166
+ Theme.of(context).extension<DashboardPageTheme>()!.textColor),
167
),
168
),
169
Padding(
@@ -169,6 +182,13 @@ class QRWidget extends StatelessWidget {
182
);
183
}
184
185
+ String get _currencyName {
186
+ if (addressListViewModel.selectedCurrency is CryptoCurrency) {
187
+ return (addressListViewModel.selectedCurrency as CryptoCurrency).title.toUpperCase();
188
+ }
189
+ return addressListViewModel.selectedCurrency.name.toUpperCase();
190
+ }
191
+
192
void _presentPicker(BuildContext context) async {
193
await showPopUp<void>(
194
builder: (_) => CurrencyPicker(
lib/src/screens/send/send_template_page.dart
+1
-1
@@ -144,7 +144,7 @@ class SendTemplatePage extends BasePage {
144
.toList();
145
146
sendTemplateViewModel.addTemplate(
147
- isCurrencySelected: mainTemplate.isCurrencySelected,
147
+ isCurrencySelected: mainTemplate.isCryptoSelected,
148
name: mainTemplate.name,
149
address: mainTemplate.address,
150
cryptoCurrency: mainTemplate.selectedCurrency.title,
lib/src/screens/send/widgets/prefix_currency_icon_widget.dart
deleted
-65
@@ -1,65 +0,0 @@
1
-import 'package:cake_wallet/themes/extensions/send_page_theme.dart';
2
-import 'package:flutter/material.dart';
3
-
4
-class PrefixCurrencyIcon extends StatelessWidget {
5
- PrefixCurrencyIcon({
6
- required this.isSelected,
7
- required this.title,
8
- this.onTap,
9
- });
10
-
11
- final bool isSelected;
12
- final String title;
13
- final Function()? onTap;
14
-
15
- @override
16
- Widget build(BuildContext context) {
17
- return GestureDetector(
18
- onTap: onTap,
19
- child: Padding(
20
- padding: EdgeInsets.fromLTRB(0, 6.0, 8.0, 0),
21
- child: Column(
22
- children: [
23
- Container(
24
- padding: EdgeInsets.symmetric(vertical: 4, horizontal: 8),
25
- decoration: BoxDecoration(
26
- borderRadius: BorderRadius.circular(26),
27
- color: isSelected
28
- ? Theme.of(context)
29
- .extension<SendPageTheme>()!
30
- .templateSelectedCurrencyBackgroundColor
31
- : Colors.transparent,
32
- ),
33
- child: Row(
34
- mainAxisSize: MainAxisSize.min,
35
- children: <Widget>[
36
- if (onTap != null)
37
- Padding(
38
- padding: EdgeInsets.only(right: 5),
39
- child: Image.asset(
40
- 'assets/images/arrow_bottom_purple_icon.png',
41
- color: Colors.white,
42
- height: 8,
43
- ),
44
- ),
45
- Text(
46
- title + ':',
47
- style: TextStyle(
48
- fontSize: 16,
49
- fontWeight: FontWeight.w600,
50
- color: isSelected
51
- ? Theme.of(context)
52
- .extension<SendPageTheme>()!
53
- .templateSelectedCurrencyTitleColor
54
- : Colors.white,
55
- ),
56
- ),
57
- ],
58
- ),
59
- ),
60
- ],
61
- ),
62
- ),
63
- );
64
- }
65
-}
lib/src/screens/send/widgets/send_card.dart
+28
-200
@@ -1,4 +1,5 @@
1
import 'package:cake_wallet/entities/priority_for_wallet_type.dart';
2
+import 'package:cake_wallet/src/screens/receive/widgets/currency_input_field.dart';
3
import 'package:cake_wallet/src/widgets/picker.dart';
4
import 'package:cake_wallet/themes/extensions/keyboard_theme.dart';
5
import 'package:cake_wallet/src/screens/exchange/widgets/currency_picker.dart';
@@ -207,166 +208,19 @@ class SendCardState extends State<SendCard> with AutomaticKeepAliveClientMixin<S
208
textStyle: TextStyle(
209
fontSize: 14, fontWeight: FontWeight.w500, color: Colors.white),
210
validator: sendViewModel.addressValidator)),
210
- Observer(
211
- builder: (_) => Padding(
212
- padding: const EdgeInsets.only(top: 20),
213
- child: Row(
214
- children: [
215
- Padding(
216
- padding: const EdgeInsets.only(bottom: 8.0),
217
- child: Row(
218
- children: [
219
- sendViewModel.hasMultipleTokens
220
- ? Container(
221
- padding: EdgeInsets.only(right: 8),
222
- height: 32,
223
- child: InkWell(
224
- onTap: () => _presentPicker(context),
225
- child: Row(
226
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
227
- mainAxisSize: MainAxisSize.min,
228
- children: <Widget>[
229
- Padding(
230
- padding: EdgeInsets.only(right: 5),
231
- child: Image.asset(
232
- 'assets/images/arrow_bottom_purple_icon.png',
233
- color: Colors.white,
234
- height: 8,
235
- ),
236
- ),
237
- Text(
238
- sendViewModel.selectedCryptoCurrency.title,
239
- style: TextStyle(
240
- fontWeight: FontWeight.w600,
241
- fontSize: 16,
242
- color: Colors.white),
243
- ),
244
- ],
245
- ),
246
- ),
247
- )
248
- : Text(
249
- sendViewModel.selectedCryptoCurrency.title,
250
- style: TextStyle(
251
- fontWeight: FontWeight.w600,
252
- fontSize: 16,
253
- color: Colors.white),
254
- ),
255
- sendViewModel.selectedCryptoCurrency.tag != null
256
- ? Padding(
257
- padding: const EdgeInsets.fromLTRB(3.0, 0, 3.0, 0),
258
- child: Container(
259
- height: 32,
260
- decoration: BoxDecoration(
261
- color: Theme.of(context)
262
- .extension<SendPageTheme>()!
263
- .textFieldButtonColor,
264
- borderRadius: BorderRadius.all(
265
- Radius.circular(6),
266
- )),
267
- child: Center(
268
- child: Padding(
269
- padding: const EdgeInsets.all(6.0),
270
- child: Text(
271
- sendViewModel.selectedCryptoCurrency.tag!,
272
- style: TextStyle(
273
- fontSize: 12,
274
- fontWeight: FontWeight.bold,
275
- color: Theme.of(context)
276
- .extension<SendPageTheme>()!
277
- .textFieldButtonIconColor),
278
- ),
279
- ),
280
- ),
281
- ),
282
- )
283
- : Container(),
284
- Padding(
285
- padding: const EdgeInsets.only(right: 10.0),
286
- child: Text(
287
- ':',
288
- style: TextStyle(
289
- fontWeight: FontWeight.w600,
290
- fontSize: 16,
291
- color: Colors.white),
292
- ),
293
- ),
294
- ],
295
- ),
296
- ),
297
- Expanded(
298
- child: Stack(
299
- children: [
300
- BaseTextFormField(
301
- focusNode: cryptoAmountFocus,
302
- controller: cryptoAmountController,
303
- keyboardType: TextInputType.numberWithOptions(
304
- signed: false, decimal: true),
305
- inputFormatters: [
306
- FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]'))
307
- ],
308
- suffixIcon: SizedBox(
309
- width: prefixIconWidth,
310
- ),
311
- hintText: '0.0000',
312
- borderColor: Colors.transparent,
313
- textStyle: TextStyle(
314
- fontSize: 14,
315
- fontWeight: FontWeight.w500,
316
- color: Colors.white),
317
- placeholderTextStyle: TextStyle(
318
- color: Theme.of(context)
319
- .extension<SendPageTheme>()!
320
- .textFieldHintColor,
321
- fontWeight: FontWeight.w500,
322
- fontSize: 14),
323
- validator: output.sendAll
324
- ? sendViewModel.allAmountValidator
325
- : sendViewModel.amountValidator,
326
- ),
327
- if (!sendViewModel.isBatchSending)
328
- Positioned(
329
- top: 2,
330
- right: 0,
331
- child: Container(
332
- width: prefixIconWidth,
333
- height: prefixIconHeight,
334
- child: InkWell(
335
- onTap: () async {
336
- output.setSendAll(sendViewModel.balance);
337
- },
338
- child: Container(
339
- decoration: BoxDecoration(
340
- color: Theme.of(context)
341
- .extension<SendPageTheme>()!
342
- .textFieldButtonColor,
343
- borderRadius: BorderRadius.all(
344
- Radius.circular(6),
345
- ),
346
- ),
347
- child: Center(
348
- child: Text(
349
- S.of(context).all,
350
- textAlign: TextAlign.center,
351
- style: TextStyle(
352
- fontSize: 12,
353
- fontWeight: FontWeight.bold,
354
- color: Theme.of(context)
355
- .extension<SendPageTheme>()!
356
- .textFieldButtonIconColor,
357
- ),
358
- ),
359
- ),
360
- ),
361
- ),
362
- ),
363
- ),
364
- ],
365
- ),
366
- ),
367
- ],
368
- )),
369
- ),
211
+ CurrencyAmountTextField(
212
+ selectedCurrency: sendViewModel.selectedCryptoCurrency.title,
213
+ amountFocusNode: cryptoAmountFocus,
214
+ amountController: cryptoAmountController,
215
+ isAmountEditable: true,
216
+ onTapPicker: () => _presentPicker(context),
217
+ isPickerEnable: sendViewModel.hasMultipleTokens,
218
+ tag: sendViewModel.selectedCryptoCurrency.tag,
219
+ allAmountButton: !sendViewModel.isBatchSending,
220
+ currencyValueValidator: output.sendAll
221
+ ? sendViewModel.allAmountValidator
222
+ : sendViewModel.amountValidator,
223
+ allAmountCallback: () async => output.setSendAll(sendViewModel.balance)),
224
Divider(
225
height: 1,
226
color: Theme.of(context).extension<SendPageTheme>()!.textFieldHintColor),
@@ -402,41 +256,16 @@ class SendCardState extends State<SendCard> with AutomaticKeepAliveClientMixin<S
256
),
257
),
258
if (!sendViewModel.isFiatDisabled)
405
- Padding(
406
- padding: const EdgeInsets.only(top: 20),
407
- child: BaseTextFormField(
408
- focusNode: fiatAmountFocus,
409
- controller: fiatAmountController,
410
- keyboardType:
411
- TextInputType.numberWithOptions(signed: false, decimal: true),
412
- inputFormatters: [
413
- FilteringTextInputFormatter.deny(
414
- RegExp('[\\-|\\ ]'),
415
- )
416
- ],
417
- prefixIcon: Padding(
418
- padding: EdgeInsets.only(top: 9),
419
- child: Text(
420
- sendViewModel.fiat.title + ':',
421
- style: TextStyle(
422
- fontSize: 16,
423
- fontWeight: FontWeight.w600,
424
- color: Colors.white,
425
- ),
426
- ),
427
- ),
259
+ CurrencyAmountTextField(
260
+ selectedCurrency: sendViewModel.fiat.title,
261
+ amountFocusNode: fiatAmountFocus,
262
+ amountController: fiatAmountController,
263
hintText: '0.00',
429
- borderColor:
430
- Theme.of(context).extension<SendPageTheme>()!.textFieldBorderColor,
431
- textStyle: TextStyle(
432
- fontSize: 14, fontWeight: FontWeight.w500, color: Colors.white),
433
- placeholderTextStyle: TextStyle(
434
- color:
435
- Theme.of(context).extension<SendPageTheme>()!.textFieldHintColor,
436
- fontWeight: FontWeight.w500,
437
- fontSize: 14),
438
- ),
439
- ),
264
+ isAmountEditable: true,
265
+ allAmountButton: false),
266
+ Divider(
267
+ height: 1,
268
+ color: Theme.of(context).extension<SendPageTheme>()!.textFieldHintColor),
269
Padding(
270
padding: EdgeInsets.only(top: 20),
271
child: BaseTextFormField(
@@ -715,12 +544,11 @@ class SendCardState extends State<SendCard> with AutomaticKeepAliveClientMixin<S
544
showPopUp<void>(
545
context: context,
546
builder: (_) => CurrencyPicker(
718
- selectedAtIndex: sendViewModel.currencies.indexOf(sendViewModel.selectedCryptoCurrency),
719
- items: sendViewModel.currencies,
720
- hintText: S.of(context).search_currency,
721
- onItemSelected: (Currency cur) =>
722
- sendViewModel.selectedCryptoCurrency = (cur as CryptoCurrency),
723
- ),
547
+ selectedAtIndex: sendViewModel.currencies.indexOf(sendViewModel.selectedCryptoCurrency),
548
+ items: sendViewModel.currencies,
549
+ hintText: S.of(context).search_currency,
550
+ onItemSelected: (Currency cur) =>
551
+ sendViewModel.selectedCryptoCurrency = (cur as CryptoCurrency)),
552
);
553
}
554
lib/src/screens/send/widgets/send_template_card.dart
+81
-100
@@ -1,5 +1,5 @@
1
import 'package:cake_wallet/src/screens/exchange/widgets/currency_picker.dart';
2
-import 'package:cake_wallet/src/screens/send/widgets/prefix_currency_icon_widget.dart';
2
+import 'package:cake_wallet/src/screens/receive/widgets/currency_input_field.dart';
3
import 'package:cake_wallet/themes/extensions/send_page_theme.dart';
4
import 'package:cake_wallet/utils/payment_request.dart';
5
import 'package:cake_wallet/utils/show_pop_up.dart';
@@ -59,7 +59,8 @@ class SendTemplateCard extends StatelessWidget {
59
hintText: sendTemplateViewModel.recipients.length > 1
60
? S.of(context).template_name
61
: S.of(context).send_name,
62
- borderColor: Theme.of(context).extension<SendPageTheme>()!.textFieldBorderColor,
62
+ borderColor:
63
+ Theme.of(context).extension<SendPageTheme>()!.textFieldBorderColor,
64
textStyle:
65
TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Colors.white),
66
placeholderTextStyle: TextStyle(
@@ -69,107 +70,87 @@ class SendTemplateCard extends StatelessWidget {
70
validator: sendTemplateViewModel.templateValidator),
71
Padding(
72
padding: EdgeInsets.only(top: 20),
72
- child: Observer(
73
- builder: (context) {
74
- return AddressTextField(
75
- selectedCurrency: template.selectedCurrency,
76
- controller: _addressController,
77
- onURIScanned: (uri) {
78
- final paymentRequest = PaymentRequest.fromUri(uri);
79
- _addressController.text = paymentRequest.address;
80
- _cryptoAmountController.text = paymentRequest.amount;
81
- },
82
- options: [
83
- AddressTextFieldOption.paste,
84
- AddressTextFieldOption.qrCode,
85
- AddressTextFieldOption.addressBook
86
- ],
87
- onPushPasteButton: (context) async {
88
- template.output.resetParsedAddress();
89
- await template.output.fetchParsedAddress(context);
90
- },
91
- onPushAddressBookButton: (context) async {
92
- template.output.resetParsedAddress();
93
- await template.output.fetchParsedAddress(context);
94
- },
95
- buttonColor: Theme.of(context).extension<SendPageTheme>()!.textFieldButtonColor,
96
- borderColor: Theme.of(context).extension<SendPageTheme>()!.textFieldBorderColor,
97
- textStyle: TextStyle(
98
- fontSize: 14,
99
- fontWeight: FontWeight.w500,
100
- color: Colors.white,
101
- ),
102
- hintStyle: TextStyle(
103
- fontSize: 14,
104
- fontWeight: FontWeight.w500,
105
- color: Theme.of(context).extension<SendPageTheme>()!.textFieldHintColor,
106
- ),
107
- validator: sendTemplateViewModel.addressValidator,
108
- );
109
- }
110
- ),
111
- ),
112
- Padding(
113
- padding: const EdgeInsets.only(top: 20),
114
- child: Focus(
115
- onFocusChange: (hasFocus) {
116
- if (hasFocus) {
117
- template.selectCurrency();
118
- }
119
- },
120
- child: BaseTextFormField(
121
- focusNode: _cryptoAmountFocus,
122
- controller: _cryptoAmountController,
123
- keyboardType: TextInputType.numberWithOptions(signed: false, decimal: true),
124
- inputFormatters: [FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]'))],
125
- prefixIcon: Observer(
126
- builder: (_) => PrefixCurrencyIcon(
127
- title: template.selectedCurrency.title,
128
- isSelected: template.isCurrencySelected,
129
- onTap: sendTemplateViewModel.walletCurrencies.length > 1
130
- ? () => _presentPicker(context)
131
- : null,
132
- ),
133
- ),
134
- hintText: '0.0000',
135
- borderColor: Theme.of(context).extension<SendPageTheme>()!.textFieldBorderColor,
136
- textStyle:
137
- TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Colors.white),
138
- placeholderTextStyle: TextStyle(
139
- color: Theme.of(context).extension<SendPageTheme>()!.textFieldHintColor,
140
- fontWeight: FontWeight.w500,
141
- fontSize: 14),
142
- validator: sendTemplateViewModel.amountValidator,
143
- ),
144
- ),
145
- ),
146
- Padding(
147
- padding: const EdgeInsets.only(top: 20),
148
- child: Focus(
149
- onFocusChange: (hasFocus) {
150
- if (hasFocus) {
151
- template.selectFiat();
152
- }
153
- },
154
- child: BaseTextFormField(
155
- focusNode: _fiatAmountFocus,
156
- controller: _fiatAmountController,
157
- keyboardType: TextInputType.numberWithOptions(signed: false, decimal: true),
158
- inputFormatters: [FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]'))],
159
- prefixIcon: Observer(
160
- builder: (_) => PrefixCurrencyIcon(
161
- title: sendTemplateViewModel.fiatCurrency,
162
- isSelected: template.isFiatSelected)),
163
- hintText: '0.00',
164
- borderColor: Theme.of(context).extension<SendPageTheme>()!.textFieldBorderColor,
165
- textStyle:
166
- TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Colors.white),
167
- placeholderTextStyle: TextStyle(
168
- color: Theme.of(context).extension<SendPageTheme>()!.textFieldHintColor,
73
+ child: Observer(builder: (context) {
74
+ return AddressTextField(
75
+ selectedCurrency: template.selectedCurrency,
76
+ controller: _addressController,
77
+ onURIScanned: (uri) {
78
+ final paymentRequest = PaymentRequest.fromUri(uri);
79
+ _addressController.text = paymentRequest.address;
80
+ _cryptoAmountController.text = paymentRequest.amount;
81
+ },
82
+ options: [
83
+ AddressTextFieldOption.paste,
84
+ AddressTextFieldOption.qrCode,
85
+ AddressTextFieldOption.addressBook
86
+ ],
87
+ onPushPasteButton: (context) async {
88
+ template.output.resetParsedAddress();
89
+ await template.output.fetchParsedAddress(context);
90
+ },
91
+ onPushAddressBookButton: (context) async {
92
+ template.output.resetParsedAddress();
93
+ await template.output.fetchParsedAddress(context);
94
+ },
95
+ buttonColor:
96
+ Theme.of(context).extension<SendPageTheme>()!.textFieldButtonColor,
97
+ borderColor:
98
+ Theme.of(context).extension<SendPageTheme>()!.textFieldBorderColor,
99
+ textStyle: TextStyle(
100
+ fontSize: 14,
101
fontWeight: FontWeight.w500,
102
+ color: Colors.white,
103
+ ),
104
+ hintStyle: TextStyle(
105
fontSize: 14,
106
+ fontWeight: FontWeight.w500,
107
+ color: Theme.of(context).extension<SendPageTheme>()!.textFieldHintColor,
108
),
172
- ),
109
+ validator: sendTemplateViewModel.addressValidator,
110
+ );
111
+ }),
112
+ ),
113
+ Focus(
114
+ onFocusChange: (hasFocus) {
115
+ if (hasFocus) template.setCryptoCurrency(true);
116
+ },
117
+ child: Column(
118
+ children: [
119
+ Observer(
120
+ builder: (context) => CurrencyAmountTextField(
121
+ selectedCurrency: template.selectedCurrency.title,
122
+ amountFocusNode: _cryptoAmountFocus,
123
+ amountController: _cryptoAmountController,
124
+ isSelected: template.isCryptoSelected,
125
+ tag: template.selectedCurrency.tag,
126
+ isPickerEnable: sendTemplateViewModel.hasMultipleTokens,
127
+ onTapPicker: () => _presentPicker(context),
128
+ currencyValueValidator: sendTemplateViewModel.amountValidator,
129
+ isAmountEditable: true)),
130
+ Divider(
131
+ height: 1,
132
+ color: Theme.of(context).extension<SendPageTheme>()!.textFieldBorderColor)
133
+ ],
134
+ ),
135
+ ),
136
+ Focus(
137
+ onFocusChange: (hasFocus) {
138
+ if (hasFocus) template.setCryptoCurrency(false);
139
+ },
140
+ child: Column(
141
+ children: [
142
+ Observer(
143
+ builder: (context) => CurrencyAmountTextField(
144
+ selectedCurrency: sendTemplateViewModel.fiatCurrency,
145
+ amountFocusNode: _fiatAmountFocus,
146
+ amountController: _fiatAmountController,
147
+ isSelected: !template.isCryptoSelected,
148
+ hintText: '0.00',
149
+ isAmountEditable: true)),
150
+ Divider(
151
+ height: 1,
152
+ color: Theme.of(context).extension<SendPageTheme>()!.textFieldBorderColor)
153
+ ],
154
),
155
),
156
],
lib/view_model/send/send_template_view_model.dart
+5
@@ -1,3 +1,4 @@
1
+import 'package:cake_wallet/reactions/wallet_connect.dart';
2
import 'package:cake_wallet/view_model/send/template_view_model.dart';
3
import 'package:cw_core/crypto_currency.dart';
4
import 'package:cw_core/wallet_type.dart';
@@ -97,4 +98,8 @@ abstract class SendTemplateViewModelBase with Store {
98
99
@computed
100
List<CryptoCurrency> get walletCurrencies => _wallet.balance.keys.toList();
101
+
102
+ bool get hasMultipleTokens => isEVMCompatibleChain(_wallet.type) ||
103
+ _wallet.type == WalletType.solana ||
104
+ _wallet.type == WalletType.tron;
105
}
lib/view_model/send/template_view_model.dart
+5
-18
@@ -40,35 +40,22 @@ abstract class TemplateViewModelBase with Store {
40
CryptoCurrency _currency;
41
42
@observable
43
- bool isCurrencySelected = true;
44
-
45
- @observable
46
- bool isFiatSelected = false;
47
-
48
- @action
49
- void selectCurrency() {
50
- isCurrencySelected = true;
51
- isFiatSelected = false;
52
- }
43
+ bool isCryptoSelected = true;
44
45
@action
55
- void selectFiat() {
56
- isFiatSelected = true;
57
- isCurrencySelected = false;
58
- }
46
+ void setCryptoCurrency(bool value) => isCryptoSelected = value;
47
48
@action
49
void reset() {
50
name = '';
51
address = '';
64
- isCurrencySelected = true;
65
- isFiatSelected = false;
52
+ isCryptoSelected = true;
53
output.reset();
54
}
55
56
Template toTemplate({required String cryptoCurrency, required String fiatCurrency}) {
57
return Template(
71
- isCurrencySelectedRaw: isCurrencySelected,
58
+ isCurrencySelectedRaw: isCryptoSelected,
59
nameRaw: name,
60
addressRaw: address,
61
cryptoCurrencyRaw: cryptoCurrency,
@@ -79,7 +66,7 @@ abstract class TemplateViewModelBase with Store {
66
67
@action
68
void changeSelectedCurrency(CryptoCurrency currency) {
82
- isCurrencySelected = true;
69
+ isCryptoSelected = true;
70
_currency = currency;
71
}
72