From 003541c4a63499e7a11c79ab8a38a6ae919c1a41 Mon Sep 17 00:00:00 2001 From: Restioson Date: Thu, 27 Jul 2023 15:58:23 +0200 Subject: [PATCH 1/2] Enable "Send Payment" button only when the invoice is validated --- mobile/lib/features/wallet/send_screen.dart | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mobile/lib/features/wallet/send_screen.dart b/mobile/lib/features/wallet/send_screen.dart index cccbac24b..7bd89f902 100644 --- a/mobile/lib/features/wallet/send_screen.dart +++ b/mobile/lib/features/wallet/send_screen.dart @@ -207,14 +207,13 @@ class _SendScreenState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ ElevatedButton( - onPressed: () async { - if (_formKey.currentState!.validate()) { - context - .read() - .sendPayment(_textEditingController.text, _lightningInvoice!); - GoRouter.of(context).go(WalletScreen.route); - } - }, + onPressed: !(_formKey.currentState?.validate() ?? false) + ? null + : () async { + context.read().sendPayment( + _textEditingController.text, _lightningInvoice!); + GoRouter.of(context).go(WalletScreen.route); + }, child: const Text("Send Payment")), ], ), From 6852939404abc53b54709e3fd390e4c4dde0c4b4 Mon Sep 17 00:00:00 2001 From: Restioson Date: Thu, 27 Jul 2023 17:10:31 +0200 Subject: [PATCH 2/2] Reliably show payment result --- mobile/lib/features/wallet/send_payment_change_notifier.dart | 1 + mobile/lib/features/wallet/wallet_screen.dart | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mobile/lib/features/wallet/send_payment_change_notifier.dart b/mobile/lib/features/wallet/send_payment_change_notifier.dart index f7fe60aff..b318add98 100644 --- a/mobile/lib/features/wallet/send_payment_change_notifier.dart +++ b/mobile/lib/features/wallet/send_payment_change_notifier.dart @@ -11,6 +11,7 @@ enum PendingPaymentState { class PendingPayment { PendingPaymentState state; + bool displayed = false; final String rawInvoice; final LightningInvoice decodedInvoice; diff --git a/mobile/lib/features/wallet/wallet_screen.dart b/mobile/lib/features/wallet/wallet_screen.dart index 1fb40a372..95bfd2801 100644 --- a/mobile/lib/features/wallet/wallet_screen.dart +++ b/mobile/lib/features/wallet/wallet_screen.dart @@ -44,7 +44,8 @@ class _WalletScreenState extends State { context.watch(); if (sendPaymentChangeNotifier.pendingPayment != null && - sendPaymentChangeNotifier.pendingPayment!.state == PendingPaymentState.pending) { + !sendPaymentChangeNotifier.pendingPayment!.displayed) { + sendPaymentChangeNotifier.pendingPayment!.displayed = true; WidgetsBinding.instance.addPostFrameCallback((_) async { return await showDialog( context: context,