Skip to content

Commit

Permalink
Merge pull request #1025 from get10101/wait-to-send-payment
Browse files Browse the repository at this point in the history
Enable "Send Payment" button only when the invoice is validated
  • Loading branch information
Restioson authored Jul 28, 2023
2 parents cced67a + 6852939 commit 2ba04d0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum PendingPaymentState {

class PendingPayment {
PendingPaymentState state;
bool displayed = false;
final String rawInvoice;
final LightningInvoice decodedInvoice;

Expand Down
15 changes: 7 additions & 8 deletions mobile/lib/features/wallet/send_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,13 @@ class _SendScreenState extends State<SendScreen> {
mainAxisAlignment: MainAxisAlignment.end,
children: [
ElevatedButton(
onPressed: () async {
if (_formKey.currentState!.validate()) {
context
.read<SendPaymentChangeNotifier>()
.sendPayment(_textEditingController.text, _lightningInvoice!);
GoRouter.of(context).go(WalletScreen.route);
}
},
onPressed: !(_formKey.currentState?.validate() ?? false)
? null
: () async {
context.read<SendPaymentChangeNotifier>().sendPayment(
_textEditingController.text, _lightningInvoice!);
GoRouter.of(context).go(WalletScreen.route);
},
child: const Text("Send Payment")),
],
),
Expand Down
3 changes: 2 additions & 1 deletion mobile/lib/features/wallet/wallet_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class _WalletScreenState extends State<WalletScreen> {
context.watch<SendPaymentChangeNotifier>();

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,
Expand Down

0 comments on commit 2ba04d0

Please sign in to comment.