diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 0be0bed48..cdf7de566 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -26,7 +26,7 @@ import 'package:cake_wallet/store/yat/yat_store.dart'; import 'package:cake_wallet/src/screens/yat/yat_sending.dart'; class SendPage extends BasePage { - SendPage({@required this.sendViewModel}) :_formKey = GlobalKey(); + SendPage({@required this.sendViewModel}) : _formKey = GlobalKey(); final SendViewModel sendViewModel; final GlobalKey _formKey; @@ -51,24 +51,24 @@ class SendPage extends BasePage { @override Widget trailing(context) => Observer(builder: (_) { - return sendViewModel.isBatchSending - ? TrailButton( - caption: S.of(context).remove, - onPressed: () { - var pageToJump = controller.page.round() - 1; - pageToJump = pageToJump > 0 ? pageToJump : 0; - final output = _defineCurrentOutput(); - sendViewModel.removeOutput(output); - controller.jumpToPage(pageToJump); - }) - : TrailButton( - caption: S.of(context).clear, - onPressed: () { - final output = _defineCurrentOutput(); - _formKey.currentState.reset(); - output.reset(); - }); - }); + return sendViewModel.isBatchSending + ? TrailButton( + caption: S.of(context).remove, + onPressed: () { + var pageToJump = controller.page.round() - 1; + pageToJump = pageToJump > 0 ? pageToJump : 0; + final output = _defineCurrentOutput(); + sendViewModel.removeOutput(output); + controller.jumpToPage(pageToJump); + }) + : TrailButton( + caption: S.of(context).clear, + onPressed: () { + final output = _defineCurrentOutput(); + _formKey.currentState.reset(); + output.reset(); + }); + }); @override Widget body(BuildContext context) { @@ -96,57 +96,39 @@ class SendPage extends BasePage { output: output, sendViewModel: sendViewModel, ); - } - ); + }); }, - ) - ), + )), Padding( - padding: EdgeInsets.only(top: 10, left: 24, right: 24, bottom: 10), - child: Container( - height: 10, - child: Observer(builder: (_) { - final count = sendViewModel.outputs.length; + padding: + EdgeInsets.only(top: 10, left: 24, right: 24, bottom: 10), + child: Container( + height: 10, + child: Observer( + builder: (_) { + final count = sendViewModel.outputs.length; - return count > 1 + return count > 1 ? SmoothPageIndicator( - controller: controller, - count: count, - effect: ScrollingDotsEffect( - spacing: 6.0, - radius: 6.0, - dotWidth: 6.0, - dotHeight: 6.0, - dotColor: Theme.of(context) - .primaryTextTheme - .display2 - .backgroundColor, - activeDotColor: Theme.of(context) - .primaryTextTheme - .display3 - .backgroundColor + controller: controller, + count: count, + effect: ScrollingDotsEffect( + spacing: 6.0, + radius: 6.0, + dotWidth: 6.0, + dotHeight: 6.0, + dotColor: Theme.of(context) + .primaryTextTheme + .display2 + .backgroundColor, + activeDotColor: Theme.of(context) + .primaryTextTheme + .display3 + .backgroundColor), ) - ) : Offstage(); - }) - ) - ), - Padding( - padding: EdgeInsets.only(left: 24, bottom: 24), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - S.of(context).send_templates, - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w600, - color: Theme.of(context) - .primaryTextTheme - .display4 - .color), - ) - ], + }, + ), ), ), Container( @@ -155,51 +137,60 @@ class SendPage extends BasePage { padding: EdgeInsets.only(left: 24), child: SingleChildScrollView( scrollDirection: Axis.horizontal, - child: Row( - children: [ - GestureDetector( - onTap: () => Navigator.of(context) - .pushNamed(Routes.sendTemplate), - child: Container( - padding: EdgeInsets.only(left: 1, right: 10), - child: DottedBorder( - borderType: BorderType.RRect, - dashPattern: [6, 4], - color: Theme.of(context) - .primaryTextTheme - .display2 - .decorationColor, - strokeWidth: 2, - radius: Radius.circular(20), - child: Container( - height: 34, - width: 75, - padding: - EdgeInsets.only(left: 10, right: 10), - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(20)), - color: Colors.transparent, - ), - child: Text( - S.of(context).send_new, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - color: Theme.of(context) - .primaryTextTheme - .display3 - .color), - ), - )), - ), - ), - Observer(builder: (_) { - final templates = sendViewModel.templates; - final itemCount = templates.length; + child: Observer( + builder: (_) { + final templates = sendViewModel.templates; + final itemCount = templates.length; - return ListView.builder( + return Row( + children: [ + GestureDetector( + onTap: () => Navigator.of(context) + .pushNamed(Routes.sendTemplate), + child: Container( + padding: EdgeInsets.only(left: 1, right: 10), + child: DottedBorder( + borderType: BorderType.RRect, + dashPattern: [6, 4], + color: Theme.of(context) + .primaryTextTheme + .headline2 + .decorationColor, + strokeWidth: 2, + radius: Radius.circular(20), + child: Container( + height: 34, + padding: EdgeInsets.only(left: 10, right: 10), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(20)), + color: Colors.transparent, + ), + child: templates.length >= 1 + ? Icon( + Icons.add, + color: Theme.of(context) + .primaryTextTheme + .display3 + .color, + ) + : Text( + S.of(context).new_template, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: Theme.of(context) + .primaryTextTheme + .display3 + .color, + ), + ), + ), + ), + ), + ), + ListView.builder( scrollDirection: Axis.horizontal, shrinkWrap: true, physics: NeverScrollableScrollPhysics(), @@ -214,109 +205,108 @@ class SendPage extends BasePage { from: template.cryptoCurrency, onTap: () async { final output = _defineCurrentOutput(); - output.address = - template.address; + output.address = template.address; output.setCryptoAmount(template.amount); output.resetParsedAddress(); await output.fetchParsedAddress(context); }, onRemove: () { showPopUp( - context: context, - builder: (dialogContext) { - return AlertWithTwoActions( - alertTitle: - S.of(context).template, - alertContent: S - .of(context) - .confirm_delete_template, - rightButtonText: - S.of(context).delete, - leftButtonText: - S.of(context).cancel, - actionRightButton: () { + context: context, + builder: (dialogContext) { + return AlertWithTwoActions( + alertTitle: S.of(context).template, + alertContent: S + .of(context) + .confirm_delete_template, + rightButtonText: S.of(context).delete, + leftButtonText: S.of(context).cancel, + actionRightButton: () { + Navigator.of(dialogContext).pop(); + sendViewModel.sendTemplateViewModel + .removeTemplate( + template: template); + }, + actionLeftButton: () => Navigator.of(dialogContext) - .pop(); - sendViewModel - .sendTemplateViewModel - .removeTemplate( - template: template); - }, - actionLeftButton: () => - Navigator.of(dialogContext) - .pop()); - }); + .pop()); + }, + ); }, ); - }); - }) - ], + }, + ), + ], + ); + }, ), ), ) ], ), bottomSectionPadding: - EdgeInsets.only(left: 24, right: 24, bottom: 24), + EdgeInsets.only(left: 24, right: 24, bottom: 24), bottomSection: Column( children: [ Padding( - padding: EdgeInsets.only(bottom: 12), - child: PrimaryButton( - onPressed: () { - sendViewModel.addOutput(); - Future.delayed(const Duration(milliseconds: 250), () { - controller.jumpToPage(sendViewModel.outputs.length - 1); - }); - }, - text: S.of(context).add_receiver, - color: Colors.transparent, - textColor: Theme.of(context) - .accentTextTheme - .display2 - .decorationColor, - isDottedBorder: true, - borderColor: Theme.of(context) - .primaryTextTheme - .display2 - .decorationColor, - ) - ), - Observer(builder: (_) { - return LoadingPrimaryButton( - onPressed: () async { - if (!_formKey.currentState.validate()) { - if (sendViewModel.outputs.length > 1) { - showErrorValidationAlert(context); + padding: EdgeInsets.only(bottom: 12), + child: PrimaryButton( + onPressed: () { + sendViewModel.addOutput(); + Future.delayed(const Duration(milliseconds: 250), () { + controller.jumpToPage(sendViewModel.outputs.length - 1); + }); + }, + text: S.of(context).add_receiver, + color: Colors.transparent, + textColor: Theme.of(context) + .accentTextTheme + .display2 + .decorationColor, + isDottedBorder: true, + borderColor: Theme.of(context) + .primaryTextTheme + .display2 + .decorationColor, + )), + Observer( + builder: (_) { + return LoadingPrimaryButton( + onPressed: () async { + if (!_formKey.currentState.validate()) { + if (sendViewModel.outputs.length > 1) { + showErrorValidationAlert(context); + } + + return; } - return; - } + final notValidItems = sendViewModel.outputs + .where((item) => + item.address.isEmpty || item.cryptoAmount.isEmpty) + .toList(); - final notValidItems = sendViewModel.outputs - .where((item) => - item.address.isEmpty || item.cryptoAmount.isEmpty) - .toList(); + if (notValidItems?.isNotEmpty ?? false) { + showErrorValidationAlert(context); + return; + } - if (notValidItems?.isNotEmpty ?? false) { - showErrorValidationAlert(context); - return; - } + await sendViewModel.createTransaction(); - await sendViewModel.createTransaction(); - - if (!sendViewModel.isBatchSending && sendViewModel.hasYat) { - Navigator.of(context).push(YatSending.createRoute(sendViewModel)); - } - }, - text: S.of(context).send, - color: Theme.of(context).accentTextTheme.body2.color, - textColor: Colors.white, - isLoading: sendViewModel.state is IsExecutingState || - sendViewModel.state is TransactionCommitting, - isDisabled: !sendViewModel.isReadyForSend, - ); - }, + if (!sendViewModel.isBatchSending && + sendViewModel.hasYat) { + Navigator.of(context) + .push(YatSending.createRoute(sendViewModel)); + } + }, + text: S.of(context).send, + color: Theme.of(context).accentTextTheme.body2.color, + textColor: Colors.white, + isLoading: sendViewModel.state is IsExecutingState || + sendViewModel.state is TransactionCommitting, + isDisabled: !sendViewModel.isReadyForSend, + ); + }, ) ], )), @@ -343,8 +333,8 @@ class SendPage extends BasePage { }); } - if (state is ExecutedSuccessfullyState - && !(!sendViewModel.isBatchSending && sendViewModel.hasYat)) { + if (state is ExecutedSuccessfullyState && + !(!sendViewModel.isBatchSending && sendViewModel.hasYat)) { WidgetsBinding.instance.addPostFrameCallback((_) { showPopUp( context: context, @@ -353,13 +343,17 @@ class SendPage extends BasePage { alertTitle: S.of(context).confirm_sending, amount: S.of(context).send_amount, amountValue: - sendViewModel.pendingTransaction.amountFormatted, - fiatAmountValue: sendViewModel.pendingTransactionFiatAmount - + ' ' + sendViewModel.fiat.title, + sendViewModel.pendingTransaction.amountFormatted, + fiatAmountValue: + sendViewModel.pendingTransactionFiatAmount + + ' ' + + sendViewModel.fiat.title, fee: S.of(context).send_fee, feeValue: sendViewModel.pendingTransaction.feeFormatted, - feeFiatAmount: sendViewModel.pendingTransactionFeeFiatAmount - + ' ' + sendViewModel.fiat.title, + feeFiatAmount: + sendViewModel.pendingTransactionFeeFiatAmount + + ' ' + + sendViewModel.fiat.title, outputs: sendViewModel.outputs, rightButtonText: S.of(context).ok, leftButtonText: S.of(context).cancel, @@ -380,8 +374,7 @@ class SendPage extends BasePage { return AlertWithOneAction( alertTitle: '', alertContent: S.of(context).send_success( - sendViewModel.currency - .toString()), + sendViewModel.currency.toString()), buttonText: S.of(context).ok, buttonAction: () => Navigator.of(context).pop()); @@ -419,8 +412,7 @@ class SendPage extends BasePage { alertTitle: S.of(context).error, alertContent: 'Please, check receiver forms', buttonText: S.of(context).ok, - buttonAction: () => - Navigator.of(context).pop()); + buttonAction: () => Navigator.of(context).pop()); }); } } diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index 10b1a24d6..882638f0e 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -516,5 +516,7 @@ "second_intro_content" : "Ihr Yat ist eine einzige eindeutige Emoji-Adresse, die alle Ihre langen hexadezimalen Adressen für alle Ihre Währungen ersetzt.", "third_intro_title" : "Yat spielt gut mit anderen", "third_intro_content" : "Yats leben auch außerhalb von Cake Wallet. Jede Wallet-Adresse auf der Welt kann durch ein Yat ersetzt werden!", - "learn_more" : "Erfahren Sie mehr" + "learn_more" : "Erfahren Sie mehr", + + "new_template" : "neue Vorlage" } diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index a8d17ddd7..788f6551a 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -517,5 +517,7 @@ "second_intro_content" : "Your Yat is a single unique emoji address that replaces all of your long hexadecimal addresses for all of your currencies.", "third_intro_title" : "Yat plays nicely with others", "third_intro_content" : "Yats live outside of Cake Wallet, too. Any wallet address on earth can be replaced with a Yat!", - "learn_more" : "Learn More" + "learn_more" : "Learn More", + + "new_template" : "New Template" } \ No newline at end of file diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 8ccf07954..c17536d33 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -516,5 +516,7 @@ "second_intro_content" : "Tu Yat es una única dirección emoji única que reemplaza todas tus direcciones hexadecimales largas para todas tus monedas.", "third_intro_title" : "Yat juega muy bien con otras", "third_intro_content" : "Los Yats también viven fuera de Cake Wallet. Cualquier dirección de billetera en la tierra se puede reemplazar con un Yat!", - "learn_more" : "Aprende más" + "learn_more" : "Aprende más", + + "new_template" : "Nueva plantilla" } \ No newline at end of file diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index 1925f6a9d..f1f6b8812 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -516,5 +516,7 @@ "second_intro_content" : "आपका Yat एक अद्वितीय इमोजी पता है जो आपकी सभी मुद्राओं के लिए आपके सभी लंबे हेक्साडेसिमल पतों को बदल देता है।", "third_intro_title" : "Yat दूसरों के साथ अच्छा खेलता है", "third_intro_content" : "Yats Cake Wallet के बाहर भी रहता है। धरती पर किसी भी वॉलेट पते को Yat से बदला जा सकता है!", - "learn_more" : "और अधिक जानें" + "learn_more" : "और अधिक जानें", + + "new_template" : "नया टेम्पलेट" } \ No newline at end of file diff --git a/res/values/strings_hr.arb b/res/values/strings_hr.arb index 7659d1a86..b382617b1 100644 --- a/res/values/strings_hr.arb +++ b/res/values/strings_hr.arb @@ -516,5 +516,7 @@ "second_intro_content" : "Vaš Yat jedinstvena je adresa emojija koja zamjenjuje sve vaše duge heksadecimalne adrese za sve vaše valute.", "third_intro_title" : "Yat se lijepo igra s drugima", "third_intro_content" : "Yats žive i izvan Cake Wallet -a. Bilo koja adresa novčanika na svijetu može se zamijeniti Yat!", - "learn_more" : "Saznajte više" + "learn_more" : "Saznajte više", + + "new_template" : "novi predložak" } \ No newline at end of file diff --git a/res/values/strings_it.arb b/res/values/strings_it.arb index b8dd1cef7..ff3e23dae 100644 --- a/res/values/strings_it.arb +++ b/res/values/strings_it.arb @@ -516,5 +516,7 @@ "second_intro_content" : "Il tuo Yat è un unico indirizzo emoji univoco che sostituisce tutti i tuoi lunghi indirizzi esadecimali per tutte le tue valute.", "third_intro_title" : "Yat gioca bene con gli altri", "third_intro_content" : "Anche Yats vive fuori da Cake Wallet. Qualsiasi indirizzo di portafoglio sulla terra può essere sostituito con un Yat!", - "learn_more" : "Impara di più" + "learn_more" : "Impara di più", + + "new_template" : "Nuovo modello" } \ No newline at end of file diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index 0450e5e14..508e08935 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -516,5 +516,7 @@ "second_intro_content" : "Yatは、すべての通貨のすべての長い16進アドレスを置き換える単一の一意の絵文字アドレスです。", "third_intro_title" : "Yatは他の人とうまく遊ぶ", "third_intro_content" : "YatsはCakeWalletの外にも住んでいます。 地球上のどのウォレットアドレスもYatに置き換えることができます!", - "learn_more" : "もっと詳しく知る" + "learn_more" : "もっと詳しく知る", + + "new_template" : "新しいテンプレート" } \ No newline at end of file diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index bb8caeff7..3d0cc4d61 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -516,5 +516,7 @@ "second_intro_content" : "귀하의 Yat는 귀하의 모든 통화에 대해 긴 16진수 주소를 모두 대체하는 고유한 단일 이모지 주소입니다.", "third_intro_title" : "Yat는 다른 사람들과 잘 놉니다.", "third_intro_content" : "Yats는 Cake Wallet 밖에서도 살고 있습니다. 지구상의 모든 지갑 주소는 Yat!", - "learn_more" : "더 알아보기" + "learn_more" : "더 알아보기", + + "new_template" : "새 템플릿" } \ No newline at end of file diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index 2de1ae319..425b976f7 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -516,5 +516,7 @@ "second_intro_content" : "Je Yat is een enkel uniek emoji-adres dat al je lange hexadecimale adressen vervangt voor al je valuta's.", "third_intro_title" : "Yat speelt leuk met anderen", "third_intro_content" : "Yats wonen ook buiten Cake Wallet. Elk portemonnee-adres op aarde kan worden vervangen door een Yat!", - "learn_more" : "Kom meer te weten" + "learn_more" : "Kom meer te weten", + + "new_template" : "Nieuwe sjabloon" } \ No newline at end of file diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index 3fe508e01..b3e98b1d3 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -516,5 +516,7 @@ "second_intro_content" : "Twój Yat to jeden unikalny adres emoji, który zastępuje wszystkie Twoje długie adresy szesnastkowe dla wszystkich Twoich walut.", "third_intro_title" : "Yat ładnie bawi się z innymi", "third_intro_content" : "Yats mieszkają również poza Cake Wallet. Każdy adres portfela na ziemi można zastąpić Yat!", - "learn_more" : "Ucz się więcej" + "learn_more" : "Ucz się więcej", + + "new_template" : "Nowy szablon" } \ No newline at end of file diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index e93c66f09..e378f81a1 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -516,5 +516,7 @@ "second_intro_content" : "Seu Yat é um endereço de emoji único e exclusivo que substitui todos os seus endereços hexadecimais longos para todas as suas moedas.", "third_intro_title" : "Yat joga bem com os outros", "third_intro_content" : "Yats também mora fora da Cake Wallet. Qualquer endereço de carteira na Terra pode ser substituído por um Yat!", - "learn_more" : "Saber mais" + "learn_more" : "Saber mais", + + "new_template" : "Novo modelo" } \ No newline at end of file diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index 6404f11d6..e65ceeffa 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -516,5 +516,7 @@ "second_intro_content" : "Ваш Yat - это единственный уникальный адрес эмодзи, который заменяет длинные шестнадцатеричные адреса для всех ваших валют.", "third_intro_title" : "Yat хорошо взаимодействует с другими", "third_intro_content" : "Yat находятся за пределами Cake Wallet. Любой адрес кошелька на земле можно заменить на Yat!", - "learn_more" : "Узнать больше" + "learn_more" : "Узнать больше", + + "new_template" : "Новый шаблон" } \ No newline at end of file diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index f9b414ddb..03a4522af 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -516,5 +516,7 @@ "second_intro_content" : "Ваш Yat - це єдина унікальна адреса емодзі, яка замінює довгі шістнадцятиричні адреси для всіх ваших валют.", "third_intro_title" : "Yat добре взаємодіє з іншими", "third_intro_content" : "Yat знаходиться за межами Cake Wallet. Будь-яку адресу гаманця на землі можна замінити на Yat!", - "learn_more" : "Дізнатися більше" + "learn_more" : "Дізнатися більше", + + "new_template" : "Новий шаблон" } \ No newline at end of file diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index 06edeb632..ae4638919 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -516,5 +516,7 @@ "second_intro_content" : "您的 Yat 是一個唯一的表情符號地址,可替換您所有貨幣的所有長十六進制地址。", "third_intro_title" : "Yat 和別人玩得很好", "third_intro_content" : "Yats 也住在 Cake Wallet 之外。 地球上任何一個錢包地址都可以用一個Yat來代替!", - "learn_more" : "了解更多" + "learn_more" : "了解更多", + + "new_template" : "新模板" } \ No newline at end of file