mirror of
https://github.com/zapstore/zapstore.git
synced 2026-10-06 04:58:23 +00:00
Fix zaps text, only allow zaps when NWC loaded
This commit is contained in:
+97
-93
@@ -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<int>(
|
||||
// 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<int>(
|
||||
// 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(
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user