From 4b58f3ec6059a3f40204a0b8e0c62cbd12a0d855 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 30 Dec 2022 11:36:00 -0600 Subject: [PATCH] mac desktop keyboard type crash fix --- .../generate_receiving_uri_qr_code_view.dart | 5 +++-- lib/pages/send_view/send_view.dart | 21 +++++++++++-------- .../wallet_settings_view.dart | 3 ++- .../transaction_search_filter_view.dart | 10 +++++---- .../wallet_view/sub_widgets/desktop_send.dart | 20 +++++++++++------- .../textfields/exchange_textfield.dart | 13 ++++++++---- 6 files changed, 44 insertions(+), 28 deletions(-) diff --git a/lib/pages/receive_view/generate_receiving_uri_qr_code_view.dart b/lib/pages/receive_view/generate_receiving_uri_qr_code_view.dart index 27bc7b151..3c61681f0 100644 --- a/lib/pages/receive_view/generate_receiving_uri_qr_code_view.dart +++ b/lib/pages/receive_view/generate_receiving_uri_qr_code_view.dart @@ -409,8 +409,9 @@ class _GenerateUriQrCodeViewState extends State { height: 1.8, ) : STextStyles.field(context), - keyboardType: - const TextInputType.numberWithOptions(decimal: true), + keyboardType: Util.isDesktop + ? null + : const TextInputType.numberWithOptions(decimal: true), onChanged: (_) => setState(() {}), decoration: standardInputDecoration( "Amount", diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index b129c4467..e34b9d8ad 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -1111,10 +1111,12 @@ class _SendViewState extends ConsumerState { const Key("amountInputFieldCryptoTextFieldKey"), controller: cryptoAmountController, focusNode: _cryptoFocus, - keyboardType: const TextInputType.numberWithOptions( - signed: false, - decimal: true, - ), + keyboardType: Util.isDesktop + ? null + : const TextInputType.numberWithOptions( + signed: false, + decimal: true, + ), textAlign: TextAlign.right, inputFormatters: [ // regex to validate a crypto amount with 8 decimal places @@ -1168,11 +1170,12 @@ class _SendViewState extends ConsumerState { const Key("amountInputFieldFiatTextFieldKey"), controller: baseAmountController, focusNode: _baseFocus, - keyboardType: - const TextInputType.numberWithOptions( - signed: false, - decimal: true, - ), + keyboardType: Util.isDesktop + ? null + : const TextInputType.numberWithOptions( + signed: false, + decimal: true, + ), textAlign: TextAlign.right, inputFormatters: [ // regex to validate a fiat amount with 2 decimal places diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart index 92b712111..f27f57312 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart @@ -391,7 +391,8 @@ class _EpiBoxInfoFormState extends ConsumerState { enableSuggestions: Util.isDesktop ? false : true, controller: portController, decoration: const InputDecoration(hintText: "Port"), - keyboardType: const TextInputType.numberWithOptions(), + keyboardType: + Util.isDesktop ? null : const TextInputType.numberWithOptions(), ), const SizedBox( height: 8, diff --git a/lib/pages/wallet_view/transaction_views/transaction_search_filter_view.dart b/lib/pages/wallet_view/transaction_views/transaction_search_filter_view.dart index 7e1b53cbb..d0e013d83 100644 --- a/lib/pages/wallet_view/transaction_views/transaction_search_filter_view.dart +++ b/lib/pages/wallet_view/transaction_views/transaction_search_filter_view.dart @@ -739,10 +739,12 @@ class _TransactionSearchViewState controller: _amountTextEditingController, focusNode: amountTextFieldFocusNode, onChanged: (_) => setState(() {}), - keyboardType: const TextInputType.numberWithOptions( - signed: false, - decimal: true, - ), + keyboardType: Util.isDesktop + ? null + : const TextInputType.numberWithOptions( + signed: false, + decimal: true, + ), inputFormatters: [ // regex to validate a crypto amount with 8 decimal places TextInputFormatter.withFunction((oldValue, newValue) => diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart index f1b967471..14f097bde 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart @@ -1002,10 +1002,12 @@ class _DesktopSendState extends ConsumerState { key: const Key("amountInputFieldCryptoTextFieldKey"), controller: cryptoAmountController, focusNode: _cryptoFocus, - keyboardType: const TextInputType.numberWithOptions( - signed: false, - decimal: true, - ), + keyboardType: Util.isDesktop + ? null + : const TextInputType.numberWithOptions( + signed: false, + decimal: true, + ), textAlign: TextAlign.right, inputFormatters: [ // regex to validate a crypto amount with 8 decimal places @@ -1056,10 +1058,12 @@ class _DesktopSendState extends ConsumerState { key: const Key("amountInputFieldFiatTextFieldKey"), controller: baseAmountController, focusNode: _baseFocus, - keyboardType: const TextInputType.numberWithOptions( - signed: false, - decimal: true, - ), + keyboardType: Util.isDesktop + ? null + : const TextInputType.numberWithOptions( + signed: false, + decimal: true, + ), textAlign: TextAlign.right, inputFormatters: [ // regex to validate a fiat amount with 2 decimal places diff --git a/lib/widgets/textfields/exchange_textfield.dart b/lib/widgets/textfields/exchange_textfield.dart index 399d077c4..6681e9e8e 100644 --- a/lib/widgets/textfields/exchange_textfield.dart +++ b/lib/widgets/textfields/exchange_textfield.dart @@ -4,6 +4,7 @@ import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/loading_indicator.dart'; class ExchangeTextField extends StatefulWidget { @@ -62,6 +63,8 @@ class _ExchangeTextFieldState extends State { late final void Function(String)? onChanged; late final void Function(String)? onSubmitted; + final isDesktop = Util.isDesktop; + @override void initState() { borderRadius = widget.borderRadius; @@ -100,10 +103,12 @@ class _ExchangeTextFieldState extends State { enableSuggestions: false, autocorrect: false, readOnly: widget.readOnly, - keyboardType: const TextInputType.numberWithOptions( - signed: false, - decimal: true, - ), + keyboardType: isDesktop + ? null + : const TextInputType.numberWithOptions( + signed: false, + decimal: true, + ), decoration: InputDecoration( contentPadding: const EdgeInsets.only( top: 12,