Merge pull request #121 from cake-tech/CAKE-116-all-button-validation-bug

CAKE-116 | added AllAmountValidator class to the amount_validator.dar…
This commit is contained in:
M 2020-10-22 21:30:32 +03:00
commit 57eaeb547b
3 changed files with 17 additions and 4 deletions

View file

@ -23,3 +23,11 @@ class AmountValidator extends TextValidator {
}
}
}
class AllAmountValidator extends TextValidator {
AllAmountValidator() : super(
errorMessage: S.current.error_text_amount,
pattern: S.current.all,
minLength: 0,
maxLength: 0);
}

View file

@ -163,7 +163,7 @@ class SendPage extends BasePage {
.decorationColor),
validator: sendViewModel.addressValidator,
),
Padding(
Observer(builder: (_) => Padding(
padding: const EdgeInsets.only(top: 20),
child: BaseTextFormField(
focusNode: _cryptoAmountFocus,
@ -226,7 +226,9 @@ class SendPage extends BasePage {
fontWeight: FontWeight.w500,
fontSize: 14),
validator:
sendViewModel.amountValidator)),
sendViewModel.sendAll
? sendViewModel.allAmountValidator
: sendViewModel.amountValidator))),
Observer(
builder: (_) => Padding(
padding: EdgeInsets.only(top: 10),
@ -513,6 +515,7 @@ class SendPage extends BasePage {
final amount = _fiatAmountController.text;
if (amount != sendViewModel.fiatAmount) {
sendViewModel.sendAll = false;
sendViewModel.setFiatAmount(amount);
}
});

View file

@ -67,6 +67,8 @@ abstract class SendViewModelBase with Store {
Validator get amountValidator => AmountValidator(type: _wallet.type);
Validator get allAmountValidator => AllAmountValidator();
Validator get addressValidator => AddressValidator(type: _wallet.currency);
Validator get templateValidator => TemplateValidator();