disable swap until synced for btc/ltc/xmr

This commit is contained in:
OmarHatem 2025-05-20 03:10:49 +03:00
parent 1e5568fc1b
commit dcaeac9b85

View file

@ -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 @override
Widget middle(BuildContext context) => Row( Widget middle(BuildContext context) => Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@ -252,20 +257,21 @@ class ExchangePage extends BasePage {
onPressed: exchangeViewModel.isAvailableInSelected ? () { onPressed: exchangeViewModel.isAvailableInSelected ? () {
FocusScope.of(context).unfocus(); FocusScope.of(context).unfocus();
if (_formKey.currentState != null && if (_formKey.currentState != null &&
_formKey.currentState!.validate()) { _formKey.currentState!.validate()) {
if ((exchangeViewModel.depositCurrency == CryptoCurrency.xmr) && if (_shouldWaitTillSynced) {
(!(exchangeViewModel.status is SyncedSyncStatus))) { showPopUp<void>(
showPopUp<void>( context: context,
context: context, builder: (BuildContext context) {
builder: (BuildContext context) { return AlertWithOneAction(
return AlertWithOneAction( alertTitle: S.of(context).exchange,
alertTitle: S.of(context).exchange, alertContent:
alertContent: S.of(context).exchange_sync_alert_content, S.of(context).exchange_sync_alert_content,
buttonText: S.of(context).ok, buttonText: S.of(context).ok,
buttonAction: () => Navigator.of(context).pop()); buttonAction: () => Navigator.of(context).pop(),
}); );
} else { });
} else {
final check = exchangeViewModel.shouldDisplayTOTP(); final check = exchangeViewModel.shouldDisplayTOTP();
authService.authenticateAction( authService.authenticateAction(
context, context,