mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-04 12:34:14 +01:00
Cw 262 better handle user exchange amount below minimum or maximum trade size (#868)
* CW-262-Better-handle-user-exchange-amount-below-minimum-or-maximum-trade-size * fix: App should compute conversion even if it's not within the limits
This commit is contained in:
@@ -198,6 +198,9 @@ abstract class ExchangeViewModelBase with Store {
|
||||
@observable
|
||||
bool isFixedRateMode;
|
||||
|
||||
@observable
|
||||
Limits limits;
|
||||
|
||||
@computed
|
||||
SyncStatus get status => wallet.syncStatus;
|
||||
|
||||
@@ -241,8 +244,6 @@ abstract class ExchangeViewModelBase with Store {
|
||||
|
||||
List<CryptoCurrency> depositCurrencies;
|
||||
|
||||
Limits limits;
|
||||
|
||||
NumberFormat _cryptoNumberFormat;
|
||||
|
||||
final SettingsStore _settingsStore;
|
||||
@@ -320,6 +321,22 @@ abstract class ExchangeViewModelBase with Store {
|
||||
.replaceAll(RegExp('\\,'), '');
|
||||
}
|
||||
|
||||
bool checkIfInputMeetsMinOrMaxCondition(String input) {
|
||||
final _enteredAmount = double.tryParse(input.replaceAll(',', '.')) ?? 0;
|
||||
double minLimit = limits.min ?? 0;
|
||||
double? maxLimit = limits.max;
|
||||
|
||||
if (_enteredAmount < minLimit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (maxLimit != null && _enteredAmount > maxLimit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void> _calculateBestRate() async {
|
||||
final amount = double.tryParse(isFixedRateMode ? receiveAmount : depositAmount) ?? 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user