diff --git a/lib/core/amount_validator.dart b/lib/core/amount_validator.dart index abf55b6b7..369bde709 100644 --- a/lib/core/amount_validator.dart +++ b/lib/core/amount_validator.dart @@ -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); +} diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 811d940dd..459e435d5 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -163,14 +163,14 @@ class SendPage extends BasePage { .decorationColor), validator: sendViewModel.addressValidator, ), - Padding( + Observer(builder: (_) => Padding( padding: const EdgeInsets.only(top: 20), child: BaseTextFormField( focusNode: _cryptoAmountFocus, controller: _cryptoAmountController, keyboardType: - TextInputType.numberWithOptions( - signed: false, decimal: true), + TextInputType.numberWithOptions( + signed: false, decimal: true), prefixIcon: Padding( padding: EdgeInsets.only(top: 9), child: Text( @@ -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); } }); diff --git a/lib/view_model/send/send_view_model.dart b/lib/view_model/send/send_view_model.dart index 3cdcc7bb2..d49be63f7 100644 --- a/lib/view_model/send/send_view_model.dart +++ b/lib/view_model/send/send_view_model.dart @@ -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();