From 7641539bf74ac68635f513992c661e8c54d20cff Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 30 Nov 2022 11:36:58 -0600 Subject: [PATCH] move tx note field to confirm tx page on desktop --- .../send_view/confirm_transaction_view.dart | 169 ++++++++++++++---- .../wallet_view/sub_widgets/desktop_send.dart | 148 ++++++++------- 2 files changed, 206 insertions(+), 111 deletions(-) diff --git a/lib/pages/send_view/confirm_transaction_view.dart b/lib/pages/send_view/confirm_transaction_view.dart index f1075b6e6..b006aeb79 100644 --- a/lib/pages/send_view/confirm_transaction_view.dart +++ b/lib/pages/send_view/confirm_transaction_view.dart @@ -28,9 +28,12 @@ import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; import 'package:stackwallet/widgets/rounded_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; +import 'package:stackwallet/widgets/stack_text_field.dart'; +import 'package:stackwallet/widgets/textfield_icon_button.dart'; class ConfirmTransactionView extends ConsumerStatefulWidget { const ConfirmTransactionView({ @@ -60,6 +63,9 @@ class _ConfirmTransactionViewState late final String routeOnSuccessName; late final bool isDesktop; + late final FocusNode _noteFocusNode; + late final TextEditingController noteController; + Future _attemptSend(BuildContext context) async { unawaited( showDialog( @@ -72,7 +78,7 @@ class _ConfirmTransactionViewState ), ); - final note = transactionInfo["note"] as String? ?? ""; + final note = noteController.text; final manager = ref.read(walletsChangeNotifierProvider).getManager(walletId); @@ -194,9 +200,20 @@ class _ConfirmTransactionViewState transactionInfo = widget.transactionInfo; walletId = widget.walletId; routeOnSuccessName = widget.routeOnSuccessName; + _noteFocusNode = FocusNode(); + noteController = TextEditingController(); + noteController.text = transactionInfo["note"] as String? ?? ""; super.initState(); } + @override + void dispose() { + noteController.dispose(); + + _noteFocusNode.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { final managerProvider = ref.watch(walletsChangeNotifierProvider @@ -563,50 +580,132 @@ class _ConfirmTransactionViewState ], ), ), - Container( - height: 1, - color: Theme.of(context) - .extension()! - .background, - ), - Padding( - padding: const EdgeInsets.all(12), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Note", - style: STextStyles.desktopTextExtraExtraSmall( - context), - ), - const SizedBox( - height: 2, - ), - Text( - transactionInfo["note"] as String, - style: STextStyles.desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of(context) - .extension()! - .textDark, - ), - ) - ], - ), - ), + // Container( + // height: 1, + // color: Theme.of(context) + // .extension()! + // .background, + // ), + // Padding( + // padding: const EdgeInsets.all(12), + // child: Column( + // mainAxisSize: MainAxisSize.min, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text( + // "Note", + // style: STextStyles.desktopTextExtraExtraSmall( + // context), + // ), + // const SizedBox( + // height: 2, + // ), + // Text( + // transactionInfo["note"] as String, + // style: STextStyles.desktopTextExtraExtraSmall( + // context) + // .copyWith( + // color: Theme.of(context) + // .extension()! + // .textDark, + // ), + // ) + // ], + // ), + // ), ], ), ), ), + if (isDesktop) + Padding( + padding: const EdgeInsets.only( + left: 32, + right: 32, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Note (optional)", + style: + STextStyles.desktopTextExtraSmall(context).copyWith( + color: Theme.of(context) + .extension()! + .textFieldActiveSearchIconRight, + ), + textAlign: TextAlign.left, + ), + const SizedBox( + height: 10, + ), + ClipRRect( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + child: TextField( + minLines: 1, + maxLines: 5, + autocorrect: isDesktop ? false : true, + enableSuggestions: isDesktop ? false : true, + controller: noteController, + focusNode: _noteFocusNode, + style: + STextStyles.desktopTextExtraSmall(context).copyWith( + color: Theme.of(context) + .extension()! + .textFieldActiveText, + height: 1.8, + ), + onChanged: (_) => setState(() {}), + decoration: standardInputDecoration( + "Type something...", + _noteFocusNode, + context, + desktopMed: true, + ).copyWith( + contentPadding: const EdgeInsets.only( + left: 16, + top: 11, + bottom: 12, + right: 5, + ), + suffixIcon: noteController.text.isNotEmpty + ? Padding( + padding: const EdgeInsets.only(right: 0), + child: UnconstrainedBox( + child: Row( + children: [ + TextFieldIconButton( + child: const XIcon(), + onTap: () async { + setState( + () => noteController.text = "", + ); + }, + ), + ], + ), + ), + ) + : null, + ), + ), + ), + const SizedBox( + height: 20, + ) + ], + ), + ), if (isDesktop) Padding( padding: const EdgeInsets.only( left: 32, ), child: Text( - "Transaction fee (estimated)", + "Transaction fee", style: STextStyles.desktopTextExtraExtraSmall(context), ), ), diff --git a/lib/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/desktop_send.dart b/lib/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/desktop_send.dart index 72690c7e5..1d7da697a 100644 --- a/lib/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/desktop_send.dart +++ b/lib/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/desktop_send.dart @@ -71,16 +71,16 @@ class _DesktopSendState extends ConsumerState { late TextEditingController sendToController; late TextEditingController cryptoAmountController; late TextEditingController baseAmountController; - late TextEditingController noteController; // late TextEditingController feeController; late final SendViewAutoFillData? _data; final _addressFocusNode = FocusNode(); - final _noteFocusNode = FocusNode(); final _cryptoFocus = FocusNode(); final _baseFocus = FocusNode(); + String? _note; + Decimal? _amountToSend; Decimal? _cachedAmountToSend; String? _address; @@ -255,7 +255,6 @@ class _DesktopSendState extends ConsumerState { sendToController.text = ""; cryptoAmountController.text = ""; baseAmountController.text = ""; - noteController.text = ""; }); }, ), @@ -325,7 +324,7 @@ class _DesktopSendState extends ConsumerState { context, rootNavigator: true, ).pop(); - txData["note"] = noteController.text; + txData["note"] = _note; txData["address"] = _address; unawaited( @@ -633,9 +632,9 @@ class _DesktopSendState extends ConsumerState { // autofill notes field if (results["message"] != null) { - noteController.text = results["message"]!; + _note = results["message"]!; } else if (results["label"] != null) { - noteController.text = results["label"]!; + _note = results["label"]!; } // autofill amount field @@ -783,7 +782,6 @@ class _DesktopSendState extends ConsumerState { sendToController = TextEditingController(); cryptoAmountController = TextEditingController(); baseAmountController = TextEditingController(); - noteController = TextEditingController(); // feeController = TextEditingController(); onCryptoAmountChanged = _cryptoAmountChanged; @@ -828,10 +826,8 @@ class _DesktopSendState extends ConsumerState { sendToController.dispose(); cryptoAmountController.dispose(); baseAmountController.dispose(); - noteController.dispose(); // feeController.dispose(); - _noteFocusNode.dispose(); _addressFocusNode.dispose(); _cryptoFocus.dispose(); _baseFocus.dispose(); @@ -1298,73 +1294,73 @@ class _DesktopSendState extends ConsumerState { } }, ), - const SizedBox( - height: 20, - ), - Text( - "Note (optional)", - style: STextStyles.desktopTextExtraSmall(context).copyWith( - color: Theme.of(context) - .extension()! - .textFieldActiveSearchIconRight, - ), - textAlign: TextAlign.left, - ), - const SizedBox( - height: 10, - ), - ClipRRect( - borderRadius: BorderRadius.circular( - Constants.size.circularBorderRadius, - ), - child: TextField( - minLines: 1, - maxLines: 5, - autocorrect: Util.isDesktop ? false : true, - enableSuggestions: Util.isDesktop ? false : true, - controller: noteController, - focusNode: _noteFocusNode, - style: STextStyles.desktopTextExtraSmall(context).copyWith( - color: Theme.of(context) - .extension()! - .textFieldActiveText, - height: 1.8, - ), - onChanged: (_) => setState(() {}), - decoration: standardInputDecoration( - "Type something...", - _noteFocusNode, - context, - desktopMed: true, - ).copyWith( - contentPadding: const EdgeInsets.only( - left: 16, - top: 11, - bottom: 12, - right: 5, - ), - suffixIcon: noteController.text.isNotEmpty - ? Padding( - padding: const EdgeInsets.only(right: 0), - child: UnconstrainedBox( - child: Row( - children: [ - TextFieldIconButton( - child: const XIcon(), - onTap: () async { - setState(() { - noteController.text = ""; - }); - }, - ), - ], - ), - ), - ) - : null, - ), - ), - ), + // const SizedBox( + // height: 20, + // ), + // Text( + // "Note (optional)", + // style: STextStyles.desktopTextExtraSmall(context).copyWith( + // color: Theme.of(context) + // .extension()! + // .textFieldActiveSearchIconRight, + // ), + // textAlign: TextAlign.left, + // ), + // const SizedBox( + // height: 10, + // ), + // ClipRRect( + // borderRadius: BorderRadius.circular( + // Constants.size.circularBorderRadius, + // ), + // child: TextField( + // minLines: 1, + // maxLines: 5, + // autocorrect: Util.isDesktop ? false : true, + // enableSuggestions: Util.isDesktop ? false : true, + // controller: noteController, + // focusNode: _noteFocusNode, + // style: STextStyles.desktopTextExtraSmall(context).copyWith( + // color: Theme.of(context) + // .extension()! + // .textFieldActiveText, + // height: 1.8, + // ), + // onChanged: (_) => setState(() {}), + // decoration: standardInputDecoration( + // "Type something...", + // _noteFocusNode, + // context, + // desktopMed: true, + // ).copyWith( + // contentPadding: const EdgeInsets.only( + // left: 16, + // top: 11, + // bottom: 12, + // right: 5, + // ), + // suffixIcon: noteController.text.isNotEmpty + // ? Padding( + // padding: const EdgeInsets.only(right: 0), + // child: UnconstrainedBox( + // child: Row( + // children: [ + // TextFieldIconButton( + // child: const XIcon(), + // onTap: () async { + // setState(() { + // noteController.text = ""; + // }); + // }, + // ), + // ], + // ), + // ), + // ) + // : null, + // ), + // ), + // ), const SizedBox( height: 20, ),