From c57b8beb270629e9cfe85e16ad61261691e693da Mon Sep 17 00:00:00 2001 From: Hanh Date: Sat, 30 Oct 2021 08:48:33 +0800 Subject: [PATCH] Fix multisend amount bug --- lib/multisend.dart | 23 +++++------------------ pubspec.yaml | 2 +- pubspec.yaml.tpl | 2 +- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/lib/multisend.dart b/lib/multisend.dart index 70dda0b..61c5847 100644 --- a/lib/multisend.dart +++ b/lib/multisend.dart @@ -10,6 +10,7 @@ import 'package:material_design_icons_flutter/material_design_icons_flutter.dart import 'package:warp/store.dart'; import 'package:warp_api/warp_api.dart'; +import 'dualmoneyinput.dart'; import 'main.dart'; import 'generated/l10n.dart'; @@ -114,10 +115,9 @@ class PayRecipient extends StatefulWidget { class PayRecipientState extends State { final _formKey = GlobalKey(); - var _amount = Decimal.zero; final _addressController = TextEditingController(); - var _currencyController = TextEditingController(); final _memoController = TextEditingController(); + final amountKey = GlobalKey(); @override Widget build(BuildContext context) { @@ -155,12 +155,7 @@ class PayRecipientState extends State { IconButton( icon: new Icon(MdiIcons.qrcodeScan), onPressed: _onScan) ]), - TextFormField( - decoration: InputDecoration(labelText: S.of(context).amount), - keyboardType: TextInputType.number, - controller: _currencyController, - inputFormatters: [makeInputFormatter(true)], - validator: _checkAmount), + DualMoneyInputWidget(key: amountKey), TextFormField( decoration: InputDecoration(labelText: S.of(context).memo), minLines: 4, @@ -188,13 +183,13 @@ class PayRecipientState extends State { if (form.validate()) { form.save(); - _amount = Decimal.parse(parseNumber(_currencyController.text).toString()); + final amount = amountKey.currentState!.amount; final c = contacts.contacts.where((c) => c.name == _addressController.text); final address = c.isEmpty ? unwrapUA(_addressController.text) : c.first.address; final r = Recipient( - address, (_amount * ZECUNIT_DECIMAL).toInt(), _memoController.text); + address, amount, _memoController.text); Navigator.of(context).pop(r); } } @@ -208,14 +203,6 @@ class PayRecipientState extends State { if (!WarpApi.validAddress(v)) return S.of(context).invalidAddress; return null; } - - String? _checkAmount(String? vs) { - if (vs == null) return S.of(context).amountMustBeANumber; - if (checkNumber(vs)) return S.of(context).amountMustBeANumber; - final v = parseNumber(vs); - if (v <= 0.0) return S.of(context).amountMustBePositive; - return null; - } } class NoRecipient extends StatelessWidget { diff --git a/pubspec.yaml b/pubspec.yaml index 70254bb..1e5f365 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.12+178 +version: 1.0.12+179 environment: sdk: ">=2.12.0 <3.0.0" diff --git a/pubspec.yaml.tpl b/pubspec.yaml.tpl index 24ac41f..c6e7b84 100644 --- a/pubspec.yaml.tpl +++ b/pubspec.yaml.tpl @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.12+178 +version: 1.0.12+179 environment: sdk: ">=2.12.0 <3.0.0"