From 30a32ab07163d207d13f0b163c10aa4c8cb0ee0e Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Thu, 12 Aug 2021 17:56:34 +0300 Subject: [PATCH] CAKE-345 | fixed add receiver button; applied dotted borders to primary button; applied localization to add receiver button; added scrollbar to confirm_sending_alert.dart --- lib/src/screens/send/send_page.dart | 15 +- .../send/widgets/confirm_sending_alert.dart | 424 +++++++++++------- lib/src/widgets/cake_scrollbar.dart | 6 +- lib/src/widgets/primary_button.dart | 19 +- lib/view_model/send/send_view_model.dart | 4 +- res/values/strings_de.arb | 2 +- res/values/strings_en.arb | 2 +- res/values/strings_es.arb | 2 +- res/values/strings_hi.arb | 2 +- res/values/strings_hr.arb | 2 +- res/values/strings_it.arb | 2 +- res/values/strings_ja.arb | 2 +- res/values/strings_ko.arb | 2 +- res/values/strings_nl.arb | 2 +- res/values/strings_pl.arb | 2 +- res/values/strings_pt.arb | 2 +- res/values/strings_ru.arb | 2 +- res/values/strings_uk.arb | 2 +- res/values/strings_zh.arb | 2 +- 19 files changed, 314 insertions(+), 182 deletions(-) diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 01f9fc71..c355e099 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -264,10 +264,21 @@ class SendPage extends BasePage { 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.green, - textColor: Colors.white, + color: Colors.transparent, + textColor: Theme.of(context) + .accentTextTheme + .display2 + .decorationColor, + isDottedBorder: true, + borderColor: Theme.of(context) + .primaryTextTheme + .display2 + .decorationColor, ) ), Observer(builder: (_) { diff --git a/lib/src/screens/send/widgets/confirm_sending_alert.dart b/lib/src/screens/send/widgets/confirm_sending_alert.dart index f6defa98..009340b2 100644 --- a/lib/src/screens/send/widgets/confirm_sending_alert.dart +++ b/lib/src/screens/send/widgets/confirm_sending_alert.dart @@ -3,6 +3,7 @@ import 'package:cake_wallet/view_model/send/output.dart'; import 'package:flutter/material.dart'; import 'package:cake_wallet/src/widgets/base_alert_dialog.dart'; import 'package:cake_wallet/generated/i18n.dart'; +import 'package:cake_wallet/src/widgets/cake_scrollbar.dart'; class ConfirmSendingAlert extends BaseAlertDialog { ConfirmSendingAlert({ @@ -18,13 +19,7 @@ class ConfirmSendingAlert extends BaseAlertDialog { @required this.rightButtonText, @required this.actionLeftButton, @required this.actionRightButton, - this.alertBarrierDismissible = true - }) { - itemCount = outputs.length; - recipientTitle = itemCount > 1 - ? S.current.transaction_details_recipient_address - : S.current.recipient_address; - } + this.alertBarrierDismissible = true}); final String alertTitle; final String amount; @@ -40,9 +35,6 @@ class ConfirmSendingAlert extends BaseAlertDialog { final VoidCallback actionRightButton; final bool alertBarrierDismissible; - String recipientTitle; - int itemCount; - @override String get titleText => alertTitle; @@ -65,131 +57,184 @@ class ConfirmSendingAlert extends BaseAlertDialog { bool get barrierDismissible => alertBarrierDismissible; @override - Widget content(BuildContext context) { - return Container( - height: 200, - child: SingleChildScrollView( - child: Column( - children: [ - Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - amount, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.normal, - fontFamily: 'Lato', - color: Theme.of(context).primaryTextTheme.title.color, - decoration: TextDecoration.none, - ), - ), - Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - amountValue, - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w600, - fontFamily: 'Lato', - color: Theme.of(context).primaryTextTheme.title.color, - decoration: TextDecoration.none, - ), - ), - Text( - fiatAmountValue, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - fontFamily: 'Lato', - color: PaletteDark.pigeonBlue, - decoration: TextDecoration.none, - ), - ) - ], - ) - ], - ), - Padding( - padding: EdgeInsets.only(top: 16), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, + Widget content(BuildContext context) => ConfirmSendingAlertContent( + amount: amount, + amountValue: amountValue, + fiatAmountValue: fiatAmountValue, + fee: fee, + feeValue: feeValue, + feeFiatAmount: feeFiatAmount, + outputs: outputs + ); +} + +class ConfirmSendingAlertContent extends StatefulWidget { + ConfirmSendingAlertContent({ + @required this.amount, + @required this.amountValue, + @required this.fiatAmountValue, + @required this.fee, + @required this.feeValue, + @required this.feeFiatAmount, + @required this.outputs}); + + final String amount; + final String amountValue; + final String fiatAmountValue; + final String fee; + final String feeValue; + final String feeFiatAmount; + final List outputs; + + @override + ConfirmSendingAlertContentState createState() => ConfirmSendingAlertContentState( + amount: amount, + amountValue: amountValue, + fiatAmountValue: fiatAmountValue, + fee: fee, + feeValue: feeValue, + feeFiatAmount: feeFiatAmount, + outputs: outputs + ); +} + +class ConfirmSendingAlertContentState extends State { + ConfirmSendingAlertContentState({ + @required this.amount, + @required this.amountValue, + @required this.fiatAmountValue, + @required this.fee, + @required this.feeValue, + @required this.feeFiatAmount, + @required this.outputs}) { + + itemCount = outputs.length; + recipientTitle = itemCount > 1 + ? S.current.transaction_details_recipient_address + : S.current.recipient_address; + } + + final String amount; + final String amountValue; + final String fiatAmountValue; + final String fee; + final String feeValue; + final String feeFiatAmount; + final List outputs; + + final double backgroundHeight = 160; + final double thumbHeight = 72; + ScrollController controller = ScrollController(); + double fromTop = 0; + String recipientTitle; + int itemCount; + + @override + Widget build(BuildContext context) { + controller.addListener(() { + fromTop = controller.hasClients + ? (controller.offset / controller.position.maxScrollExtent * + (backgroundHeight - thumbHeight)) + : 0; + setState(() {}); + }); + + return Stack( + alignment: Alignment.center, + clipBehavior: Clip.none, + children: [ + Container( + height: 200, + child: SingleChildScrollView( + controller: controller, + child: Column( children: [ - Text( - fee, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.normal, - fontFamily: 'Lato', - color: Theme.of(context).primaryTextTheme.title.color, - decoration: TextDecoration.none, - ), - ), - Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ + Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ Text( - feeValue, + amount, style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w600, + fontSize: 16, + fontWeight: FontWeight.normal, fontFamily: 'Lato', - color: Theme.of(context).primaryTextTheme.title.color, + color: Theme.of(context) + .primaryTextTheme + .title + .color, decoration: TextDecoration.none, ), ), - Text( - feeFiatAmount, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - fontFamily: 'Lato', - color: PaletteDark.pigeonBlue, - decoration: TextDecoration.none, - ), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + amountValue, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w600, + fontFamily: 'Lato', + color: Theme.of(context) + .primaryTextTheme + .title + .color, + decoration: TextDecoration.none, + ), + ), + Text( + fiatAmountValue, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + fontFamily: 'Lato', + color: PaletteDark.pigeonBlue, + decoration: TextDecoration.none, + ), + ) + ], ) ], - ) - ], - ) - ), - Padding( - padding: EdgeInsets.only(top: 16), - child: Column( - children: [ - Text( - '$recipientTitle:', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.normal, - fontFamily: 'Lato', - color: Theme.of(context).primaryTextTheme.title.color, - decoration: TextDecoration.none, ), - ), - itemCount > 1 - ? ListView.builder( - padding: EdgeInsets.only(top: 0), - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemCount: itemCount, - itemBuilder: (context, index) { - final item = outputs[index]; - final _address = item.address; - final _amount = - item.cryptoAmount.replaceAll(',', '.'); - - return Column( - children: [ - Padding( - padding: EdgeInsets.only(top: 8), - child: Text( - _address, + Padding( + padding: EdgeInsets.only(top: 16), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + fee, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.normal, + fontFamily: 'Lato', + color: Theme.of(context) + .primaryTextTheme + .title + .color, + decoration: TextDecoration.none, + ), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + feeValue, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w600, + fontFamily: 'Lato', + color: Theme.of(context) + .primaryTextTheme + .title + .color, + decoration: TextDecoration.none, + ), + ), + Text( + feeFiatAmount, style: TextStyle( fontSize: 12, fontWeight: FontWeight.w600, @@ -198,49 +243,104 @@ class ConfirmSendingAlert extends BaseAlertDialog { decoration: TextDecoration.none, ), ) + ], + ) + ], + ) + ), + Padding( + padding: EdgeInsets.only(top: 16), + child: Column( + children: [ + Text( + '$recipientTitle:', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.normal, + fontFamily: 'Lato', + color: Theme.of(context) + .primaryTextTheme + .title + .color, + decoration: TextDecoration.none, ), - Padding( - padding: EdgeInsets.only(top: 8), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.end, + ), + itemCount > 1 + ? ListView.builder( + padding: EdgeInsets.only(top: 0), + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemCount: itemCount, + itemBuilder: (context, index) { + final item = outputs[index]; + final _address = item.address; + final _amount = + item.cryptoAmount.replaceAll(',', '.'); + + return Column( children: [ - Text( - _amount, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - fontFamily: 'Lato', - color: PaletteDark.pigeonBlue, - decoration: TextDecoration.none, - ), + Padding( + padding: EdgeInsets.only(top: 8), + child: Text( + _address, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + fontFamily: 'Lato', + color: PaletteDark.pigeonBlue, + decoration: TextDecoration.none, + ), + ) + ), + Padding( + padding: EdgeInsets.only(top: 8), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Text( + _amount, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + fontFamily: 'Lato', + color: PaletteDark.pigeonBlue, + decoration: TextDecoration.none, + ), + ) + ], + ) ) ], - ) - ) - ], - ); - } - ) - : Padding( - padding: EdgeInsets.only(top: 8), - child: Text( - outputs.first.address, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - fontFamily: 'Lato', - color: PaletteDark.pigeonBlue, - decoration: TextDecoration.none, + ); + }) + : Padding( + padding: EdgeInsets.only(top: 8), + child: Text( + outputs.first.address, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + fontFamily: 'Lato', + color: PaletteDark.pigeonBlue, + decoration: TextDecoration.none, + ), + ), + ) + ], ), - ), - ) - ], - ), + ) + ], + ) ) - ], - ) - ) + ), + if (itemCount > 1) CakeScrollbar( + backgroundHeight: backgroundHeight, + thumbHeight: thumbHeight, + fromTop: fromTop, + rightOffset: -15 + ) + ] ); } } \ No newline at end of file diff --git a/lib/src/widgets/cake_scrollbar.dart b/lib/src/widgets/cake_scrollbar.dart index 90b571c9..6ccf391c 100644 --- a/lib/src/widgets/cake_scrollbar.dart +++ b/lib/src/widgets/cake_scrollbar.dart @@ -4,17 +4,19 @@ class CakeScrollbar extends StatelessWidget { CakeScrollbar({ @required this.backgroundHeight, @required this.thumbHeight, - @required this.fromTop + @required this.fromTop, + this.rightOffset = 6 }); final double backgroundHeight; final double thumbHeight; final double fromTop; + final double rightOffset; @override Widget build(BuildContext context) { return Positioned( - right: 6, + right: rightOffset, child: Container( height: backgroundHeight, width: 6, diff --git a/lib/src/widgets/primary_button.dart b/lib/src/widgets/primary_button.dart index 929bcd89..1b12d5d3 100644 --- a/lib/src/widgets/primary_button.dart +++ b/lib/src/widgets/primary_button.dart @@ -1,3 +1,4 @@ +import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -8,18 +9,22 @@ class PrimaryButton extends StatelessWidget { @required this.color, @required this.textColor, this.isDisabled = false, + this.isDottedBorder = false, + this.borderColor = Colors.black, this.onDisabledPressed}); final VoidCallback onPressed; final VoidCallback onDisabledPressed; final Color color; final Color textColor; + final Color borderColor; final String text; final bool isDisabled; + final bool isDottedBorder; @override Widget build(BuildContext context) { - return ButtonTheme( + final content = ButtonTheme( minWidth: double.infinity, height: 52.0, child: FlatButton( @@ -27,6 +32,8 @@ class PrimaryButton extends StatelessWidget { ? (onDisabledPressed != null ? onDisabledPressed : null) : onPressed, color: isDisabled ? color.withOpacity(0.5) : color, + splashColor: Colors.transparent, + highlightColor: Colors.transparent, disabledColor: color.withOpacity(0.5), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(26.0), @@ -40,6 +47,16 @@ class PrimaryButton extends StatelessWidget { ? textColor.withOpacity(0.5) : textColor)), )); + + return isDottedBorder + ? DottedBorder( + borderType: BorderType.RRect, + dashPattern: [6, 4], + color: borderColor, + strokeWidth: 2, + radius: Radius.circular(26), + child: content) + : content; } } diff --git a/lib/view_model/send/send_view_model.dart b/lib/view_model/send/send_view_model.dart index 6efad2c0..650b7402 100644 --- a/lib/view_model/send/send_view_model.dart +++ b/lib/view_model/send/send_view_model.dart @@ -58,7 +58,9 @@ abstract class SendViewModelBase with Store { @action void removeOutput(Output output) { - outputs.remove(output); + if (isBatchSending) { + outputs.remove(output); + } } @action diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index 9b46b5d1..4f093dcd 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -494,5 +494,5 @@ "address_detected" : "Adresse erkannt", "address_from_domain" : "Sie haben die Adresse von der unaufhaltsamen Domain ${domain} erhalten", - "add_receiver" : "Empfänger hinzufügen" + "add_receiver" : "Fügen Sie einen weiteren Empfänger hinzu (optional)" } diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index 5699dabe..e03de8a1 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -494,5 +494,5 @@ "address_detected" : "Address detected", "address_from_domain" : "You got address from unstoppable domain ${domain}", - "add_receiver" : "Add receiver" + "add_receiver" : "Add another receiver (optional)" } \ No newline at end of file diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index bcfd44dd..fa4f4026 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -494,5 +494,5 @@ "address_detected" : "Dirección detectada", "address_from_domain" : "Tienes la dirección de unstoppable domain ${domain}", - "add_receiver" : "Agregar receptor" + "add_receiver" : "Agregar otro receptor (opcional)" } \ No newline at end of file diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index e147f97c..73f22dc1 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -494,5 +494,5 @@ "address_detected" : "पता लग गया", "address_from_domain" : "आपको अजेय डोमेन ${domain} से पता मिला है", - "add_receiver" : "रिसीवर जोड़ें" + "add_receiver" : "एक और रिसीवर जोड़ें (वैकल्पिक)" } \ No newline at end of file diff --git a/res/values/strings_hr.arb b/res/values/strings_hr.arb index 6361aae0..29a47286 100644 --- a/res/values/strings_hr.arb +++ b/res/values/strings_hr.arb @@ -494,5 +494,5 @@ "address_detected" : "Adresa je otkrivena", "address_from_domain" : "Dobili ste adresu od unstoppable domain ${domain}", - "add_receiver" : "Dodajte prijamnik" + "add_receiver" : "Dodajte drugi prijemnik (izborno)" } \ No newline at end of file diff --git a/res/values/strings_it.arb b/res/values/strings_it.arb index 484fc83e..a5dd4e6c 100644 --- a/res/values/strings_it.arb +++ b/res/values/strings_it.arb @@ -494,5 +494,5 @@ "address_detected" : "Indirizzo rilevato", "address_from_domain" : "Hai l'indirizzo da unstoppable domain ${domain}", - "add_receiver" : "Aggiungi ricevitore" + "add_receiver" : "Aggiungi un altro ricevitore (opzionale)" } \ No newline at end of file diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index ab4846c7..feb9a507 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -494,5 +494,5 @@ "address_detected" : "アドレスが検出されました", "address_from_domain" : "あなたはからアドレスを得ました unstoppable domain ${domain}", - "add_receiver" : "レシーバーを追加" + "add_receiver" : "別のレシーバーを追加します(オプション)" } \ No newline at end of file diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index 93f36dee..54ec0a56 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -494,5 +494,5 @@ "address_detected" : "주소 감지", "address_from_domain" : "주소는 unstoppable domain ${domain}", - "add_receiver" : "수신기 추가" + "add_receiver" : "다른 수신기 추가(선택 사항)" } \ No newline at end of file diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index f53361b8..6f88e3da 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -494,5 +494,5 @@ "address_detected" : "Adres gedetecteerd", "address_from_domain" : "Je adres is van unstoppable domain ${domain}", - "add_receiver" : "Ontvanger toevoegen" + "add_receiver" : "Nog een ontvanger toevoegen (optioneel)" } \ No newline at end of file diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index 378d890c..d1da847e 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -494,5 +494,5 @@ "address_detected" : "Wykryto adres", "address_from_domain" : "Dostałeś adres od unstoppable domain ${domain}", - "add_receiver" : "Dodaj odbiorcę" + "add_receiver" : "Dodaj kolejny odbiornik (opcjonalnie)" } \ No newline at end of file diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index 2a3de257..7145e40b 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -494,5 +494,5 @@ "address_detected" : "Endereço detectado", "address_from_domain" : "Você obteve o endereço de unstoppable domain ${domain}", - "add_receiver" : "Adicionar receptor" + "add_receiver" : "Adicione outro receptor (opcional)" } \ No newline at end of file diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index 3595a677..6d2a7c12 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -494,5 +494,5 @@ "address_detected" : "Обнаружен адрес", "address_from_domain" : "Вы получили адрес из unstoppable domain ${domain}", - "add_receiver" : "Добавить получателя" + "add_receiver" : "Добавить получателя (необязательно)" } \ No newline at end of file diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index cb69df4b..db2c34f9 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -494,5 +494,5 @@ "address_detected" : "Виявлено адресу", "address_from_domain" : "Ви отримали адресу від unstoppable domain ${domain}", - "add_receiver" : "Додати одержувача" + "add_receiver" : "Додати одержувача (необов'язково)" } \ No newline at end of file diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index a083178b..66e25e60 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -494,5 +494,5 @@ "address_detected" : "檢測到地址", "address_from_domain" : "您有以下地址 unstoppable domain ${domain}", - "add_receiver" : "添加接收器" + "add_receiver" : "添加另一個接收器(可選)" } \ No newline at end of file