From ff944928b6589cd7fb7c4b574c53adf7663307b3 Mon Sep 17 00:00:00 2001 From: likho Date: Mon, 31 Jul 2023 12:16:08 +0200 Subject: [PATCH] fix: Onchain notes missing for desktop --- .../send_view/confirm_transaction_view.dart | 73 ++++++++++++++++++- .../wallet_view/sub_widgets/desktop_send.dart | 4 + 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/lib/pages/send_view/confirm_transaction_view.dart b/lib/pages/send_view/confirm_transaction_view.dart index a1fc66f21..152437c23 100644 --- a/lib/pages/send_view/confirm_transaction_view.dart +++ b/lib/pages/send_view/confirm_transaction_view.dart @@ -89,6 +89,11 @@ class _ConfirmTransactionViewState late final FocusNode _noteFocusNode; late final TextEditingController noteController; + + late final FocusNode _onChainNoteFocusNode; + late final TextEditingController onChainNoteController; + + Future _attemptSend(BuildContext context) async { final manager = ref.read(walletsChangeNotifierProvider).getManager(walletId); @@ -138,6 +143,9 @@ class _ConfirmTransactionViewState txidFuture = (manager.wallet as FiroWallet) .confirmSendPublic(txData: transactionInfo); } else { + if (coin == Coin.epicCash) { + transactionInfo["onChainNote"] = onChainNoteController.text; + } txidFuture = manager.confirmSend(txData: transactionInfo); } } @@ -272,14 +280,21 @@ class _ConfirmTransactionViewState _noteFocusNode = FocusNode(); noteController = TextEditingController(); noteController.text = transactionInfo["note"] as String? ?? ""; + + _onChainNoteFocusNode = FocusNode(); + onChainNoteController = TextEditingController(); + onChainNoteController.text = transactionInfo["onChainNote"] as String? ?? ""; + super.initState(); } @override void dispose() { noteController.dispose(); + onChainNoteController.dispose(); _noteFocusNode.dispose(); + _onChainNoteFocusNode.dispose(); super.dispose(); } @@ -840,8 +855,64 @@ class _ConfirmTransactionViewState mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ + if (coin == Coin.epicCash) + Text( + "On chain Note (optional)", + style: STextStyles.smallMed12(context), + textAlign: TextAlign.left, + ), + if (coin == Coin.epicCash) + const SizedBox( + height: 8, + ), + if (coin == Coin.epicCash) + ClipRRect( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + child: TextField( + autocorrect: Util.isDesktop ? false : true, + enableSuggestions: Util.isDesktop ? false : true, + maxLength: 256, + controller: onChainNoteController, + focusNode: _onChainNoteFocusNode, + style: STextStyles.field(context), + onChanged: (_) => setState(() {}), + decoration: standardInputDecoration( + "Type something...", + _onChainNoteFocusNode, + context, + ).copyWith( + suffixIcon: onChainNoteController.text.isNotEmpty + ? Padding( + padding: + const EdgeInsets.only(right: 0), + child: UnconstrainedBox( + child: Row( + children: [ + TextFieldIconButton( + child: const XIcon(), + onTap: () async { + setState(() { + onChainNoteController.text = ""; + }); + }, + ), + ], + ), + ), + ) + : null, + ), + ), + ), + if (coin == Coin.epicCash) + const SizedBox( + height: 12, + ), Text( - "Note (optional)", + (coin == Coin.epicCash) ? "Local Note (optional)" + : "Note (optional)", style: STextStyles.desktopTextExtraSmall(context).copyWith( color: Theme.of(context) 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 0488358a7..3d65eb6e2 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 @@ -105,6 +105,7 @@ class _DesktopSendState extends ConsumerState { final _baseFocus = FocusNode(); String? _note; + String? _onChainNote; Amount? _amountToSend; Amount? _cachedAmountToSend; @@ -354,6 +355,9 @@ class _DesktopSendState extends ConsumerState { } else { txData["address"] = _address; txData["note"] = _note ?? ""; + if (coin == Coin.epicCash) { + txData['onChainNote'] = _onChainNote ?? ""; + } } // pop building dialog Navigator.of(