save

fosse committed Sep 18, 2023 at 14:57 UTC ed5a139490a733107faae03857de6480f378bc87
1 file changed +49 -70
lib/src/screens/send/send_page.dart
+49 -70
@@ -66,9 +66,8 @@ class SendPage extends BasePage {
66 color: titleColor(context),
67 size: 16,
68 );
69 - final _closeButton = currentTheme.type == ThemeType.dark
70 - ? closeButtonImageDarkTheme
71 - : closeButtonImage;
69 + final _closeButton =
70 + currentTheme.type == ThemeType.dark ? closeButtonImageDarkTheme : closeButtonImage;
71
72 bool isMobileView = ResponsiveLayoutUtil.instance.isMobile;
73
@@ -79,13 +78,10 @@ class SendPage extends BasePage {
78 child: ButtonTheme(
79 minWidth: double.minPositive,
80 child: Semantics(
82 - label: !isMobileView
83 - ? S.of(context).close
84 - : S.of(context).seed_alert_back,
81 + label: !isMobileView ? S.of(context).close : S.of(context).seed_alert_back,
82 child: TextButton(
83 style: ButtonStyle(
87 - overlayColor: MaterialStateColor.resolveWith(
88 - (states) => Colors.transparent),
84 + overlayColor: MaterialStateColor.resolveWith((states) => Colors.transparent),
85 ),
86 onPressed: () => onClose(context),
87 child: !isMobileView ? _closeButton : _backButton,
@@ -123,8 +119,7 @@ class SendPage extends BasePage {
119 Padding(
120 padding: const EdgeInsets.only(right: 8.0),
121 child: Observer(
126 - builder: (_) =>
127 - SyncIndicatorIcon(isSynced: sendViewModel.isReadyForSend),
122 + builder: (_) => SyncIndicatorIcon(isSynced: sendViewModel.isReadyForSend),
123 ),
124 ),
125 if (supMiddle != null) supMiddle
@@ -158,10 +153,10 @@ class SendPage extends BasePage {
153 _setEffects(context);
154
155 return GestureDetector(
161 - onLongPress: () => sendViewModel.balanceViewModel.isReversing =
162 - !sendViewModel.balanceViewModel.isReversing,
163 - onLongPressUp: () => sendViewModel.balanceViewModel.isReversing =
164 - !sendViewModel.balanceViewModel.isReversing,
156 + onLongPress: () =>
157 + sendViewModel.balanceViewModel.isReversing = !sendViewModel.balanceViewModel.isReversing,
158 + onLongPressUp: () =>
159 + sendViewModel.balanceViewModel.isReversing = !sendViewModel.balanceViewModel.isReversing,
160 child: Form(
161 key: _formKey,
162 child: ScrollableWithBottomSection(
@@ -191,8 +186,7 @@ class SendPage extends BasePage {
186 },
187 )),
188 Padding(
194 - padding: EdgeInsets.only(
195 - top: 10, left: 24, right: 24, bottom: 10),
189 + padding: EdgeInsets.only(top: 10, left: 24, right: 24, bottom: 10),
190 child: Container(
191 height: 10,
192 child: Observer(
@@ -208,8 +202,12 @@ class SendPage extends BasePage {
202 radius: 6.0,
203 dotWidth: 6.0,
204 dotHeight: 6.0,
211 - dotColor: Theme.of(context).extension<SendPageTheme>()!.indicatorDotColor,
212 - activeDotColor: Theme.of(context).extension<SendPageTheme>()!.templateBackgroundColor),
205 + dotColor: Theme.of(context)
206 + .extension<SendPageTheme>()!
207 + .indicatorDotColor,
208 + activeDotColor: Theme.of(context)
209 + .extension<SendPageTheme>()!
210 + .templateBackgroundColor),
211 )
212 : Offstage();
213 },
@@ -230,8 +228,7 @@ class SendPage extends BasePage {
228 return Row(
229 children: <Widget>[
230 AddTemplateButton(
233 - onTap: () => Navigator.of(context)
234 - .pushNamed(Routes.sendTemplate),
231 + onTap: () => Navigator.of(context).pushNamed(Routes.sendTemplate),
232 currentTemplatesLength: templates.length,
233 ),
234 ListView.builder(
@@ -244,9 +241,8 @@ class SendPage extends BasePage {
241 return TemplateTile(
242 key: UniqueKey(),
243 to: template.name,
247 - hasMultipleRecipients:
248 - template.additionalRecipients != null &&
249 - template.additionalRecipients!.length > 1,
244 + hasMultipleRecipients: template.additionalRecipients != null &&
245 + template.additionalRecipients!.length > 1,
246 amount: template.isCurrencySelected
247 ? template.amount
248 : template.amountFiat,
@@ -257,7 +253,9 @@ class SendPage extends BasePage {
253 if (template.additionalRecipients?.isNotEmpty ?? false) {
254 sendViewModel.clearOutputs();
255
260 - for (int i = 0;i < template.additionalRecipients!.length;i++) {
256 + for (int i = 0;
257 + i < template.additionalRecipients!.length;
258 + i++) {
259 Output output;
260 try {
261 output = sendViewModel.outputs[i];
@@ -286,26 +284,17 @@ class SendPage extends BasePage {
284 context: context,
285 builder: (dialogContext) {
286 return AlertWithTwoActions(
289 - alertTitle:
290 - S.of(context).template,
291 - alertContent: S
292 - .of(context)
293 - .confirm_delete_template,
294 - rightButtonText:
295 - S.of(context).delete,
296 - leftButtonText:
297 - S.of(context).cancel,
287 + alertTitle: S.of(context).template,
288 + alertContent: S.of(context).confirm_delete_template,
289 + rightButtonText: S.of(context).delete,
290 + leftButtonText: S.of(context).cancel,
291 actionRightButton: () {
299 - Navigator.of(dialogContext)
300 - .pop();
301 - sendViewModel
302 - .sendTemplateViewModel
303 - .removeTemplate(
304 - template: template);
292 + Navigator.of(dialogContext).pop();
293 + sendViewModel.sendTemplateViewModel
294 + .removeTemplate(template: template);
295 },
296 actionLeftButton: () =>
307 - Navigator.of(dialogContext)
308 - .pop());
297 + Navigator.of(dialogContext).pop());
298 },
299 );
300 },
@@ -321,8 +310,7 @@ class SendPage extends BasePage {
310 ],
311 ),
312 ),
324 - bottomSectionPadding:
325 - EdgeInsets.only(left: 24, right: 24, bottom: 24),
313 + bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24),
314 bottomSection: Column(
315 children: [
316 if (sendViewModel.hasCurrecyChanger)
@@ -331,10 +319,10 @@ class SendPage extends BasePage {
319 padding: EdgeInsets.only(bottom: 12),
320 child: PrimaryButton(
321 onPressed: () => presentCurrencyPicker(context),
334 - text:
335 - 'Change your asset (${sendViewModel.selectedCryptoCurrency})',
322 + text: 'Change your asset (${sendViewModel.selectedCryptoCurrency})',
323 color: Colors.transparent,
337 - textColor: Theme.of(context).extension<SeedWidgetTheme>()!.hintTextColor,
324 + textColor:
325 + Theme.of(context).extension<SeedWidgetTheme>()!.hintTextColor,
326 ))),
327 if (sendViewModel.sendTemplateViewModel.hasMultiRecipient)
328 Padding(
@@ -343,22 +331,21 @@ class SendPage extends BasePage {
331 onPressed: () {
332 sendViewModel.addOutput();
333 Future.delayed(const Duration(milliseconds: 250), () {
346 - controller
347 - .jumpToPage(sendViewModel.outputs.length - 1);
334 + controller.jumpToPage(sendViewModel.outputs.length - 1);
335 });
336 },
337 text: S.of(context).add_receiver,
338 color: Colors.transparent,
339 textColor: Theme.of(context).extension<SeedWidgetTheme>()!.hintTextColor,
340 isDottedBorder: true,
354 - borderColor: Theme.of(context).extension<SendPageTheme>()!.templateDottedBorderColor,
341 + borderColor:
342 + Theme.of(context).extension<SendPageTheme>()!.templateDottedBorderColor,
343 )),
344 Observer(
345 builder: (_) {
346 return LoadingPrimaryButton(
347 onPressed: () async {
360 - if (_formKey.currentState != null &&
361 - !_formKey.currentState!.validate()) {
348 + if (_formKey.currentState != null && !_formKey.currentState!.validate()) {
349 if (sendViewModel.outputs.length > 1) {
350 showErrorValidationAlert(context);
351 }
@@ -367,9 +354,7 @@ class SendPage extends BasePage {
354 }
355
356 final notValidItems = sendViewModel.outputs
370 - .where((item) =>
371 - item.address.isEmpty ||
372 - item.cryptoAmount.isEmpty)
357 + .where((item) => item.address.isEmpty || item.cryptoAmount.isEmpty)
358 .toList();
359
360 if (notValidItems.isNotEmpty) {
@@ -389,8 +374,7 @@ class SendPage extends BasePage {
374 );
375 },
376 text: S.of(context).send,
392 - color:
393 - Theme.of(context).primaryColor,
377 + color: Theme.of(context).primaryColor,
378 textColor: Colors.white,
379 isLoading: sendViewModel.state is IsExecutingState ||
380 sendViewModel.state is TransactionCommitting,
@@ -433,14 +417,11 @@ class SendPage extends BasePage {
417 return ConfirmSendingAlert(
418 alertTitle: S.of(context).confirm_sending,
419 amount: S.of(context).send_amount,
436 - amountValue:
437 - sendViewModel.pendingTransaction!.amountFormatted,
438 - fiatAmountValue:
439 - sendViewModel.pendingTransactionFiatAmountFormatted,
420 + amountValue: sendViewModel.pendingTransaction!.amountFormatted,
421 + fiatAmountValue: sendViewModel.pendingTransactionFiatAmountFormatted,
422 fee: S.of(context).send_fee,
423 feeValue: sendViewModel.pendingTransaction!.feeFormatted,
442 - feeFiatAmount: sendViewModel
443 - .pendingTransactionFeeFiatAmountFormatted,
424 + feeFiatAmount: sendViewModel.pendingTransactionFeeFiatAmountFormatted,
425 outputs: sendViewModel.outputs,
426 rightButtonText: S.of(context).ok,
427 leftButtonText: S.of(context).cancel,
@@ -461,8 +442,7 @@ class SendPage extends BasePage {
442 return AlertWithOneAction(
443 alertTitle: '',
444 alertContent: S.of(context).send_success(
464 - sendViewModel.selectedCryptoCurrency
465 - .toString()),
445 + sendViewModel.selectedCryptoCurrency.toString()),
446 buttonText: S.of(context).ok,
447 buttonAction: () {
448 Navigator.of(context).pop();
@@ -492,8 +472,8 @@ class SendPage extends BasePage {
472
473 Future<void> _setInputsFromTemplate(BuildContext context,
474 {required Output output, required Template template}) async {
495 - final fiatFromTemplate = FiatCurrency.all
496 - .singleWhere((element) => element.title == template.fiatCurrency);
475 + final fiatFromTemplate =
476 + FiatCurrency.all.singleWhere((element) => element.title == template.fiatCurrency);
477
478 output.address = template.address;
479
@@ -534,12 +514,11 @@ class SendPage extends BasePage {
514 builder: (_) => Picker(
515 items: sendViewModel.currencies,
516 displayItem: (Object item) => item.toString(),
537 - selectedAtIndex: sendViewModel.currencies
538 - .indexOf(sendViewModel.selectedCryptoCurrency),
517 + selectedAtIndex:
518 + sendViewModel.currencies.indexOf(sendViewModel.selectedCryptoCurrency),
519 title: S.of(context).please_select,
520 mainAxisAlignment: MainAxisAlignment.center,
541 - onItemSelected: (CryptoCurrency cur) =>
542 - sendViewModel.selectedCryptoCurrency = cur,
521 + onItemSelected: (CryptoCurrency cur) => sendViewModel.selectedCryptoCurrency = cur,
522 ),
523 context: context);
524 }