CAKE-116 | added AllAmountValidator class to the amount_validator.dart; applied all amount validator to the send page; added fiat amount controller to the send page

This commit is contained in:
OleksandrSobol 2020-10-09 10:41:29 +03:00
parent a8695cc560
commit 0b6b711618
3 changed files with 80 additions and 58 deletions
lib

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

@ -161,7 +161,8 @@ class SendPage extends BasePage {
.decorationColor),
validator: sendViewModel.addressValidator,
),
Padding(
Observer(
builder: (_) => Padding(
padding: const EdgeInsets.only(top: 20),
child: BaseTextFormField(
focusNode: _cryptoAmountFocus,
@ -224,7 +225,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),
@ -507,6 +510,15 @@ class SendPage extends BasePage {
}
});
_fiatAmountController.addListener(() {
final amount = _fiatAmountController.text;
if (amount != sendViewModel.fiatAmount) {
sendViewModel.sendAll = false;
sendViewModel.setFiatAmount(amount);
}
});
reaction((_) => sendViewModel.sendAll, (bool all) {
if (all) {
_cryptoAmountController.text = S.current.all;

View file

@ -64,6 +64,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();