mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 01:37:40 +00: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:
parent
dd71edd8c8
commit
4cb4ede2d3
2 changed files with 33 additions and 1 deletions
|
@ -411,7 +411,18 @@ class ExchangePage extends BasePage {
|
|||
buttonAction: () => Navigator.of(context).pop());
|
||||
});
|
||||
} 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}) =>
|
||||
_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() {
|
||||
return _providersForPair(from: depositCurrency, to: receiveCurrency);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue