From dcaeac9b85ffb9a5c8f39378f120ba24dc212dbc Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Tue, 20 May 2025 03:10:49 +0300 Subject: [PATCH] disable swap until synced for btc/ltc/xmr --- lib/src/screens/exchange/exchange_page.dart | 34 ++++++++++++--------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/src/screens/exchange/exchange_page.dart b/lib/src/screens/exchange/exchange_page.dart index e5027198b..b7b377fe1 100644 --- a/lib/src/screens/exchange/exchange_page.dart +++ b/lib/src/screens/exchange/exchange_page.dart @@ -97,6 +97,11 @@ class ExchangePage extends BasePage { } }; + bool get _shouldWaitTillSynced => + [CryptoCurrency.xmr, CryptoCurrency.btc, CryptoCurrency.ltc] + .contains(exchangeViewModel.depositCurrency) && + !(exchangeViewModel.status is SyncedSyncStatus); + @override Widget middle(BuildContext context) => Row( mainAxisAlignment: MainAxisAlignment.center, @@ -252,20 +257,21 @@ class ExchangePage extends BasePage { onPressed: exchangeViewModel.isAvailableInSelected ? () { FocusScope.of(context).unfocus(); - if (_formKey.currentState != null && - _formKey.currentState!.validate()) { - if ((exchangeViewModel.depositCurrency == CryptoCurrency.xmr) && - (!(exchangeViewModel.status is SyncedSyncStatus))) { - showPopUp( - context: context, - builder: (BuildContext context) { - return AlertWithOneAction( - alertTitle: S.of(context).exchange, - alertContent: S.of(context).exchange_sync_alert_content, - buttonText: S.of(context).ok, - buttonAction: () => Navigator.of(context).pop()); - }); - } else { + if (_formKey.currentState != null && + _formKey.currentState!.validate()) { + if (_shouldWaitTillSynced) { + showPopUp( + context: context, + builder: (BuildContext context) { + return AlertWithOneAction( + alertTitle: S.of(context).exchange, + alertContent: + S.of(context).exchange_sync_alert_content, + buttonText: S.of(context).ok, + buttonAction: () => Navigator.of(context).pop(), + ); + }); + } else { final check = exchangeViewModel.shouldDisplayTOTP(); authService.authenticateAction( context,