Skip to content

Commit

Permalink
Merge pull request #2571 from get10101/feat/return-to-trade-screen-wh…
Browse files Browse the repository at this point in the history
…en-order-has-been-created

feat: Return to trade screen when order has been created
  • Loading branch information
holzeis authored May 28, 2024
2 parents a4f12f7 + f207d87 commit 1b37506
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 1b37506

Please sign in to comment.