mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-01 12:04:21 +01:00
CAKE-185 | added validation of amount for xmr.to provider in the exchange_page.dart; added isValidAmount() to exchange_view_model.dart
This commit is contained in:
@@ -411,7 +411,18 @@ class ExchangePage extends BasePage {
|
|||||||
buttonAction: () => Navigator.of(context).pop());
|
buttonAction: () => Navigator.of(context).pop());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
exchangeViewModel.createTrade();
|
exchangeViewModel.isValidAmount()
|
||||||
|
? exchangeViewModel.createTrade()
|
||||||
|
: showPopUp<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertWithOneAction(
|
||||||
|
alertTitle: 'XMR.TO error',
|
||||||
|
alertContent: 'Invalid amount. Maximum limit 8 digits after the decimal point ',
|
||||||
|
buttonText: S.of(context).ok,
|
||||||
|
buttonAction: () =>
|
||||||
|
Navigator.of(context).pop());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -306,6 +306,27 @@ abstract class ExchangeViewModelBase with Store {
|
|||||||
void removeTemplate({ExchangeTemplate template}) =>
|
void removeTemplate({ExchangeTemplate template}) =>
|
||||||
_exchangeTemplateStore.remove(template: template);
|
_exchangeTemplateStore.remove(template: template);
|
||||||
|
|
||||||
|
bool isValidAmount() {
|
||||||
|
bool isValid = true;
|
||||||
|
|
||||||
|
if (provider is XMRTOExchangeProvider) {
|
||||||
|
final amount = isReceiveAmountEntered
|
||||||
|
? receiveAmount
|
||||||
|
: depositAmount;
|
||||||
|
|
||||||
|
final amountParts = amount.replaceAll(',', '.')
|
||||||
|
.split('.');
|
||||||
|
|
||||||
|
final numberOfFractionDigits =
|
||||||
|
amountParts.length > 1
|
||||||
|
? amountParts[1].length : 0;
|
||||||
|
|
||||||
|
isValid = !(numberOfFractionDigits > 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
|
|
||||||
List<ExchangeProvider> providersForCurrentPair() {
|
List<ExchangeProvider> providersForCurrentPair() {
|
||||||
return _providersForPair(from: depositCurrency, to: receiveCurrency);
|
return _providersForPair(from: depositCurrency, to: receiveCurrency);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user