extra debugging for pressing swap from within a wallet

This commit is contained in:
julian 2023-03-27 11:29:18 -06:00
parent 1aec70dd69
commit 453558d5ef
2 changed files with 52 additions and 5 deletions

View file

@ -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<WalletView> {
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<void>(
context: context,
@ -273,6 +269,15 @@ class _WalletViewState extends ConsumerState<WalletView> {
),
);
} 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(

View file

@ -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<T> showLoading<T>({
required Future<T> whileFuture,
required BuildContext context,
required String message,
String? subMessage,
bool isDesktop = false,
}) async {
unawaited(
showDialog<void>(
context: context,
barrierDismissible: false,
builder: (_) => WillPopScope(
onWillPop: () async => false,
child: Container(
color: Theme.of(context)
.extension<StackColors>()!
.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;
}