@@ -33,6 +33,7 @@ import 'package:lexeapp/logger.dart';
3333import 'package:lexeapp/result.dart' ;
3434import 'package:lexeapp/route/receive/state.dart'
3535 show
36+ AmountDescription,
3637 BtcAddrInputs,
3738 BtcAddrKind,
3839 LnInvoiceInputs,
@@ -468,27 +469,28 @@ class ReceivePaymentPageInnerState extends State<ReceivePaymentPageInner> {
468469 // Open an edit page when we press a "+ Amount" or "Edit" button for the given
469470 // page.
470471 Future <void > openEditPage (PaymentOfferKind kind) async {
471- // Only support setting amount/desc for invoices atm.
472- if (kind != PaymentOfferKind .lightningInvoice) return ;
473-
474472 switch (kind) {
475473 case PaymentOfferKind .lightningInvoice:
476- await this .openEditInvoicePage ();
474+ await this .openEditLnInvoicePage ();
475+ return ;
476+ case PaymentOfferKind .lightningOffer:
477+ await this .openEditLnOfferPage ();
477478 return ;
478-
479479 // Other kinds don't support editing amount/description yet.
480480 default :
481481 return ;
482482 }
483483 }
484484
485- Future <void > openEditInvoicePage () async {
486- final prev = this .lnInvoiceInputs.value;
485+ Future <void > openEditLnInvoicePage () async {
486+ final prevInvoice = this .lnInvoiceInputs.value;
487+ final prev = AmountDescription (
488+ amountSats: prevInvoice.amountSats,
489+ description: prevInvoice.description,
490+ );
487491
488- final LnInvoiceInputs ? flowResult = await Navigator .of (this .context).push (
489- MaterialPageRoute (
490- builder: (_) => ReceivePaymentEditInvoicePage (prev: prev),
491- ),
492+ final AmountDescription ? flowResult = await Navigator .of (this .context).push (
493+ MaterialPageRoute (builder: (_) => ReceivePaymentEditPage (prev: prev)),
492494 );
493495
494496 if (! this .mounted || flowResult == null || flowResult == prev) return ;
@@ -505,7 +507,43 @@ class ReceivePaymentPageInnerState extends State<ReceivePaymentPageInner> {
505507 );
506508
507509 // Update inputs to fetch new invoice.
508- this .lnInvoiceInputs.value = flowResult;
510+ final inputs = LnInvoiceInputs (
511+ amountSats: flowResult.amountSats,
512+ description: flowResult.description,
513+ );
514+ this .lnInvoiceInputs.value = inputs;
515+ }
516+
517+ Future <void > openEditLnOfferPage () async {
518+ final prevOffer = this .lnOfferInputs.value;
519+ final prev = AmountDescription (
520+ amountSats: prevOffer.amountSats,
521+ description: prevOffer.description,
522+ );
523+
524+ final AmountDescription ? flowResult = await Navigator .of (this .context).push (
525+ MaterialPageRoute (builder: (_) => ReceivePaymentEditPage (prev: prev)),
526+ );
527+
528+ if (! this .mounted || flowResult == null || flowResult == prev) return ;
529+
530+ // Clear LN offer code so it's clear we're fetching a new one.
531+ final lnOfferPaymentOffer = this .lnOfferPaymentOffer ();
532+ final lnOffer = lnOfferPaymentOffer.value;
533+ lnOfferPaymentOffer.value = PaymentOffer (
534+ kind: lnOffer.kind,
535+ code: null ,
536+ expiresAt: null ,
537+ amountSats: flowResult.amountSats,
538+ description: flowResult.description,
539+ );
540+
541+ // Update inputs to fetch new offer.
542+ final inputs = LnOfferInputs (
543+ amountSats: flowResult.amountSats,
544+ description: flowResult.description,
545+ );
546+ this .lnOfferInputs.value = inputs;
509547 }
510548
511549 @override
@@ -1283,20 +1321,18 @@ class CopyCodeButtonOrPlaceholder extends StatelessWidget {
12831321// }
12841322// }
12851323
1286- /// A page for the user to set a desired amount and optional description on
1287- /// their payment offer .
1288- class ReceivePaymentEditInvoicePage extends StatefulWidget {
1289- const ReceivePaymentEditInvoicePage ({super .key, required this .prev});
1324+ /// A page for the user to set an optional amount and/or optional description on
1325+ /// their inbound payment details .
1326+ class ReceivePaymentEditPage extends StatefulWidget {
1327+ const ReceivePaymentEditPage ({super .key, required this .prev});
12901328
1291- final LnInvoiceInputs prev;
1329+ final AmountDescription prev;
12921330
12931331 @override
1294- State <ReceivePaymentEditInvoicePage > createState () =>
1295- _ReceivePaymentEditInvoicePageState ();
1332+ State <ReceivePaymentEditPage > createState () => _ReceivePaymentEditPageState ();
12961333}
12971334
1298- class _ReceivePaymentEditInvoicePageState
1299- extends State <ReceivePaymentEditInvoicePage > {
1335+ class _ReceivePaymentEditPageState extends State <ReceivePaymentEditPage > {
13001336 final GlobalKey <FormFieldState <String >> amountFieldKey = GlobalKey ();
13011337 final GlobalKey <FormFieldState <String >> descriptionFieldKey = GlobalKey ();
13021338
@@ -1331,7 +1367,7 @@ class _ReceivePaymentEditInvoicePageState
13311367 description = null ;
13321368 }
13331369
1334- final flowResult = LnInvoiceInputs (
1370+ final flowResult = AmountDescription (
13351371 amountSats: amountSats,
13361372 description: description,
13371373 );
0 commit comments