disable swap until synced for btc/ltc/xmr

OmarHatem committed May 20, 2025 at 03:10 UTC dcaeac9b85ffb9a5c8f39378f120ba24dc212dbc
1 file changed +20 -14
lib/src/screens/exchange/exchange_page.dart
+20 -14
@@ -97,6 +97,11 @@ class ExchangePage extends BasePage {
97 }
98 };
99
100 + bool get _shouldWaitTillSynced =>
101 + [CryptoCurrency.xmr, CryptoCurrency.btc, CryptoCurrency.ltc]
102 + .contains(exchangeViewModel.depositCurrency) &&
103 + !(exchangeViewModel.status is SyncedSyncStatus);
104 +
105 @override
106 Widget middle(BuildContext context) => Row(
107 mainAxisAlignment: MainAxisAlignment.center,
@@ -252,20 +257,21 @@ class ExchangePage extends BasePage {
257 onPressed: exchangeViewModel.isAvailableInSelected ? () {
258 FocusScope.of(context).unfocus();
259
255 - if (_formKey.currentState != null &&
256 - _formKey.currentState!.validate()) {
257 - if ((exchangeViewModel.depositCurrency == CryptoCurrency.xmr) &&
258 - (!(exchangeViewModel.status is SyncedSyncStatus))) {
259 - showPopUp<void>(
260 - context: context,
261 - builder: (BuildContext context) {
262 - return AlertWithOneAction(
263 - alertTitle: S.of(context).exchange,
264 - alertContent: S.of(context).exchange_sync_alert_content,
265 - buttonText: S.of(context).ok,
266 - buttonAction: () => Navigator.of(context).pop());
267 - });
268 - } else {
260 + if (_formKey.currentState != null &&
261 + _formKey.currentState!.validate()) {
262 + if (_shouldWaitTillSynced) {
263 + showPopUp<void>(
264 + context: context,
265 + builder: (BuildContext context) {
266 + return AlertWithOneAction(
267 + alertTitle: S.of(context).exchange,
268 + alertContent:
269 + S.of(context).exchange_sync_alert_content,
270 + buttonText: S.of(context).ok,
271 + buttonAction: () => Navigator.of(context).pop(),
272 + );
273 + });
274 + } else {
275 final check = exchangeViewModel.shouldDisplayTOTP();
276 authService.authenticateAction(
277 context,