From 20c35451d59a76ff0b991ae11c4ce671a33ce09d Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Mon, 12 Oct 2020 19:47:01 +0300 Subject: [PATCH] CAKE-120 | added xmr.to exchange description to exchange and exchange template pages; made observable isReceiveAmountEntered parameter in the exchange view model; added isReceiveAmountEntered parameter to applyTemplate() (exchange page) and reset() (exchange view model); added possibility to enter amount in receive card (exchange template page) --- lib/src/screens/exchange/exchange_page.dart | 5 ++++- .../exchange/exchange_template_page.dart | 17 +++++++++++++++-- .../exchange/exchange_view_model.dart | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/src/screens/exchange/exchange_page.dart b/lib/src/screens/exchange/exchange_page.dart index bf587776f..09483a67d 100644 --- a/lib/src/screens/exchange/exchange_page.dart +++ b/lib/src/screens/exchange/exchange_page.dart @@ -373,7 +373,9 @@ class ExchangePage extends BasePage { child: Observer(builder: (_) { final description = exchangeViewModel.provider is XMRTOExchangeProvider - ? S.of(context).amount_is_guaranteed + ? exchangeViewModel.isReceiveAmountEntered + ? S.of(context).amount_is_guaranteed + : S.of(context).amount_is_estimate : S.of(context).amount_is_estimate; return Center( child: Text( @@ -433,6 +435,7 @@ class ExchangePage extends BasePage { exchangeViewModel.changeDepositAmount(amount: template.amount); exchangeViewModel.depositAddress = template.depositAddress; exchangeViewModel.receiveAddress = template.receiveAddress; + exchangeViewModel.isReceiveAmountEntered = false; } void _setReactions( diff --git a/lib/src/screens/exchange/exchange_template_page.dart b/lib/src/screens/exchange/exchange_template_page.dart index c68efc473..cd3923fb8 100644 --- a/lib/src/screens/exchange/exchange_template_page.dart +++ b/lib/src/screens/exchange/exchange_template_page.dart @@ -1,4 +1,5 @@ import 'dart:ui'; +import 'package:cake_wallet/exchange/exchange_provider.dart'; import 'package:cake_wallet/exchange/exchange_template.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; @@ -169,7 +170,9 @@ class ExchangeTemplatePage extends BasePage { exchangeViewModel.wallet.currency ? exchangeViewModel.wallet.address : exchangeViewModel.receiveAddress, - initialIsAmountEditable: false, + initialIsAmountEditable: + exchangeViewModel.provider is + XMRTOExchangeProvider ? true : false, initialIsAddressEditable: exchangeViewModel.isReceiveAddressEnabled, isAmountEstimated: true, @@ -202,7 +205,9 @@ class ExchangeTemplatePage extends BasePage { child: Observer(builder: (_) { final description = exchangeViewModel.provider is XMRTOExchangeProvider - ? S.of(context).amount_is_guaranteed + ? exchangeViewModel.isReceiveAmountEntered + ? S.of(context).amount_is_guaranteed + : S.of(context).amount_is_estimate : S.of(context).amount_is_estimate; return Center( child: Text( @@ -328,6 +333,12 @@ class ExchangeTemplatePage extends BasePage { receiveKey.currentState.isAddressEditable(isEditable: isEnabled); }); + reaction((_) => exchangeViewModel.provider, (ExchangeProvider provider) { + provider is XMRTOExchangeProvider + ? receiveKey.currentState.isAmountEditable(isEditable: true) + : receiveKey.currentState.isAmountEditable(isEditable: false); + }); + /*reaction((_) => exchangeViewModel.limitsState, (LimitsState state) { String min; String max; @@ -358,6 +369,7 @@ class ExchangeTemplatePage extends BasePage { if (depositAmountController.text != exchangeViewModel.depositAmount) { exchangeViewModel.changeDepositAmount( amount: depositAmountController.text); + exchangeViewModel.isReceiveAmountEntered = false; } }); @@ -368,6 +380,7 @@ class ExchangeTemplatePage extends BasePage { if (receiveAmountController.text != exchangeViewModel.receiveAmount) { exchangeViewModel.changeReceiveAmount( amount: receiveAmountController.text); + exchangeViewModel.isReceiveAmountEntered = true; } }); diff --git a/lib/view_model/exchange/exchange_view_model.dart b/lib/view_model/exchange/exchange_view_model.dart index b6efa310f..396bd3e05 100644 --- a/lib/view_model/exchange/exchange_view_model.dart +++ b/lib/view_model/exchange/exchange_view_model.dart @@ -93,6 +93,7 @@ abstract class ExchangeViewModelBase with Store { @observable bool isReceiveAddressEnabled; + @observable bool isReceiveAmountEntered; Limits limits; @@ -256,6 +257,7 @@ abstract class ExchangeViewModelBase with Store { @action void reset() { + isReceiveAmountEntered = false; depositAmount = ''; receiveAmount = ''; depositCurrency = CryptoCurrency.xmr;