Skip to content

Commit

Permalink
feat: Return to trade screen when order has been created
Browse files Browse the repository at this point in the history
  • Loading branch information
holzeis committed May 28, 2024
1 parent a4f12f7 commit f207d87
Showing 1 changed file with 25 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class _ChannelFunding extends State<ChannelFunding> {

@override
Widget build(BuildContext context) {
final status = context.watch<FundingChannelChangeNotifier>().status;
final orderCreated = status == FundingChannelTaskStatus.orderCreated;

final qrCode = switch (selectedBox) {
FundingType.lightning => CustomQrCode(
data: widget.funding.paymentRequest,
Expand Down Expand Up @@ -119,7 +122,13 @@ class _ChannelFunding extends State<ChannelFunding> {
.read<SubmitOrderChangeNotifier>()
.orderService
.abortUnfundedChannelOpeningMarketOrder()
.then((value) => GoRouter.of(context).pop());
.then((value) {
if (orderCreated) {
GoRouter.of(context).go(TradeScreen.route);
} else {
GoRouter.of(context).pop();
}
});
},
),
const Row(
Expand Down Expand Up @@ -218,36 +227,23 @@ class _ChannelFunding extends State<ChannelFunding> {
],
),
// information text about the tx status
Expanded(
child: Selector<FundingChannelChangeNotifier, FundingChannelTaskStatus?>(
selector: (_, provider) {
return provider.status;
}, builder: (BuildContext context, value, Widget? child) {
return buildInfoBox(value, selectedBox);
})),
Expanded(child: buildInfoBox(status, selectedBox)),
Padding(
padding: const EdgeInsets.only(top: 1, left: 8, right: 8, bottom: 8),
child: Selector<FundingChannelChangeNotifier, FundingChannelTaskStatus?>(
selector: (_, provider) {
return provider.status;
}, builder: (BuildContext context, value, Widget? child) {
if (value case FundingChannelTaskStatus.orderCreated) {
return ElevatedButton(
onPressed: () {
GoRouter.of(context).go(TradeScreen.route);
},
style: ElevatedButton.styleFrom(
minimumSize: const Size.fromHeight(50),
backgroundColor: tenTenOnePurple),
child: const Text(
"Home",
style: TextStyle(color: Colors.white),
),
);
} else {
return buildButtonRow();
}
})),
child: orderCreated
? ElevatedButton(
onPressed: () {
GoRouter.of(context).go(TradeScreen.route);
},
style: ElevatedButton.styleFrom(
minimumSize: const Size.fromHeight(50),
backgroundColor: tenTenOnePurple),
child: const Text(
"Home",
style: TextStyle(color: Colors.white),
),
)
: buildButtonRow()),
],
),
),
Expand Down

0 comments on commit f207d87

Please sign in to comment.