From 1aec70dd69f29326967d836f95bb553027e3369a Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 27 Mar 2023 11:28:18 -0600 Subject: [PATCH 1/2] swap send from stack bugfix --- lib/pages/exchange_view/exchange_step_views/step_4_view.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/exchange_view/exchange_step_views/step_4_view.dart b/lib/pages/exchange_view/exchange_step_views/step_4_view.dart index 30d40f008..16eb3923f 100644 --- a/lib/pages/exchange_view/exchange_step_views/step_4_view.dart +++ b/lib/pages/exchange_view/exchange_step_views/step_4_view.dart @@ -579,7 +579,7 @@ class _Step4ViewState extends ConsumerState { time, ]); - final txData = results.last + final txData = results.first as Map; if (!wasCancelled) { From 453558d5ef3abffbd7b404c4a6ebd32775c9ea33 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 27 Mar 2023 11:29:18 -0600 Subject: [PATCH 2/2] extra debugging for pressing swap from within a wallet --- lib/pages/wallet_view/wallet_view.dart | 15 ++++++--- lib/utilities/show_loading.dart | 42 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 lib/utilities/show_loading.dart diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index eaea818e9..8d12df5a6 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -44,6 +44,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart'; import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/show_loading.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/background.dart'; @@ -260,11 +261,6 @@ class _WalletViewState extends ConsumerState { void _onExchangePressed(BuildContext context) async { final coin = ref.read(managerProvider).coin; - final currency = ExchangeDataLoadingService.instance.isar.currencies - .where() - .tickerEqualToAnyExchangeNameName(coin.ticker) - .findFirstSync(); - if (coin.isTestNet) { await showDialog( context: context, @@ -273,6 +269,15 @@ class _WalletViewState extends ConsumerState { ), ); } else { + final currency = await showLoading( + whileFuture: ExchangeDataLoadingService.instance.isar.currencies + .where() + .tickerEqualToAnyExchangeNameName(coin.ticker) + .findFirst(), + context: context, + message: "Loading...", + ); + if (mounted) { unawaited( Navigator.of(context).pushNamed( diff --git a/lib/utilities/show_loading.dart b/lib/utilities/show_loading.dart new file mode 100644 index 000000000..9e48f7800 --- /dev/null +++ b/lib/utilities/show_loading.dart @@ -0,0 +1,42 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/widgets/custom_loading_overlay.dart'; + +Future showLoading({ + required Future whileFuture, + required BuildContext context, + required String message, + String? subMessage, + bool isDesktop = false, +}) async { + unawaited( + showDialog( + context: context, + barrierDismissible: false, + builder: (_) => WillPopScope( + onWillPop: () async => false, + child: Container( + color: Theme.of(context) + .extension()! + .overlay + .withOpacity(0.6), + child: CustomLoadingOverlay( + message: message, + subMessage: subMessage, + eventBus: null, + ), + ), + ), + ), + ); + + final result = await whileFuture; + + if (context.mounted) { + Navigator.of(context, rootNavigator: isDesktop).pop(); + } + + return result; +}