Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 33 additions & 46 deletions lib/features/order/screens/add_lightning_invoice_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,55 +67,42 @@ class _AddLightningInvoiceScreenState
(amount ?? 0) > 0;

return Scaffold(
backgroundColor: AppTheme.backgroundDark,
backgroundColor: AppTheme.dark1,
appBar: OrderAppBar(title: S.of(context)!.addLightningInvoice),
body: Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewPadding.bottom,
),
child: Column(
children: [
Expanded(
child: Container(
margin: const EdgeInsets.all(16),
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: AppTheme.backgroundCard,
borderRadius: BorderRadius.circular(16),
border:
Border.all(color: Colors.white.withValues(alpha: 0.1)),
),
child: showLnAddressConfirmation
? _buildLnAddressConfirmation(
orderIdValue: orderIdValue,
)
: showNwcInvoice
? _buildNwcInvoiceFlow(
amount: amount ?? 0,
fiatAmount: fiatAmount,
fiatCode: fiatCode,
orderIdValue: orderIdValue,
)
: AddLightningInvoiceWidget(
controller: invoiceController,
onSubmit: () async {
final invoice = invoiceController.text.trim();
if (invoice.isNotEmpty) {
await _submitInvoice(invoice, amount);
}
},
onCancel: () async {
await _cancelOrder();
},
amount: amount ?? 0,
fiatAmount: fiatAmount,
fiatCode: fiatCode,
orderId: orderIdValue,
),
),
),
],
padding: EdgeInsets.fromLTRB(
16,
16,
16,
16 + MediaQuery.of(context).viewPadding.bottom,
),
child: showLnAddressConfirmation
? _buildLnAddressConfirmation(
orderIdValue: orderIdValue,
)
: showNwcInvoice
? _buildNwcInvoiceFlow(
amount: amount ?? 0,
fiatAmount: fiatAmount,
fiatCode: fiatCode,
orderIdValue: orderIdValue,
)
: AddLightningInvoiceWidget(
controller: invoiceController,
onSubmit: () async {
final invoice = invoiceController.text.trim();
if (invoice.isNotEmpty) {
await _submitInvoice(invoice, amount);
}
},
onCancel: () async {
await _cancelOrder();
},
amount: amount ?? 0,
fiatAmount: fiatAmount,
fiatCode: fiatCode,
orderId: orderIdValue,
),
),
);
},
Expand Down
133 changes: 67 additions & 66 deletions lib/features/order/screens/pay_lightning_invoice_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:mostro_mobile/core/app_theme.dart';
import 'package:mostro_mobile/features/order/providers/order_notifier_provider.dart';
import 'package:mostro_mobile/features/order/widgets/order_app_bar.dart';
import 'package:mostro_mobile/features/wallet/providers/nwc_provider.dart';
import 'package:mostro_mobile/shared/widgets/custom_card.dart';
import 'package:mostro_mobile/shared/widgets/nwc_payment_widget.dart';
import 'package:mostro_mobile/shared/widgets/pay_lightning_invoice_widget.dart';
import 'package:mostro_mobile/generated/l10n.dart';
Expand Down Expand Up @@ -42,74 +41,76 @@ class _PayLightningInvoiceScreenState
return Scaffold(
backgroundColor: AppTheme.dark1,
appBar: OrderAppBar(title: S.of(context)!.payLightningInvoice),
body: CustomCard(
padding: const EdgeInsets.all(16),
child: Material(
color: AppTheme.dark2,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (showNwcPayment) ...[
// NWC auto-payment flow
Text(
S.of(context)!.payInvoiceToContinue(
sats.toString(),
fiatCode,
fiatAmount,
widget.orderId,
),
style: const TextStyle(color: AppTheme.cream1, fontSize: 18),
textAlign: TextAlign.center,
),
const SizedBox(height: 24),
NwcPaymentWidget(
lnInvoice: lnInvoice,
sats: sats,
onPaymentSuccess: () {
// Payment succeeded — Mostro will update the order state
// automatically via the event stream. We just navigate home.
context.go('/');
},
onFallbackToManual: () {
setState(() => _manualMode = true);
},
body: Padding(
padding: EdgeInsets.fromLTRB(
16,
16,
16,
16 + MediaQuery.of(context).viewPadding.bottom,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (showNwcPayment) ...[
// NWC auto-payment flow
Text(
S.of(context)!.payInvoiceToContinue(
sats.toString(),
fiatCode,
fiatAmount,
widget.orderId,
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () async {
context.go('/');
await orderNotifier.cancelOrder();
},
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: Colors.red,
),
child: Text(S.of(context)!.cancel),
style: const TextStyle(color: AppTheme.cream1, fontSize: 18),
textAlign: TextAlign.center,
),
const SizedBox(height: 24),
NwcPaymentWidget(
lnInvoice: lnInvoice,
sats: sats,
onPaymentSuccess: () {
// Payment succeeded — Mostro will update the order state
// automatically via the event stream. We just navigate home.
context.go('/');
},
onFallbackToManual: () {
setState(() => _manualMode = true);
},
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () async {
context.go('/');
await orderNotifier.cancelOrder();
},
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: Colors.red,
),
],
),
] else ...[
// Manual payment flow (original)
PayLightningInvoiceWidget(
onSubmit: () async {
context.go('/');
},
onCancel: () async {
context.go('/');
await orderNotifier.cancelOrder();
},
lnInvoice: lnInvoice,
sats: sats,
fiatAmount: fiatAmount,
fiatCode: fiatCode,
orderId: widget.orderId,
),
],
child: Text(S.of(context)!.cancel),
),
],
),
] else ...[
// Manual payment flow (original)
PayLightningInvoiceWidget(
onSubmit: () async {
context.go('/');
},
onCancel: () async {
context.go('/');
await orderNotifier.cancelOrder();
},
lnInvoice: lnInvoice,
sats: sats,
fiatAmount: fiatAmount,
fiatCode: fiatCode,
orderId: widget.orderId,
),
],
),
],
),
),
);
Expand Down
Loading