mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-12 09:32:33 +00:00
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:
parent
a8695cc560
commit
0b6b711618
3 changed files with 80 additions and 58 deletions
lib
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue