mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
fix: bottom sheet stuck on swap (#2211)
This commit is contained in:
parent
77980496a8
commit
b2d4698cdf
2 changed files with 17 additions and 1 deletions
|
@ -7,6 +7,7 @@ class TradeState extends EnumerableItem<String> with Serializable<String> {
|
|||
bool operator ==(Object other) => other is TradeState && other.raw == raw;
|
||||
|
||||
static const pending = TradeState(raw: 'pending', title: 'Pending');
|
||||
static const awaiting = TradeState(raw: 'awaiting', title: 'Awaiting');
|
||||
static const confirming = TradeState(raw: 'confirming', title: 'Confirming');
|
||||
static const trading = TradeState(raw: 'trading', title: 'Trading');
|
||||
static const traded = TradeState(raw: 'traded', title: 'Traded');
|
||||
|
@ -134,6 +135,8 @@ class TradeState extends EnumerableItem<String> with Serializable<String> {
|
|||
return success;
|
||||
case 'expired':
|
||||
return expired;
|
||||
case 'awaiting':
|
||||
return awaiting;
|
||||
default:
|
||||
throw Exception('Unexpected token: $raw in TradeState deserialize');
|
||||
}
|
||||
|
|
|
@ -205,6 +205,7 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
|||
);
|
||||
}
|
||||
|
||||
BuildContext? dialogContext;
|
||||
BuildContext? loadingBottomSheetContext;
|
||||
|
||||
void _setEffects() {
|
||||
|
@ -213,7 +214,12 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
|||
}
|
||||
|
||||
_exchangeStateReaction = reaction((_) => this.widget.exchangeTradeViewModel.sendViewModel.state,
|
||||
(ExecutionState state) {
|
||||
(ExecutionState state) async {
|
||||
|
||||
if (dialogContext != null && dialogContext?.mounted == true) {
|
||||
Navigator.of(dialogContext!).pop();
|
||||
}
|
||||
|
||||
if (state is! IsExecutingState &&
|
||||
loadingBottomSheetContext != null &&
|
||||
loadingBottomSheetContext!.mounted) {
|
||||
|
@ -237,6 +243,13 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
|||
}
|
||||
|
||||
if (state is IsExecutingState) {
|
||||
// wait a bit to avoid showing the loading dialog if transaction is failed
|
||||
await Future.delayed(const Duration(milliseconds: 300));
|
||||
final currentState = widget.exchangeTradeViewModel.sendViewModel.state;
|
||||
if (currentState is ExecutedSuccessfullyState || currentState is FailureState) {
|
||||
return;
|
||||
}
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (context.mounted) {
|
||||
showModalBottomSheet<void>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue