Skip to content

Commit 4ab9399

Browse files
authored
Merge pull request #156 from MostroP2P/add-message-invoice-screen
Add order information when displaying or requesting the invoice
2 parents 2046bbc + 73348ee commit 4ab9399

File tree

9 files changed

+193
-21
lines changed

9 files changed

+193
-21
lines changed

lib/features/order/screens/add_lightning_invoice_screen.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class _AddLightningInvoiceScreenState
3131
data: (mostroMessage) {
3232
final orderPayload = mostroMessage?.getPayload<Order>();
3333
final amount = orderPayload?.amount;
34+
final fiatAmount = orderPayload?.fiatAmount.toString() ?? '0';
35+
final fiatCode = orderPayload?.fiatCode ?? '';
36+
final orderIdValue = orderPayload?.id ?? orderId;
3437

3538
return Scaffold(
3639
backgroundColor: AppTheme.dark1,
@@ -86,6 +89,9 @@ class _AddLightningInvoiceScreenState
8689
}
8790
},
8891
amount: amount ?? 0,
92+
fiatAmount: fiatAmount,
93+
fiatCode: fiatCode,
94+
orderId: orderIdValue,
8995
),
9096
),
9197
),

lib/features/order/screens/pay_lightning_invoice_screen.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ class _PayLightningInvoiceScreenState
2222
extends ConsumerState<PayLightningInvoiceScreen> {
2323
@override
2424
Widget build(BuildContext context) {
25-
final order = ref.watch(orderNotifierProvider(widget.orderId));
26-
final lnInvoice = order.paymentRequest?.lnInvoice ?? '';
25+
final orderState = ref.watch(orderNotifierProvider(widget.orderId));
26+
final lnInvoice = orderState.paymentRequest?.lnInvoice ?? '';
27+
final sats = orderState.order?.amount ?? 0;
28+
final fiatAmount = orderState.order?.fiatAmount.toString() ?? '0';
29+
final fiatCode = orderState.order?.fiatCode ?? '';
2730
final orderNotifier =
2831
ref.watch(orderNotifierProvider(widget.orderId).notifier);
2932

@@ -45,7 +48,11 @@ class _PayLightningInvoiceScreenState
4548
context.go('/');
4649
await orderNotifier.cancelOrder();
4750
},
48-
lnInvoice: lnInvoice),
51+
lnInvoice: lnInvoice,
52+
sats: sats,
53+
fiatAmount: fiatAmount,
54+
fiatCode: fiatCode,
55+
orderId: widget.orderId),
4956
],
5057
),
5158
),

lib/features/order/widgets/lightning_address_section.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:mostro_mobile/features/order/widgets/form_section.dart';
3+
import 'package:mostro_mobile/generated/l10n.dart';
34

