diff --git a/lib/generated/i18n.dart b/lib/generated/i18n.dart index d7ee6dafe..28804f461 100644 --- a/lib/generated/i18n.dart +++ b/lib/generated/i18n.dart @@ -5049,7 +5049,7 @@ class $pl extends S { @override String get settings_change_language => "Zmień język"; @override - String get clear => "Jasny"; + String get clear => "Wyczyść"; @override String get settings_change_pin => "Zmień PIN"; @override diff --git a/lib/router.dart b/lib/router.dart index 03b041b35..44cbf4501 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -239,9 +239,12 @@ class Router { case Routes.sendTemplate: return CupertinoPageRoute( - builder: (_) => SendTemplatePage( - sendStore: settings.arguments as SendStore, - ) + builder: (_) => Provider( + create: (_) => SendStore( + walletService: walletService, + priceStore: priceStore, + transactionDescriptions: transactionDescriptions), + child: SendTemplatePage()) ); case Routes.receive: diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index d04c63cba..1881e891c 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -40,6 +40,32 @@ class SendPage extends BasePage { @override bool get resizeToAvoidBottomPadding => false; + @override + Widget trailing(context) { + final sendStore = Provider.of(context); + + return Container( + height: 32, + width: 82, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(16)), + color: PaletteDark.menuHeader + ), + child: ButtonTheme( + minWidth: double.minPositive, + child: FlatButton( + onPressed: () => sendStore.clear(), + child: Text( + S.of(context).clear, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 10.0, + color: Colors.blue), + )), + ), + ); + } + @override Widget body(BuildContext context) => SendForm(); } @@ -201,6 +227,7 @@ class SendFormState extends State { onTap: () => sendStore.setSendAll(), child: Center( child: Text(S.of(context).all, + textAlign: TextAlign.center, style: TextStyle( fontSize: 9, fontWeight: FontWeight.bold, @@ -270,6 +297,27 @@ class SendFormState extends State { color: PaletteDark.walletCardSubAddressField, width: 1.0)))), ), + Padding( + padding: const EdgeInsets.only(top: 20), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(S.of(context).send_estimated_fee, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Colors.white, + )), + Text( + '${calculateEstimatedFee(priority: settingsStore.transactionPriority)} XMR', + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Colors.white, + )) + ], + ), + ) ]), ), ), @@ -434,6 +482,20 @@ class SendFormState extends State { } }); + reaction((_) => sendStore.address, (String address) { + if (address != _addressController.text) { + _addressController.text = address; + } + }); + + _addressController.addListener(() { + final address = _addressController.text; + + if (sendStore.address != address) { + sendStore.changeAddress(address); + } + }); + _fiatAmountController.addListener(() { final fiatAmount = _fiatAmountController.text; diff --git a/lib/src/screens/send/send_template_page.dart b/lib/src/screens/send/send_template_page.dart index dfdb37a5c..1326aac51 100644 --- a/lib/src/screens/send/send_template_page.dart +++ b/lib/src/screens/send/send_template_page.dart @@ -17,10 +17,6 @@ import 'package:cake_wallet/src/widgets/top_panel.dart'; import 'package:cake_wallet/src/stores/send_template/send_template_store.dart'; class SendTemplatePage extends BasePage { - SendTemplatePage({@required this.sendStore}); - - final SendStore sendStore; - @override String get title => S.current.send_title; @@ -31,23 +27,15 @@ class SendTemplatePage extends BasePage { bool get resizeToAvoidBottomPadding => false; @override - Widget body(BuildContext context) => SendTemplateForm(sendStore); + Widget body(BuildContext context) => SendTemplateForm(); } class SendTemplateForm extends StatefulWidget { - SendTemplateForm(this.sendStore); - - final SendStore sendStore; - @override - SendTemplateFormState createState() => SendTemplateFormState(sendStore); + SendTemplateFormState createState() => SendTemplateFormState(); } class SendTemplateFormState extends State { - SendTemplateFormState(this.sendStore); - - final SendStore sendStore; - final _nameController = TextEditingController(); final _addressController = TextEditingController(); final _cryptoAmountController = TextEditingController(); @@ -70,9 +58,11 @@ class SendTemplateFormState extends State { Widget build(BuildContext context) { final settingsStore = Provider.of(context); final balanceStore = Provider.of(context); + final sendStore = Provider.of(context); + sendStore.settingsStore = settingsStore; final sendTemplateStore = Provider.of(context); - _setEffects(context, sendStore); + _setEffects(context); return Container( color: PaletteDark.historyPanel, @@ -163,30 +153,6 @@ class SendTemplateFormState extends State { color: Colors.white, )), ), - suffixIcon: Padding( - padding: EdgeInsets.only( - bottom: 5 - ), - child: Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - width: MediaQuery.of(context).size.width/2, - alignment: Alignment.centerLeft, - child: Text( - ' / ' + balanceStore.unlockedBalance, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 16, - color: PaletteDark.walletCardText - ) - ), - ), - ], - ), - ), hintStyle: TextStyle( fontSize: 16.0, color: Colors.white), @@ -199,11 +165,7 @@ class SendTemplateFormState extends State { borderSide: BorderSide( color: PaletteDark.walletCardSubAddressField, width: 1.0))), - validator: (value) { - sendStore.validateXMR( - value, balanceStore.unlockedBalance); - return sendStore.errorMessage; - }), + ), ); } ), @@ -271,12 +233,12 @@ class SendTemplateFormState extends State { ); } - void _setEffects(BuildContext context, SendStore sendStore) { + void _setEffects(BuildContext context) { if (_effectsInstalled) { return; } - //final sendStore = Provider.of(context); + final sendStore = Provider.of(context); reaction((_) => sendStore.fiatAmount, (String amount) { if (amount != _fiatAmountController.text) { diff --git a/lib/src/stores/send/send_store.dart b/lib/src/stores/send/send_store.dart index 5f0df3541..77323a518 100644 --- a/lib/src/stores/send/send_store.dart +++ b/lib/src/stores/send/send_store.dart @@ -45,6 +45,9 @@ abstract class SendStoreBase with Store { @observable String cryptoAmount; + @observable + String address; + @observable bool isValid; @@ -157,6 +160,18 @@ abstract class SendStoreBase with Store { } } + @action + void changeAddress(String address) { + this.address = address; + } + + @action + void clear() { + address = ''; + cryptoAmount = ''; + fiatAmount = ''; + } + Future isOpenaliasRecord(String name) async { final _openaliasRecord = await OpenaliasRecord .fetchAddressAndName(OpenaliasRecord.formatDomainName(name)); diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index 5d8715241..ae81e924f 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -58,7 +58,7 @@ "exchange" : "Wymieniać się", - "clear" : "Jasny", + "clear" : "Wyczyść", "change_exchange_provider" : "Zmień dostawcę programu Exchange", "you_will_send" : "Wyślesz", "you_will_get" : "Dostaniesz",