mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-23 03:05:11 +00:00
Fix popup null context as it was using a dismissed (unmounted) context [skip ci]
This commit is contained in:
parent
50641e2ddc
commit
fa54ebe855
2 changed files with 126 additions and 125 deletions
|
@ -112,7 +112,7 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
||||||
width: 16,
|
width: 16,
|
||||||
color: Theme.of(context).primaryTextTheme!.overline!.color!);
|
color: Theme.of(context).primaryTextTheme!.overline!.color!);
|
||||||
|
|
||||||
_setEffects(context);
|
_setEffects();
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
child: ScrollableWithBottomSection(
|
child: ScrollableWithBottomSection(
|
||||||
|
@ -234,7 +234,7 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setEffects(BuildContext context) {
|
void _setEffects() {
|
||||||
if (_effectsInstalled) {
|
if (_effectsInstalled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -245,12 +245,12 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
showPopUp<void>(
|
showPopUp<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext popupContext) {
|
||||||
return AlertWithOneAction(
|
return AlertWithOneAction(
|
||||||
alertTitle: S.of(context).error,
|
alertTitle: S.of(popupContext).error,
|
||||||
alertContent: state.error,
|
alertContent: state.error,
|
||||||
buttonText: S.of(context).ok,
|
buttonText: S.of(popupContext).ok,
|
||||||
buttonAction: () => Navigator.of(context).pop());
|
buttonAction: () => Navigator.of(popupContext).pop());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -259,118 +259,24 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
showPopUp<void>(
|
showPopUp<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext popupContext) {
|
||||||
return ConfirmSendingAlert(
|
return ConfirmSendingAlert(
|
||||||
alertTitle: S.of(context).confirm_sending,
|
alertTitle: S.of(popupContext).confirm_sending,
|
||||||
amount: S.of(context).send_amount,
|
amount: S.of(popupContext).send_amount,
|
||||||
amountValue: widget.exchangeTradeViewModel.sendViewModel
|
amountValue: widget.exchangeTradeViewModel.sendViewModel
|
||||||
.pendingTransaction!.amountFormatted,
|
.pendingTransaction!.amountFormatted,
|
||||||
fee: S.of(context).send_fee,
|
fee: S.of(popupContext).send_fee,
|
||||||
feeValue: widget.exchangeTradeViewModel.sendViewModel
|
feeValue: widget.exchangeTradeViewModel.sendViewModel
|
||||||
.pendingTransaction!.feeFormatted,
|
.pendingTransaction!.feeFormatted,
|
||||||
rightButtonText: S.of(context).ok,
|
rightButtonText: S.of(popupContext).ok,
|
||||||
leftButtonText: S.of(context).cancel,
|
leftButtonText: S.of(popupContext).cancel,
|
||||||
actionRightButton: () async {
|
actionRightButton: () async {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(popupContext).pop();
|
||||||
await widget.exchangeTradeViewModel.sendViewModel
|
await widget.exchangeTradeViewModel.sendViewModel
|
||||||
.commitTransaction();
|
.commitTransaction();
|
||||||
await showPopUp<void>(
|
transactionStatePopup();
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return Observer(builder: (_) {
|
|
||||||
final state = widget
|
|
||||||
.exchangeTradeViewModel.sendViewModel.state;
|
|
||||||
|
|
||||||
if (state is TransactionCommitted) {
|
|
||||||
return Stack(
|
|
||||||
children: <Widget>[
|
|
||||||
Container(
|
|
||||||
color: Theme.of(context).backgroundColor,
|
|
||||||
child: Center(
|
|
||||||
child: Image.asset(
|
|
||||||
'assets/images/birthday_cake.png'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
top: 220, left: 24, right: 24),
|
|
||||||
child: Text(
|
|
||||||
S.of(context).send_success(widget
|
|
||||||
.exchangeTradeViewModel
|
|
||||||
.wallet
|
|
||||||
.currency
|
|
||||||
.toString()),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 22,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Theme.of(context)
|
|
||||||
.primaryTextTheme!
|
|
||||||
.headline6!
|
|
||||||
.color,
|
|
||||||
decoration: TextDecoration.none,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
left: 24,
|
|
||||||
right: 24,
|
|
||||||
bottom: 24,
|
|
||||||
child: PrimaryButton(
|
|
||||||
onPressed: () =>
|
|
||||||
Navigator.of(context).pop(),
|
|
||||||
text: S.of(context).send_got_it,
|
|
||||||
color: Theme.of(context)
|
|
||||||
.accentTextTheme!
|
|
||||||
.bodyText1!
|
|
||||||
.color!,
|
|
||||||
textColor: Colors.white))
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Stack(
|
|
||||||
children: <Widget>[
|
|
||||||
Container(
|
|
||||||
color: Theme.of(context).backgroundColor,
|
|
||||||
child: Center(
|
|
||||||
child: Image.asset(
|
|
||||||
'assets/images/birthday_cake.png'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
BackdropFilter(
|
|
||||||
filter: ImageFilter.blur(
|
|
||||||
sigmaX: 3.0, sigmaY: 3.0),
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.backgroundColor
|
|
||||||
.withOpacity(0.25)),
|
|
||||||
child: Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.only(top: 220),
|
|
||||||
child: Text(
|
|
||||||
S.of(context).send_sending,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 22,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Theme.of(context).primaryTextTheme!.headline6!.color!,
|
|
||||||
decoration: TextDecoration.none,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
actionLeftButton: () => Navigator.of(context).pop(),
|
actionLeftButton: () => Navigator.of(popupContext).pop(),
|
||||||
feeFiatAmount: widget.exchangeTradeViewModel
|
feeFiatAmount: widget.exchangeTradeViewModel
|
||||||
.pendingTransactionFeeFiatAmountFormatted,
|
.pendingTransactionFeeFiatAmountFormatted,
|
||||||
fiatAmountValue: widget.exchangeTradeViewModel
|
fiatAmountValue: widget.exchangeTradeViewModel
|
||||||
|
@ -385,12 +291,12 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
showPopUp<void>(
|
showPopUp<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext popupContext) {
|
||||||
return AlertWithOneAction(
|
return AlertWithOneAction(
|
||||||
alertTitle: S.of(context).sending,
|
alertTitle: S.of(popupContext).sending,
|
||||||
alertContent: S.of(context).transaction_sent,
|
alertContent: S.of(popupContext).transaction_sent,
|
||||||
buttonText: S.of(context).ok,
|
buttonText: S.of(popupContext).ok,
|
||||||
buttonAction: () => Navigator.of(context).pop());
|
buttonAction: () => Navigator.of(popupContext).pop());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -398,4 +304,102 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
||||||
|
|
||||||
_effectsInstalled = true;
|
_effectsInstalled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transactionStatePopup() {
|
||||||
|
showPopUp<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext popupContext) {
|
||||||
|
return Observer(builder: (_) {
|
||||||
|
final state = widget
|
||||||
|
.exchangeTradeViewModel.sendViewModel.state;
|
||||||
|
|
||||||
|
if (state is TransactionCommitted) {
|
||||||
|
return Stack(
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
color: Theme.of(popupContext).backgroundColor,
|
||||||
|
child: Center(
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/birthday_cake.png'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
top: 220, left: 24, right: 24),
|
||||||
|
child: Text(
|
||||||
|
S.of(popupContext).send_success(widget
|
||||||
|
.exchangeTradeViewModel
|
||||||
|
.wallet
|
||||||
|
.currency
|
||||||
|
.toString()),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 22,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Theme.of(popupContext)
|
||||||
|
.primaryTextTheme!
|
||||||
|
.headline6!
|
||||||
|
.color,
|
||||||
|
decoration: TextDecoration.none,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
left: 24,
|
||||||
|
right: 24,
|
||||||
|
bottom: 24,
|
||||||
|
child: PrimaryButton(
|
||||||
|
onPressed: () =>
|
||||||
|
Navigator.of(popupContext).pop(),
|
||||||
|
text: S.of(popupContext).send_got_it,
|
||||||
|
color: Theme.of(popupContext)
|
||||||
|
.accentTextTheme!
|
||||||
|
.bodyText1!
|
||||||
|
.color!,
|
||||||
|
textColor: Colors.white))
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Stack(
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
color: Theme.of(popupContext).backgroundColor,
|
||||||
|
child: Center(
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/birthday_cake.png'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
BackdropFilter(
|
||||||
|
filter: ImageFilter.blur(
|
||||||
|
sigmaX: 3.0, sigmaY: 3.0),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(popupContext)
|
||||||
|
.backgroundColor
|
||||||
|
.withOpacity(0.25)),
|
||||||
|
child: Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.only(top: 220),
|
||||||
|
child: Text(
|
||||||
|
S.of(popupContext).send_sending,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 22,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Theme.of(popupContext).primaryTextTheme!.headline6!.color!,
|
||||||
|
decoration: TextDecoration.none,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ Future<T?> showPopUp<T>({
|
||||||
bool useRootNavigator = true,
|
bool useRootNavigator = true,
|
||||||
RouteSettings? routeSettings
|
RouteSettings? routeSettings
|
||||||
}) async {
|
}) async {
|
||||||
if (context.mounted) {
|
|
||||||
return showDialog<T>(
|
return showDialog<T>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: builder,
|
builder: builder,
|
||||||
|
@ -19,5 +18,3 @@ Future<T?> showPopUp<T>({
|
||||||
useRootNavigator: useRootNavigator,
|
useRootNavigator: useRootNavigator,
|
||||||
routeSettings: routeSettings);
|
routeSettings: routeSettings);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue