From 7d18e763a1bc83ab6f9aae5c1a5d1912ecde482d Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 30 Aug 2022 17:06:54 -0600 Subject: [PATCH] show activity while checking balance+fee for a wallet initiated exchange --- .../wallet_initiated_exchange_view.dart | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/pages/exchange_view/wallet_initiated_exchange_view.dart b/lib/pages/exchange_view/wallet_initiated_exchange_view.dart index 564a8b6e2..b76a7022c 100644 --- a/lib/pages/exchange_view/wallet_initiated_exchange_view.dart +++ b/lib/pages/exchange_view/wallet_initiated_exchange_view.dart @@ -31,6 +31,7 @@ import 'package:stackwallet/utilities/enums/flush_bar_type.dart'; import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import 'package:stackwallet/widgets/custom_loading_overlay.dart'; import 'package:stackwallet/widgets/loading_indicator.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:tuple/tuple.dart'; @@ -1185,6 +1186,24 @@ class _WalletInitiatedExchangeViewState if (ft.toLowerCase() == coin.ticker.toLowerCase()) { + bool shouldPop = false; + bool wasPopped = false; + unawaited(showDialog( + context: context, + builder: (_) => WillPopScope( + onWillPop: () async { + if (shouldPop) { + wasPopped = true; + } + return shouldPop; + }, + child: const CustomLoadingOverlay( + message: "Checking available balance", + eventBus: null, + ), + ), + )); + final availableBalance = await manager.availableBalance; @@ -1194,6 +1213,12 @@ class _WalletInitiatedExchangeViewState Format.decimalAmountToSatoshis( sendAmount), feeObject.medium); + + shouldPop = true; + if (!wasPopped && mounted) { + Navigator.of(context).pop(); + } + if (availableBalance < sendAmount + Format.satoshisToAmount(fee)) {