45
class LightningAddressSection extends StatelessWidget {
56
final TextEditingController controller;
@@ -12,16 +13,16 @@ class LightningAddressSection extends StatelessWidget {
1213
@override
1314
Widget build(BuildContext context) {
1415
return FormSection(
15-
title: 'Lightning Address (optional)',
16+
title: S.of(context)!.lightningAddressOptional,
1617
icon: const Icon(Icons.bolt, color: Colors.amber, size: 18),
1718
iconBackgroundColor: Colors.amber.withValues(alpha: 0.3),
1819
child: TextField(
1920
controller: controller,
2021
style: const TextStyle(color: Colors.white),
21-
decoration: const InputDecoration(
22+
decoration: InputDecoration(
2223
border: InputBorder.none,
23-
hintText: 'Enter lightning address',
24-
hintStyle: TextStyle(color: Colors.grey),
24+
hintText: S.of(context)!.enterLightningAddress,
25+
hintStyle: const TextStyle(color: Colors.grey),
2526
),
2627
),
2728
);

lib/features/order/widgets/order_type_header.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:mostro_mobile/data/models/enums/order_type.dart';
3+
import 'package:mostro_mobile/generated/l10n.dart';
34

45
class OrderTypeHeader extends StatelessWidget {
56
final OrderType orderType;
@@ -22,8 +23,8 @@ class OrderTypeHeader extends StatelessWidget {
2223
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 8),
2324
child: Text(
2425
orderType == OrderType.buy
25-
? 'You want to buy Bitcoin'
26-
: 'You want to sell Bitcoin',
26+
? S.of(context)!.youWantToBuyBitcoin
27+
: S.of(context)!.youWantToSellBitcoin,
2728
textAlign: TextAlign.center,
2829
style: const TextStyle(
2930
color: Colors.white,

lib/l10n/intl_en.arb

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@
319319
"invoiceExpirationWindow": "Invoice Expiration Window",
320320

321321
"@_comment_order_creation": "Order Creation Form Strings",
322+
"youWantToBuyBitcoin": "You want to buy Bitcoin",
323+
"youWantToSellBitcoin": "You want to sell Bitcoin",
324+
"lightningAddressOptional": "Lightning Address (optional)",
325+
"enterLightningAddress": "Enter lightning address",
322326
"enterFiatAmountBuy": "Enter the fiat amount you want to pay (you can set a range)",
323327
"enterFiatAmountSell": "Enter the fiat amount you want to receive (you can set a range)",
324328
"enterAmountHint": "Enter amount (example: 100 or 100-500)",
@@ -477,7 +481,27 @@
477481
},
478482

479483
"@_comment_lightning_invoice": "Lightning Invoice Widget Strings",
480-
"pleaseEnterLightningInvoiceFor": "Please enter a Lightning Invoice for: ",
484+
"pleaseEnterLightningInvoiceFor": "Please enter a Lightning Invoice for {sats} Sats equivalent to {fiat_code} {fiat_amount} to continue the exchange for order with ID {order_id}",
485+
"@pleaseEnterLightningInvoiceFor": {
486+
"placeholders": {
487+
"sats": {
488+
"type": "String",
489+
"description": "The amount of satoshis"
490+
},
491+
"fiat_code": {
492+
"type": "String",
493+
"description": "The fiat currency code"
494+
},
495+
"fiat_amount": {
496+
"type": "String",
497+
"description": "The fiat amount"
498+
},
499+
"order_id": {
500+
"type": "String",
501+
"description": "The order ID"
502+
}
503+
}
504+
},
481505
"sats": " sats",
482506
"lightningInvoice": "Lightning Invoice",
483507
"enterInvoiceHere": "Enter invoice here",
@@ -495,7 +519,27 @@
495519

496520
"@_comment_pay_invoice_screen": "Pay Lightning Invoice Screen Strings",
497521
"payLightningInvoice": "Pay Lightning Invoice",
498-
"payInvoiceToContinue": "Pay this invoice to continue the exchange",
522+
"payInvoiceToContinue": "Pay this invoice for {sats} Sats equivalent to {fiat_code} {fiat_amount} to continue the exchange for order {order_id}",
523+
"@payInvoiceToContinue": {
524+
"placeholders": {
525+
"sats": {
526+
"type": "String",
527+
"description": "The amount of satoshis"
528+
},
529+
"fiat_code": {
530+
"type": "String",
531+
"description": "The fiat currency code"
532+
},
533+
"fiat_amount": {
534+
"type": "String",
535+
"description": "The fiat amount"
536+
},
537+
"order_id": {
538+
"type": "String",
539+
"description": "The order ID"
540+
}
541+
}
542+
},
499543
"failedToGenerateQR": "Failed to generate QR code",
500544
"invoiceCopiedToClipboard": "Invoice copied to clipboard",
501545
"copy": "Copy",

lib/l10n/intl_es.arb

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@
282282
"invoiceExpirationWindow": "Ventana de Expiración de Factura",
283283

284284
"@_comment_order_creation": "Cadenas del Formulario de Creación de Orden",
285+
"youWantToBuyBitcoin": "Quieres comprar Bitcoin",
286+
"youWantToSellBitcoin": "Quieres vender Bitcoin",
287+
"lightningAddressOptional": "Lightning Address (opcional)",
288+
"enterLightningAddress": "Introduzca una lightning address",
285289
"enterFiatAmountBuy": "Ingresa la cantidad fiat que quieres pagar (puedes establecer un rango)",
286290
"enterFiatAmountSell": "Ingresa la cantidad fiat que quieres recibir (puedes establecer un rango)",
287291
"enterAmountHint": "Ingresa cantidad (ejemplo: 100 o 100-500)",
@@ -442,7 +446,27 @@
442446
},
443447

444448
"@_comment_lightning_invoice": "Cadenas de Widget de Factura Lightning",
445-
"pleaseEnterLightningInvoiceFor": "Por favor ingresa una Factura Lightning para: ",
449+
"pleaseEnterLightningInvoiceFor": "Ingresa una Factura Lightning de {sats} Sats equivalentes a {fiat_amount} {fiat_code} para continuar el intercambio de la orden con ID {order_id}",
450+
"@pleaseEnterLightningInvoiceFor": {
451+
"placeholders": {
452+
"sats": {
453+
"type": "String",
454+
"description": "La cantidad de satoshis"
455+
},
456+
"fiat_amount": {
457+
"type": "String",
458+
"description": "La cantidad fiat"
459+
},
460+
"fiat_code": {
461+
"type": "String",
462+
"description": "El código de moneda fiat"
463+
},
464+
"order_id": {
465+
"type": "String",
466+
"description": "El ID de la orden"
467+
}
468+
}
469+
},
446470
"sats": " sats",
447471
"lightningInvoice": "Factura Lightning",
448472
"enterInvoiceHere": "Ingresa la factura aquí",
@@ -460,7 +484,27 @@
460484

461485
"@_comment_pay_invoice_screen": "Cadenas de Pantalla de Pago de Factura Lightning",
462486
"payLightningInvoice": "Pagar Factura Lightning",
463-
"payInvoiceToContinue": "Paga esta factura para continuar el intercambio",
487+
"payInvoiceToContinue": "Paga esta factura de {sats} Sats equivalentes a {fiat_amount} {fiat_code} para continuar el intercambio de la orden {order_id}",
488+
"@payInvoiceToContinue": {
489+
"placeholders": {
490+
"sats": {
491+
"type": "String",
492+
"description": "La cantidad de satoshis"
493+
},
494+
"fiat_code": {
495+
"type": "String",
496+
"description": "El código de moneda fiat"
497+
},
498+
"fiat_amount": {
499+
"type": "String",
500+
"description": "La cantidad fiat"
501+
},
502+
"order_id": {
503+
"type": "String",
504+
"description": "El ID de la orden"
505+
}
506+
}
507+
},
464508
"failedToGenerateQR": "Error al generar código QR",
465509
"invoiceCopiedToClipboard": "Factura copiada al portapapeles",
466510
"copy": "Copiar",

lib/l10n/intl_it.arb

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@
282282
"invoiceExpirationWindow": "Finestra Scadenza Fattura",
283283

284284
"@_comment_order_creation": "Stringhe Modulo Creazione Ordine",
285+
"youWantToBuyBitcoin": "Vuoi comprare Bitcoin",
286+
"youWantToSellBitcoin": "Vuoi vendere Bitcoin",
287+
"lightningAddressOptional": "Lightning Address (opzionale)",
288+
"enterLightningAddress": "Inserisci lightning address",
285289
"enterFiatAmountBuy": "Inserisci l'importo fiat che vuoi pagare (puoi impostare un intervallo)",
286290
"enterFiatAmountSell": "Inserisci l'importo fiat che vuoi ricevere (puoi impostare un intervallo)",
287291
"enterAmountHint": "Inserisci importo (esempio: 100 o 100-500)",
@@ -442,7 +446,27 @@
442446
},
443447

444448
"@_comment_lightning_invoice": "Stringhe Widget Fattura Lightning",
445-
"pleaseEnterLightningInvoiceFor": "Per favore inserisci una Fattura Lightning per: ",
449+
"pleaseEnterLightningInvoiceFor": "Per favore inserisci una Fattura Lightning per {sats} Sats equivalenti a {fiat_amount} {fiat_code} per continuare lo scambio dell'ordine con ID {order_id}",
450+
"@pleaseEnterLightningInvoiceFor": {
451+
"placeholders": {
452+
"sats": {
453+
"type": "String",
454+
"description": "L'importo in satoshi"
455+
},
456+
"fiat_amount": {
457+
"type": "String",
458+
"description": "L'importo fiat"
459+
},
460+
"fiat_code": {
461+
"type": "String",
462+
"description": "Il codice della valuta fiat"
463+
},
464+
"order_id": {
465+
"type": "String",
466+
"description": "L'ID dell'ordine"
467+
}
468+
}
469+
},
446470
"sats": " sats",
447471
"lightningInvoice": "Fattura Lightning",
448472
"enterInvoiceHere": "Inserisci la fattura qui",
@@ -460,7 +484,27 @@
460484

461485
"@_comment_pay_invoice_screen": "Stringhe Schermata Pagamento Fattura Lightning",
462486
"payLightningInvoice": "Paga Fattura Lightning",
463-
"payInvoiceToContinue": "Paga questa fattura per continuare lo scambio",
487+
"payInvoiceToContinue": "Paga questa fattura di {sats} Sats equivalenti a {fiat_amount} {fiat_code} per continuare lo scambio dell'ordine {order_id}",
488+
"@payInvoiceToContinue": {
489+
"placeholders": {
490+
"sats": {
491+
"type": "String",
492+
"description": "L'importo in satoshi"
493+
},
494+
"fiat_code": {
495+
"type": "String",
496+
"description": "Il codice della valuta fiat"
497+
},
498+
"fiat_amount": {
499+
"type": "String",
500+
"description": "L'importo fiat"
501+
},
502+
"order_id": {
503+
"type": "String",
504+
"description": "L'ID dell'ordine"
505+
}
506+
}
507+
},
464508
"failedToGenerateQR": "Errore nella generazione del codice QR",
465509
"invoiceCopiedToClipboard": "Fattura copiata negli appunti",
466510
"copy": "Copia",

lib/shared/widgets/add_lightning_invoice_widget.dart

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
import 'package:flutter/material.dart';
22
import 'package:mostro_mobile/core/app_theme.dart';
3-
import 'package:mostro_mobile/shared/widgets/clickable_text_widget.dart';
43
import 'package:mostro_mobile/generated/l10n.dart';
54

65
class AddLightningInvoiceWidget extends StatefulWidget {
76
final TextEditingController controller;
87
final VoidCallback onSubmit;
98
final VoidCallback onCancel;
109
final int amount;
10+
final String fiatAmount;
11+
final String fiatCode;
12+
final String orderId;
1113

1214
const AddLightningInvoiceWidget({
1315
super.key,
1416
required this.controller,
1517
required this.onSubmit,
1618
required this.onCancel,
1719
required this.amount,
20+
required this.fiatAmount,
21+
required this.fiatCode,
22+
required this.orderId,
1823
});
1924

2025
@override
@@ -28,10 +33,17 @@ class _AddLightningInvoiceWidgetState extends State<AddLightningInvoiceWidget> {
2833
return Column(
2934
crossAxisAlignment: CrossAxisAlignment.start,
3035
children: [
31-
ClickableText(
32-
leftText: S.of(context)!.pleaseEnterLightningInvoiceFor,
33-
clickableText: '${widget.amount}',
34-
rightText: S.of(context)!.sats,
36+
Text(
37+
S.of(context)!.pleaseEnterLightningInvoiceFor(
38+
widget.amount.toString(),
39+
widget.fiatCode,
40+
widget.fiatAmount,
41+
widget.orderId,
42+
),
43+
style: const TextStyle(
44+
color: AppTheme.cream1,
45+
fontSize: 16,
46+
),
3547
),
3648
const SizedBox(height: 16),
3749
TextFormField(

lib/shared/widgets/pay_lightning_invoice_widget.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,20 @@ class PayLightningInvoiceWidget extends StatefulWidget {
1313
final VoidCallback onCancel;
1414
final Logger logger = Logger();
1515
final String lnInvoice;
16+
final int sats;
17+
final String fiatAmount;
18+
final String fiatCode;
19+
final String orderId;
1620

1721
PayLightningInvoiceWidget({
1822
super.key,
1923
required this.onSubmit,
2024
required this.onCancel,
2125
required this.lnInvoice,
26+
required this.sats,
27+
required this.fiatAmount,
28+
required this.fiatCode,
29+
required this.orderId,
2230
});
2331

2432
@override
@@ -33,7 +41,12 @@ class _PayLightningInvoiceWidgetState extends State<PayLightningInvoiceWidget> {
3341
crossAxisAlignment: CrossAxisAlignment.center,
3442
children: [
3543
Text(
36-
S.of(context)!.payInvoiceToContinue,
44+
S.of(context)!.payInvoiceToContinue(
45+
widget.sats.toString(),
46+
widget.fiatCode,
47+
widget.fiatAmount,
48+
widget.orderId,
49+
),
3750
style: const TextStyle(color: AppTheme.cream1, fontSize: 18),
3851
textAlign: TextAlign.center,
3952
),

0 commit comments

Comments
 (0)