From d756b367d3f703e909ca4e3f083fc7be009ccc14 Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Sat, 16 Dec 2023 03:20:56 +0200 Subject: [PATCH] Make the exchange receive field always editable and can be taken from QR or Address book (#1230) --- lib/src/screens/exchange/exchange_page.dart | 5 ----- lib/src/screens/exchange/exchange_template_page.dart | 7 ------- lib/src/screens/exchange/widgets/exchange_card.dart | 2 +- lib/view_model/exchange/exchange_view_model.dart | 8 -------- 4 files changed, 1 insertion(+), 21 deletions(-) diff --git a/lib/src/screens/exchange/exchange_page.dart b/lib/src/screens/exchange/exchange_page.dart index 1f441ea99f..b3fbd19a79 100644 --- a/lib/src/screens/exchange/exchange_page.dart +++ b/lib/src/screens/exchange/exchange_page.dart @@ -411,10 +411,6 @@ class ExchangePage extends BasePage { } }); - reaction((_) => exchangeViewModel.isReceiveAddressEnabled, (bool isEnabled) { - receiveKey.currentState!.isAddressEditable(isEditable: isEnabled); - }); - reaction((_) => exchangeViewModel.isReceiveAmountEditable, (bool isReceiveAmountEditable) { receiveKey.currentState!.isAmountEditable(isEditable: isReceiveAmountEditable); }); @@ -670,7 +666,6 @@ class ExchangePage extends BasePage { ? exchangeViewModel.wallet.walletAddresses.address : exchangeViewModel.receiveAddress, initialIsAmountEditable: exchangeViewModel.isReceiveAmountEditable, - initialIsAddressEditable: exchangeViewModel.isReceiveAddressEnabled, isAmountEstimated: true, isMoneroWallet: exchangeViewModel.isMoneroWallet, currencies: exchangeViewModel.receiveCurrencies, diff --git a/lib/src/screens/exchange/exchange_template_page.dart b/lib/src/screens/exchange/exchange_template_page.dart index 31f35661d4..3a7456dd8c 100644 --- a/lib/src/screens/exchange/exchange_template_page.dart +++ b/lib/src/screens/exchange/exchange_template_page.dart @@ -174,8 +174,6 @@ class ExchangeTemplatePage extends BasePage { ? exchangeViewModel.wallet.walletAddresses.address : exchangeViewModel.receiveAddress, initialIsAmountEditable: false, - initialIsAddressEditable: - exchangeViewModel.isReceiveAddressEnabled, isAmountEstimated: true, isMoneroWallet: exchangeViewModel.isMoneroWallet, currencies: exchangeViewModel.receiveCurrencies, @@ -328,11 +326,6 @@ class ExchangeTemplatePage extends BasePage { } }); - reaction((_) => exchangeViewModel.isReceiveAddressEnabled, - (bool isEnabled) { - receiveKey.currentState!.isAddressEditable(isEditable: isEnabled); - }); - reaction((_) => exchangeViewModel.provider, (ExchangeProvider? provider) { receiveKey.currentState!.isAmountEditable(isEditable: false); }); diff --git a/lib/src/screens/exchange/widgets/exchange_card.dart b/lib/src/screens/exchange/widgets/exchange_card.dart index b55e96e85b..706ace7ded 100644 --- a/lib/src/screens/exchange/widgets/exchange_card.dart +++ b/lib/src/screens/exchange/widgets/exchange_card.dart @@ -23,7 +23,6 @@ class ExchangeCard extends StatefulWidget { required this.initialAddress, required this.initialWalletName, required this.initialIsAmountEditable, - required this.initialIsAddressEditable, required this.isAmountEstimated, required this.currencies, required this.onCurrencySelected, @@ -31,6 +30,7 @@ class ExchangeCard extends StatefulWidget { this.currencyValueValidator, this.addressTextFieldValidator, this.title = '', + this.initialIsAddressEditable = true, this.hasRefundAddress = false, this.isMoneroWallet = false, this.currencyButtonColor = Colors.transparent, diff --git a/lib/view_model/exchange/exchange_view_model.dart b/lib/view_model/exchange/exchange_view_model.dart index fb70198853..afe6178039 100644 --- a/lib/view_model/exchange/exchange_view_model.dart +++ b/lib/view_model/exchange/exchange_view_model.dart @@ -66,7 +66,6 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with receiveAddress = '', depositAddress = '', isDepositAddressEnabled = false, - isReceiveAddressEnabled = false, isReceiveAmountEditable = false, _useTorOnly = false, receiveCurrencies = [], @@ -108,7 +107,6 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with bestRateSync = Timer.periodic(Duration(seconds: 10), (timer) => _calculateBestRate()); isDepositAddressEnabled = !(depositCurrency == wallet.currency); - isReceiveAddressEnabled = !(receiveCurrency == wallet.currency); depositAmount = ''; receiveAmount = ''; receiveAddress = ''; @@ -201,9 +199,6 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with @observable bool isDepositAddressEnabled; - @observable - bool isReceiveAddressEnabled; - @observable bool isReceiveAmountEntered; @@ -315,7 +310,6 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with isFixedRateMode = false; _onPairChange(); isDepositAddressEnabled = !(depositCurrency == wallet.currency); - isReceiveAddressEnabled = !(receiveCurrency == wallet.currency); } @action @@ -324,7 +318,6 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with isFixedRateMode = false; _onPairChange(); isDepositAddressEnabled = !(depositCurrency == wallet.currency); - isReceiveAddressEnabled = !(receiveCurrency == wallet.currency); } @action @@ -535,7 +528,6 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with depositAddress = depositCurrency == wallet.currency ? wallet.walletAddresses.address : ''; receiveAddress = receiveCurrency == wallet.currency ? wallet.walletAddresses.address : ''; isDepositAddressEnabled = !(depositCurrency == wallet.currency); - isReceiveAddressEnabled = !(receiveCurrency == wallet.currency); isFixedRateMode = false; _onPairChange(); }