From 06651d34f6bb3cac0d1674d2e277fca65acf432a Mon Sep 17 00:00:00 2001 From: Aleksander Rem Date: Tue, 19 Jan 2021 03:00:03 +0100 Subject: [PATCH 1/5] Working QR amount input --- lib/ui/home_page.dart | 4 +- lib/ui/receive/receive_sheet.dart | 270 +++++++++++++++++++++++++++++- 2 files changed, 271 insertions(+), 3 deletions(-) diff --git a/lib/ui/home_page.dart b/lib/ui/home_page.dart index 7bd6c4d0..b05ef24c 100755 --- a/lib/ui/home_page.dart +++ b/lib/ui/home_page.dart @@ -676,6 +676,8 @@ class _AppHomePageState extends State painter.toImageData(MediaQuery.of(context).size.width).then((byteData) { setState(() { receive = ReceiveSheet( + localCurrency: StateContainer.of(context).curCurrency, + address: StateContainer.of(context).wallet.address, qrWidget: Container( width: MediaQuery.of(context).size.width / 2.675, child: Image.memory(byteData.buffer.asUint8List())), @@ -833,7 +835,7 @@ class _AppHomePageState extends State if (receive == null) { return; } - Sheets.showAppHeightEightSheet( + Sheets.showAppHeightNineSheet( context: context, widget: receive); }, highlightColor: receive != null diff --git a/lib/ui/receive/receive_sheet.dart b/lib/ui/receive/receive_sheet.dart index e86577fc..127488bc 100755 --- a/lib/ui/receive/receive_sheet.dart +++ b/lib/ui/receive/receive_sheet.dart @@ -6,22 +6,36 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:natrium_wallet_flutter/themes.dart'; import 'package:path_provider/path_provider.dart'; import 'package:share/share.dart'; +import 'package:intl/intl.dart'; +import 'package:decimal/decimal.dart'; import 'package:natrium_wallet_flutter/localization.dart'; +import 'package:natrium_wallet_flutter/model/available_currency.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter/rendering.dart'; +import 'package:natrium_wallet_flutter/app_icons.dart'; import 'package:natrium_wallet_flutter/dimens.dart'; +import 'package:natrium_wallet_flutter/ui/widgets/app_text_field.dart'; import 'package:natrium_wallet_flutter/ui/widgets/buttons.dart'; import 'package:natrium_wallet_flutter/ui/util/ui_util.dart'; +import 'package:natrium_wallet_flutter/ui/util/formatters.dart'; import 'package:natrium_wallet_flutter/ui/receive/share_card.dart'; import 'package:natrium_wallet_flutter/appstate_container.dart'; +import 'package:natrium_wallet_flutter/util/numberutil.dart'; +import 'package:qr_flutter/qr_flutter.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:flare_flutter/flare_actor.dart'; class ReceiveSheet extends StatefulWidget { + final AvailableCurrency localCurrency; final Widget qrWidget; + final String address; - ReceiveSheet({this.qrWidget}) : super(); + ReceiveSheet({ + @required this.localCurrency, + this.address, + this.qrWidget} + ) : super(); _ReceiveSheetStateState createState() => _ReceiveSheetStateState(); } @@ -37,6 +51,18 @@ class _ReceiveSheetStateState extends State { // Timer reference so we can cancel repeated events Timer _addressCopiedTimer; + FocusNode _sendAmountFocusNode; + String _rawAmount; + TextEditingController _sendAmountController; + NumberFormat _localCurrencyFormat; + bool _localCurrencyMode = false; + String _amountValidationText = ""; + String _amountHint = ""; + String _lastLocalCurrencyAmount = ""; + String _lastCryptoAmount = ""; + + Widget qrWidget; + Future _capturePng() async { if (shareCardKey != null && shareCardKey.currentContext != null) { RenderRepaintBoundary boundary = @@ -59,6 +85,52 @@ class _ReceiveSheetStateState extends State { // Share card initialization shareCardKey = GlobalKey(); _showShareCard = false; + + _sendAmountFocusNode = FocusNode(); + _sendAmountController = TextEditingController(); + + // On amount focus change + _sendAmountFocusNode.addListener(() { + if (_sendAmountFocusNode.hasFocus) { + if (_rawAmount != null) { + setState(() { + _sendAmountController.text = + NumberUtil.getRawAsUsableString(_rawAmount).replaceAll(",", ""); + _rawAmount = null; + }); + } + // if (quickSendAmount != null) { + // _sendAmountController.text = ""; + // setState(() { + // quickSendAmount = null; + // }); + // } + setState(() { + _amountHint = null; + }); + } else { + setState(() { + _amountHint = ""; + }); + + // // Redraw QR? + // String raw; + // if (_localCurrencyMode) { + // _lastLocalCurrencyAmount = _sendAmountController.text; + // _lastCryptoAmount = _convertLocalCurrencyToCrypto(); + // raw = NumberUtil.getAmountAsRaw(_lastCryptoAmount); + // } else { + // raw = _sendAmountController.text.length > 0 ? NumberUtil.getAmountAsRaw(_sendAmountController.text) : ''; + // } + // this.paintQrCode(address: widget.address, amount: raw); + } + }); + // Set initial currency format + _localCurrencyFormat = NumberFormat.currency( + locale: widget.localCurrency.getLocale().toString(), + symbol: widget.localCurrency.getCurrencySymbol()); + + qrWidget = widget.qrWidget; } @override @@ -107,6 +179,31 @@ class _ReceiveSheetStateState extends State { ], ), + // Column for Balance Text, Enter Amount container + Enter Amount Error container WIP + Column( + children: [ + // ******* Enter Amount Container ******* // + getEnterAmountContainer(), + // ******* Enter Amount Container End ******* // + + // ******* Enter Amount Error Container ******* // + Container( + alignment: AlignmentDirectional(0, 0), + margin: EdgeInsets.only(top: 3), + child: Text(_amountValidationText, + style: TextStyle( + fontSize: 14.0, + color: StateContainer.of(context) + .curTheme + .primary, + fontFamily: 'NunitoSans', + fontWeight: FontWeight.w600, + )), + ), + // ******* Enter Amount Error Container End ******* // + ], + ), + // QR which takes all the available space left from the buttons & address text Expanded( child: Center( @@ -142,7 +239,7 @@ class _ReceiveSheetStateState extends State { child: Container( height: MediaQuery.of(context).size.width / 2.65, width: MediaQuery.of(context).size.width / 2.65, - child: widget.qrWidget, + child: this.qrWidget, ), ), // Outer ring @@ -359,4 +456,173 @@ class _ReceiveSheetStateState extends State { ], )); } + + String _convertLocalCurrencyToCrypto() { + String convertedAmt = _sendAmountController.text.replaceAll(",", "."); + convertedAmt = NumberUtil.sanitizeNumber(convertedAmt); + if (convertedAmt.isEmpty) { + return ""; + } + Decimal valueLocal = Decimal.parse(convertedAmt); + Decimal conversion = Decimal.parse( + StateContainer.of(context).wallet.localCurrencyConversion); + return NumberUtil.truncateDecimal(valueLocal / conversion).toString(); + } + + String _convertCryptoToLocalCurrency() { + String convertedAmt = NumberUtil.sanitizeNumber(_sendAmountController.text, + maxDecimalDigits: 2); + if (convertedAmt.isEmpty) { + return ""; + } + Decimal valueCrypto = Decimal.parse(convertedAmt); + Decimal conversion = Decimal.parse( + StateContainer.of(context).wallet.localCurrencyConversion); + convertedAmt = + NumberUtil.truncateDecimal(valueCrypto * conversion, digits: 2) + .toString(); + convertedAmt = + convertedAmt.replaceAll(".", _localCurrencyFormat.symbols.DECIMAL_SEP); + convertedAmt = _localCurrencyFormat.currencySymbol + convertedAmt; + return convertedAmt; + } + + void toggleLocalCurrency() { + // Keep a cache of previous amounts because, it's kinda nice to see approx what nano is worth + // this way you can tap button and tap back and not end up with X.9993451 NANO + if (_localCurrencyMode) { + // Switching to crypto-mode + String cryptoAmountStr; + // Check out previous state + if (_sendAmountController.text == _lastLocalCurrencyAmount) { + cryptoAmountStr = _lastCryptoAmount; + } else { + _lastLocalCurrencyAmount = _sendAmountController.text; + _lastCryptoAmount = _convertLocalCurrencyToCrypto(); + cryptoAmountStr = _lastCryptoAmount; + } + setState(() { + _localCurrencyMode = false; + }); + Future.delayed(Duration(milliseconds: 50), () { + _sendAmountController.text = cryptoAmountStr; + _sendAmountController.selection = TextSelection.fromPosition( + TextPosition(offset: cryptoAmountStr.length)); + }); + } else { + // Switching to local-currency mode + String localAmountStr; + // Check our previous state + if (_sendAmountController.text == _lastCryptoAmount) { + localAmountStr = _lastLocalCurrencyAmount; + } else { + _lastCryptoAmount = _sendAmountController.text; + _lastLocalCurrencyAmount = _convertCryptoToLocalCurrency(); + localAmountStr = _lastLocalCurrencyAmount; + } + setState(() { + _localCurrencyMode = true; + }); + Future.delayed(Duration(milliseconds: 50), () { + _sendAmountController.text = localAmountStr; + _sendAmountController.selection = TextSelection.fromPosition( + TextPosition(offset: localAmountStr.length)); + }); + } + } + + void redrawQrCode() { + String raw; + if (_localCurrencyMode) { + _lastLocalCurrencyAmount = _sendAmountController.text; + _lastCryptoAmount = _convertLocalCurrencyToCrypto(); + raw = NumberUtil.getAmountAsRaw(_lastCryptoAmount); + } else { + raw = _sendAmountController.text.length > 0 ? NumberUtil.getAmountAsRaw(_sendAmountController.text) : ''; + } + this.paintQrCode(address: widget.address, amount: raw); + } + + void paintQrCode({String address, String amount}) { + QrPainter painter = QrPainter( + data: amount != '' ? 'nano:' + address + '?amount=' + amount : address, + version: amount != '' ? 9 : 6, + gapless: false, + errorCorrectionLevel: QrErrorCorrectLevel.Q, + ); + painter.toImageData(MediaQuery.of(context).size.width).then((byteData) { + setState(() { + this.qrWidget = Container( + width: MediaQuery.of(context).size.width / 2.675, + child: Image.memory(byteData.buffer.asUint8List()) + ); + }); + }); + } + + //************ Enter Amount Container Method ************// + //*******************************************************// + getEnterAmountContainer() { + return AppTextField( + focusNode: _sendAmountFocusNode, + controller: _sendAmountController, + topMargin: 30, + cursorColor: StateContainer.of(context).curTheme.primary, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 16.0, + color: StateContainer.of(context).curTheme.primary, + fontFamily: 'NunitoSans', + ), + inputFormatters: _rawAmount == null + ? [ + LengthLimitingTextInputFormatter(13), + _localCurrencyMode + ? CurrencyFormatter( + decimalSeparator: + _localCurrencyFormat.symbols.DECIMAL_SEP, + commaSeparator: _localCurrencyFormat.symbols.GROUP_SEP, + maxDecimalDigits: 2) + : CurrencyFormatter( + maxDecimalDigits: NumberUtil.maxDecimalDigits), + LocalCurrencyFormatter( + active: _localCurrencyMode, + currencyFormat: _localCurrencyFormat) + ] + : [LengthLimitingTextInputFormatter(13)], + onChanged: (text) { + // Always reset the error message to be less annoying + setState(() { + _amountValidationText = ""; + // Reset the raw amount + _rawAmount = null; + }); + + this.redrawQrCode(); + }, + textInputAction: TextInputAction.next, + maxLines: null, + autocorrect: false, + hintText: + _amountHint == null ? "" : AppLocalization.of(context).enterAmount, + prefixButton: _rawAmount == null + ? TextFieldButton( + icon: AppIcons.swapcurrency, + onPressed: () { + toggleLocalCurrency(); + }, + ) + : null, + fadeSuffixOnCondition: true, + keyboardType: TextInputType.numberWithOptions(decimal: true), + textAlign: TextAlign.center, + onSubmitted: (text) { + FocusScope.of(context).unfocus(); + // if (!Address(_sendAddressController.text).isValid()) { + // FocusScope.of(context).requestFocus(_sendAddressFocusNode); + // } + }, + ); + } //************ Enter Address Container Method End ************// + //*************************************************************// } From a9e3f05949a3e9f73bff5d70f37660dad89be10b Mon Sep 17 00:00:00 2001 From: Aleksander Rem Date: Tue, 19 Jan 2021 17:22:50 +0100 Subject: [PATCH 2/5] Renamed variables and removed unnecessary code --- lib/ui/receive/receive_sheet.dart | 129 +++++++++--------------------- 1 file changed, 39 insertions(+), 90 deletions(-) diff --git a/lib/ui/receive/receive_sheet.dart b/lib/ui/receive/receive_sheet.dart index 127488bc..f1b76e87 100755 --- a/lib/ui/receive/receive_sheet.dart +++ b/lib/ui/receive/receive_sheet.dart @@ -51,12 +51,11 @@ class _ReceiveSheetStateState extends State { // Timer reference so we can cancel repeated events Timer _addressCopiedTimer; - FocusNode _sendAmountFocusNode; - String _rawAmount; - TextEditingController _sendAmountController; + // New vars + FocusNode _receiveAmountFocusNode; + TextEditingController _receiveAmountController; NumberFormat _localCurrencyFormat; bool _localCurrencyMode = false; - String _amountValidationText = ""; String _amountHint = ""; String _lastLocalCurrencyAmount = ""; String _lastCryptoAmount = ""; @@ -86,25 +85,16 @@ class _ReceiveSheetStateState extends State { shareCardKey = GlobalKey(); _showShareCard = false; - _sendAmountFocusNode = FocusNode(); - _sendAmountController = TextEditingController(); + // Set initial state of QR widget + qrWidget = widget.qrWidget; + + // Set up amount input + _receiveAmountFocusNode = FocusNode(); + _receiveAmountController = TextEditingController(); // On amount focus change - _sendAmountFocusNode.addListener(() { - if (_sendAmountFocusNode.hasFocus) { - if (_rawAmount != null) { - setState(() { - _sendAmountController.text = - NumberUtil.getRawAsUsableString(_rawAmount).replaceAll(",", ""); - _rawAmount = null; - }); - } - // if (quickSendAmount != null) { - // _sendAmountController.text = ""; - // setState(() { - // quickSendAmount = null; - // }); - // } + _receiveAmountFocusNode.addListener(() { + if (_receiveAmountFocusNode.hasFocus) { setState(() { _amountHint = null; }); @@ -112,25 +102,13 @@ class _ReceiveSheetStateState extends State { setState(() { _amountHint = ""; }); - - // // Redraw QR? - // String raw; - // if (_localCurrencyMode) { - // _lastLocalCurrencyAmount = _sendAmountController.text; - // _lastCryptoAmount = _convertLocalCurrencyToCrypto(); - // raw = NumberUtil.getAmountAsRaw(_lastCryptoAmount); - // } else { - // raw = _sendAmountController.text.length > 0 ? NumberUtil.getAmountAsRaw(_sendAmountController.text) : ''; - // } - // this.paintQrCode(address: widget.address, amount: raw); } }); + // Set initial currency format _localCurrencyFormat = NumberFormat.currency( locale: widget.localCurrency.getLocale().toString(), symbol: widget.localCurrency.getCurrencySymbol()); - - qrWidget = widget.qrWidget; } @override @@ -179,28 +157,10 @@ class _ReceiveSheetStateState extends State { ], ), - // Column for Balance Text, Enter Amount container + Enter Amount Error container WIP + // Column for Enter Amount container Column( children: [ - // ******* Enter Amount Container ******* // getEnterAmountContainer(), - // ******* Enter Amount Container End ******* // - - // ******* Enter Amount Error Container ******* // - Container( - alignment: AlignmentDirectional(0, 0), - margin: EdgeInsets.only(top: 3), - child: Text(_amountValidationText, - style: TextStyle( - fontSize: 14.0, - color: StateContainer.of(context) - .curTheme - .primary, - fontFamily: 'NunitoSans', - fontWeight: FontWeight.w600, - )), - ), - // ******* Enter Amount Error Container End ******* // ], ), @@ -458,7 +418,7 @@ class _ReceiveSheetStateState extends State { } String _convertLocalCurrencyToCrypto() { - String convertedAmt = _sendAmountController.text.replaceAll(",", "."); + String convertedAmt = _receiveAmountController.text.replaceAll(",", "."); convertedAmt = NumberUtil.sanitizeNumber(convertedAmt); if (convertedAmt.isEmpty) { return ""; @@ -470,7 +430,7 @@ class _ReceiveSheetStateState extends State { } String _convertCryptoToLocalCurrency() { - String convertedAmt = NumberUtil.sanitizeNumber(_sendAmountController.text, + String convertedAmt = NumberUtil.sanitizeNumber(_receiveAmountController.text, maxDecimalDigits: 2); if (convertedAmt.isEmpty) { return ""; @@ -494,10 +454,10 @@ class _ReceiveSheetStateState extends State { // Switching to crypto-mode String cryptoAmountStr; // Check out previous state - if (_sendAmountController.text == _lastLocalCurrencyAmount) { + if (_receiveAmountController.text == _lastLocalCurrencyAmount) { cryptoAmountStr = _lastCryptoAmount; } else { - _lastLocalCurrencyAmount = _sendAmountController.text; + _lastLocalCurrencyAmount = _receiveAmountController.text; _lastCryptoAmount = _convertLocalCurrencyToCrypto(); cryptoAmountStr = _lastCryptoAmount; } @@ -505,18 +465,18 @@ class _ReceiveSheetStateState extends State { _localCurrencyMode = false; }); Future.delayed(Duration(milliseconds: 50), () { - _sendAmountController.text = cryptoAmountStr; - _sendAmountController.selection = TextSelection.fromPosition( + _receiveAmountController.text = cryptoAmountStr; + _receiveAmountController.selection = TextSelection.fromPosition( TextPosition(offset: cryptoAmountStr.length)); }); } else { // Switching to local-currency mode String localAmountStr; // Check our previous state - if (_sendAmountController.text == _lastCryptoAmount) { + if (_receiveAmountController.text == _lastCryptoAmount) { localAmountStr = _lastLocalCurrencyAmount; } else { - _lastCryptoAmount = _sendAmountController.text; + _lastCryptoAmount = _receiveAmountController.text; _lastLocalCurrencyAmount = _convertCryptoToLocalCurrency(); localAmountStr = _lastLocalCurrencyAmount; } @@ -524,21 +484,21 @@ class _ReceiveSheetStateState extends State { _localCurrencyMode = true; }); Future.delayed(Duration(milliseconds: 50), () { - _sendAmountController.text = localAmountStr; - _sendAmountController.selection = TextSelection.fromPosition( + _receiveAmountController.text = localAmountStr; + _receiveAmountController.selection = TextSelection.fromPosition( TextPosition(offset: localAmountStr.length)); }); } } - void redrawQrCode() { + void redrawQr() { String raw; if (_localCurrencyMode) { - _lastLocalCurrencyAmount = _sendAmountController.text; + _lastLocalCurrencyAmount = _receiveAmountController.text; _lastCryptoAmount = _convertLocalCurrencyToCrypto(); raw = NumberUtil.getAmountAsRaw(_lastCryptoAmount); } else { - raw = _sendAmountController.text.length > 0 ? NumberUtil.getAmountAsRaw(_sendAmountController.text) : ''; + raw = _receiveAmountController.text.length > 0 ? NumberUtil.getAmountAsRaw(_receiveAmountController.text) : ''; } this.paintQrCode(address: widget.address, amount: raw); } @@ -564,8 +524,8 @@ class _ReceiveSheetStateState extends State { //*******************************************************// getEnterAmountContainer() { return AppTextField( - focusNode: _sendAmountFocusNode, - controller: _sendAmountController, + focusNode: _receiveAmountFocusNode, + controller: _receiveAmountController, topMargin: 30, cursorColor: StateContainer.of(context).curTheme.primary, style: TextStyle( @@ -574,8 +534,7 @@ class _ReceiveSheetStateState extends State { color: StateContainer.of(context).curTheme.primary, fontFamily: 'NunitoSans', ), - inputFormatters: _rawAmount == null - ? [ + inputFormatters: [ LengthLimitingTextInputFormatter(13), _localCurrencyMode ? CurrencyFormatter( @@ -588,40 +547,30 @@ class _ReceiveSheetStateState extends State { LocalCurrencyFormatter( active: _localCurrencyMode, currencyFormat: _localCurrencyFormat) - ] - : [LengthLimitingTextInputFormatter(13)], + ], onChanged: (text) { - // Always reset the error message to be less annoying - setState(() { - _amountValidationText = ""; - // Reset the raw amount - _rawAmount = null; - }); - - this.redrawQrCode(); + this.redrawQr(); }, textInputAction: TextInputAction.next, maxLines: null, autocorrect: false, hintText: _amountHint == null ? "" : AppLocalization.of(context).enterAmount, - prefixButton: _rawAmount == null - ? TextFieldButton( + prefixButton: TextFieldButton( icon: AppIcons.swapcurrency, onPressed: () { toggleLocalCurrency(); }, - ) - : null, + ), fadeSuffixOnCondition: true, keyboardType: TextInputType.numberWithOptions(decimal: true), textAlign: TextAlign.center, - onSubmitted: (text) { - FocusScope.of(context).unfocus(); - // if (!Address(_sendAddressController.text).isValid()) { - // FocusScope.of(context).requestFocus(_sendAddressFocusNode); - // } - }, + // onSubmitted: (text) { + // // FocusScope.of(context).unfocus(); + // // if (!Address(_sendAddressController.text).isValid()) { + // // FocusScope.of(context).requestFocus(_sendAddressFocusNode); + // // } + // }, ); } //************ Enter Address Container Method End ************// //*************************************************************// From 425e72b2a9b318383eaf330e1998ef5f21b1d7d8 Mon Sep 17 00:00:00 2001 From: Aleksander Rem Date: Tue, 19 Jan 2021 17:39:48 +0100 Subject: [PATCH 3/5] Include currency in amount hint --- lib/ui/receive/receive_sheet.dart | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/ui/receive/receive_sheet.dart b/lib/ui/receive/receive_sheet.dart index f1b76e87..eae8a591 100755 --- a/lib/ui/receive/receive_sheet.dart +++ b/lib/ui/receive/receive_sheet.dart @@ -28,14 +28,14 @@ import 'package:flare_flutter/flare_actor.dart'; class ReceiveSheet extends StatefulWidget { final AvailableCurrency localCurrency; - final Widget qrWidget; final String address; + final Widget qrWidget; - ReceiveSheet({ - @required this.localCurrency, - this.address, - this.qrWidget} - ) : super(); + ReceiveSheet( + {@required this.localCurrency, + this.address, + this.qrWidget}) + : super(); _ReceiveSheetStateState createState() => _ReceiveSheetStateState(); } @@ -51,12 +51,13 @@ class _ReceiveSheetStateState extends State { // Timer reference so we can cancel repeated events Timer _addressCopiedTimer; - // New vars FocusNode _receiveAmountFocusNode; TextEditingController _receiveAmountController; + NumberFormat _localCurrencyFormat; bool _localCurrencyMode = false; String _amountHint = ""; + String _lastLocalCurrencyAmount = ""; String _lastCryptoAmount = ""; @@ -555,7 +556,7 @@ class _ReceiveSheetStateState extends State { maxLines: null, autocorrect: false, hintText: - _amountHint == null ? "" : AppLocalization.of(context).enterAmount, + _amountHint == null ? "" : AppLocalization.of(context).enterAmount + (_localCurrencyMode ?' (' + _localCurrencyFormat.currencySymbol +')' : ' (NANO)'), prefixButton: TextFieldButton( icon: AppIcons.swapcurrency, onPressed: () { @@ -565,12 +566,6 @@ class _ReceiveSheetStateState extends State { fadeSuffixOnCondition: true, keyboardType: TextInputType.numberWithOptions(decimal: true), textAlign: TextAlign.center, - // onSubmitted: (text) { - // // FocusScope.of(context).unfocus(); - // // if (!Address(_sendAddressController.text).isValid()) { - // // FocusScope.of(context).requestFocus(_sendAddressFocusNode); - // // } - // }, ); } //************ Enter Address Container Method End ************// //*************************************************************// From a3ca0a4a5c83b7cc077790e1be00dcb4b4612f57 Mon Sep 17 00:00:00 2001 From: Aleksander Rem Date: Tue, 19 Jan 2021 17:53:45 +0100 Subject: [PATCH 4/5] Bugfix --- lib/ui/receive/receive_sheet.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ui/receive/receive_sheet.dart b/lib/ui/receive/receive_sheet.dart index eae8a591..dee7da3e 100755 --- a/lib/ui/receive/receive_sheet.dart +++ b/lib/ui/receive/receive_sheet.dart @@ -497,7 +497,7 @@ class _ReceiveSheetStateState extends State { if (_localCurrencyMode) { _lastLocalCurrencyAmount = _receiveAmountController.text; _lastCryptoAmount = _convertLocalCurrencyToCrypto(); - raw = NumberUtil.getAmountAsRaw(_lastCryptoAmount); + raw = _lastCryptoAmount.length > 0 ? NumberUtil.getAmountAsRaw(_lastCryptoAmount) : ''; } else { raw = _receiveAmountController.text.length > 0 ? NumberUtil.getAmountAsRaw(_receiveAmountController.text) : ''; } From ee1a4a438692d9104f4f653008d6fb8059c2c0ec Mon Sep 17 00:00:00 2001 From: Aleksander Rem Date: Tue, 19 Jan 2021 18:03:05 +0100 Subject: [PATCH 5/5] Cleanup --- lib/ui/receive/receive_sheet.dart | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/ui/receive/receive_sheet.dart b/lib/ui/receive/receive_sheet.dart index dee7da3e..f76e5d08 100755 --- a/lib/ui/receive/receive_sheet.dart +++ b/lib/ui/receive/receive_sheet.dart @@ -497,9 +497,13 @@ class _ReceiveSheetStateState extends State { if (_localCurrencyMode) { _lastLocalCurrencyAmount = _receiveAmountController.text; _lastCryptoAmount = _convertLocalCurrencyToCrypto(); - raw = _lastCryptoAmount.length > 0 ? NumberUtil.getAmountAsRaw(_lastCryptoAmount) : ''; + raw = _lastCryptoAmount.length > 0 + ? NumberUtil.getAmountAsRaw(_lastCryptoAmount) + : ''; } else { - raw = _receiveAmountController.text.length > 0 ? NumberUtil.getAmountAsRaw(_receiveAmountController.text) : ''; + raw = _receiveAmountController.text.length > 0 + ? NumberUtil.getAmountAsRaw(_receiveAmountController.text) + : ''; } this.paintQrCode(address: widget.address, amount: raw); } @@ -556,7 +560,8 @@ class _ReceiveSheetStateState extends State { maxLines: null, autocorrect: false, hintText: - _amountHint == null ? "" : AppLocalization.of(context).enterAmount + (_localCurrencyMode ?' (' + _localCurrencyFormat.currencySymbol +')' : ' (NANO)'), + _amountHint == null ? "" : AppLocalization.of(context).enterAmount + + (_localCurrencyMode ?' (' + _localCurrencyFormat.currencySymbol +')' : ' (NANO)'), prefixButton: TextFieldButton( icon: AppIcons.swapcurrency, onPressed: () {