diff --git a/lib/widgets/zap_button.dart b/lib/widgets/zap_button.dart index b09d369..f1e9f34 100644 --- a/lib/widgets/zap_button.dart +++ b/lib/widgets/zap_button.dart @@ -35,104 +35,108 @@ class ZapButton extends HookConsumerWidget { } return ElevatedButton( - onPressed: () async { - if (!nwcConnection.isPresent) { - await showDialog( - // ignore: use_build_context_synchronously - context: context, - builder: (_) => AlertDialog( - title: Text('Connect your wallet').bold, - content: NwcContainer(dialogMode: true), - ), - ); - } - - if (!ref.read(nwcConnectionProvider).isPresent) { - return; - } - - final amount = await showDialog( - // ignore: use_build_context_synchronously - context: context, - builder: (context) { - return AlertDialog( - title: Text('Choose zap amount').bold, - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - if (user == null) - SignInButton( - publicKeyAllowed: false, - minimal: true, - signedOutText: - '⚠️ If you do not sign in, you will be zapping anonymously', - ), - TextField( - controller: amountController, - keyboardType: TextInputType.number, - decoration: - InputDecoration(hintText: "Enter amount in sats"), + onPressed: nwcConnection.isLoading + ? null + : () async { + if (!nwcConnection.isPresent) { + await showDialog( + // ignore: use_build_context_synchronously + context: context, + builder: (_) => AlertDialog( + title: Text('Connect your wallet').bold, + content: NwcContainer(dialogMode: true), ), - SizedBox(height: 20), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - ElevatedButton( - onPressed: () => Navigator.of(context).pop(21), - child: Text('⚡️ 21'), + ); + if (!ref.read(nwcConnectionProvider).isPresent) { + return; + } + } + + final amount = await showDialog( + // ignore: use_build_context_synchronously + context: context, + builder: (context) { + return AlertDialog( + title: Text('Choose zap amount').bold, + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + if (user == null) + SignInButton( + publicKeyAllowed: false, + minimal: true, + signedOutText: + '⚠️ If you do not sign in, you will be zapping anonymously', + ), + TextField( + controller: amountController, + keyboardType: TextInputType.number, + decoration: + InputDecoration(hintText: "Enter amount in sats"), + ), + SizedBox(height: 20), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + ElevatedButton( + onPressed: () => Navigator.of(context).pop(21), + child: Text('⚡️ 21'), + ), + ElevatedButton( + onPressed: () => Navigator.of(context).pop(210), + child: Text('⚡️ 210'), + ), + ElevatedButton( + onPressed: () => Navigator.of(context).pop(2100), + child: Text('⚡️ 2100'), + ), + ], + ), + ], + ), + actions: [ + TextButton( + child: Text('Cancel'), + onPressed: () { + Navigator.of(context) + .pop(); // Dismiss the dialog without returning an amount + }, ), - ElevatedButton( - onPressed: () => Navigator.of(context).pop(210), - child: Text('⚡️ 210'), - ), - ElevatedButton( - onPressed: () => Navigator.of(context).pop(2100), - child: Text('⚡️ 2100'), + TextButton( + child: Text('Zap').bold, + onPressed: () { + Navigator.of(context) + .pop(int.tryParse(amountController.text) ?? 0); + }, ), ], - ), - ], - ), - actions: [ - TextButton( - child: Text('Cancel'), - onPressed: () { - Navigator.of(context) - .pop(); // Dismiss the dialog without returning an amount - }, - ), - TextButton( - child: Text('Zap').bold, - onPressed: () { - Navigator.of(context) - .pop(int.tryParse(amountController.text) ?? 0); - }, - ), - ], - ); - }, - ); + ); + }, + ); - if (amount != null && amount > 0) { - try { - // ignore: use_build_context_synchronously - context.showInfo('Zap sent!', - description: - '$amount sats on their way. Your zap should show up in a few seconds.'); - if (user != null) { - await user.zap(amount, event: app.latestMetadata!); - } else { - await anonUser! - .zap(amount, event: app.latestMetadata!, signer: pkSigner); - } - } catch (e) { - // ignore: use_build_context_synchronously - context.showError( - title: 'Unable to zap', description: e.toString()); - } - } - }, - style: ElevatedButton.styleFrom(backgroundColor: Colors.grey[800]), + if (amount != null && amount > 0) { + try { + // ignore: use_build_context_synchronously + context.showInfo('Zap sent!', + description: + '$amount sats on their way. Your zap should show up in a few seconds.'); + if (user != null) { + await user.zap(amount, event: app.latestMetadata!); + } else { + await anonUser!.zap(amount, + event: app.latestMetadata!, signer: pkSigner); + } + } catch (e) { + // ignore: use_build_context_synchronously + context.showError( + title: 'Unable to zap', description: e.toString()); + } + } + }, + style: ElevatedButton.styleFrom( + backgroundColor: Colors.grey[800], + disabledBackgroundColor: Colors.grey[500], + ), child: Text( '⚡️ Zap this release', style: TextStyle( diff --git a/lib/widgets/zap_receipts.dart b/lib/widgets/zap_receipts.dart index 3ce5002..6a24cec 100644 --- a/lib/widgets/zap_receipts.dart +++ b/lib/widgets/zap_receipts.dart @@ -50,9 +50,7 @@ class ZapReceipts extends HookConsumerWidget { return Padding( padding: const EdgeInsets.only(top: 10, bottom: 10), child: UsersRichText( - preSpan: TextSpan( - text: '⚡ $totalAmountInSats sats (${receipts.length} zaps) by'), - trailingText: ' and others', + preSpan: TextSpan(text: '⚡ $totalAmountInSats sats zapped from '), users: senders, ), );