From 6094a767d743f28f35461f6f5ac6173aadee1568 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 27 Jan 2023 14:10:23 -0600 Subject: [PATCH] desktop rescanning navigation fix --- .../sub_widgets/rescanning_dialog.dart | 67 ++++++++++++------- .../wallet_network_settings_view.dart | 12 ++-- 2 files changed, 48 insertions(+), 31 deletions(-) diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/rescanning_dialog.dart b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/rescanning_dialog.dart index da39b1017..0435d023b 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/rescanning_dialog.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/rescanning_dialog.dart @@ -2,6 +2,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/conditional_parent.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; class RescanningDialog extends StatefulWidget { @@ -21,9 +24,12 @@ class _RescanningDialogState extends State late AnimationController? _spinController; late Animation _spinAnimation; + late final bool isDesktop; + // late final VoidCallback onCancel; @override void initState() { + isDesktop = Util.isDesktop; // onCancel = widget.onCancel; _spinController = AnimationController( @@ -53,33 +59,42 @@ class _RescanningDialogState extends State onWillPop: () async { return false; }, - child: StackDialog( - title: "Rescanning blockchain", - message: "This may take a while. Please do not exit this screen.", - icon: RotationTransition( - turns: _spinAnimation, - child: SvgPicture.asset( - Assets.svg.arrowRotate3, - width: 24, - height: 24, - color: Theme.of(context).extension()!.accentColorDark, - ), + child: ConditionalParent( + condition: isDesktop, + builder: (child) => DesktopDialog( + maxHeight: 200, + maxWidth: 500, + child: child, + ), + child: StackDialog( + title: "Rescanning blockchain", + message: "This may take a while. Please do not exit this screen.", + icon: RotationTransition( + turns: _spinAnimation, + child: SvgPicture.asset( + Assets.svg.arrowRotate3, + width: 24, + height: 24, + color: + Theme.of(context).extension()!.accentColorDark, + ), + ), + // rightButton: TextButton( + // style: Theme.of(context).textButtonTheme.style?.copyWith( + // backgroundColor: MaterialStateProperty.all( + // CFColors.buttonGray, + // ), + // ), + // child: Text( + // "Cancel", + // style: STextStyles.itemSubtitle12(context), + // ), + // onPressed: () { + // Navigator.of(context).pop(); + // onCancel.call(); + // }, + // ), ), - // rightButton: TextButton( - // style: Theme.of(context).textButtonTheme.style?.copyWith( - // backgroundColor: MaterialStateProperty.all( - // CFColors.buttonGray, - // ), - // ), - // child: Text( - // "Cancel", - // style: STextStyles.itemSubtitle12(context), - // ), - // onPressed: () { - // Navigator.of(context).pop(); - // onCancel.call(); - // }, - // ), ), ); } diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart index cc552279c..21e0f2d49 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart @@ -76,6 +76,8 @@ class _WalletNetworkSettingsViewState StreamSubscription? _blocksRemainingSubscription; // late StreamSubscription _nodeStatusSubscription; + late final bool isDesktop; + late double _percent; late int _blocksRemaining; bool _advancedIsExpanded = false; @@ -114,7 +116,7 @@ class _WalletNetworkSettingsViewState if (mounted) { // pop rescanning dialog - Navigator.pop(context); + Navigator.of(context, rootNavigator: isDesktop).pop(); // show success await showDialog( @@ -132,7 +134,7 @@ class _WalletNetworkSettingsViewState style: STextStyles.itemSubtitle12(context), ), onPressed: () { - Navigator.of(context).pop(); + Navigator.of(context, rootNavigator: isDesktop).pop(); }, ), ), @@ -143,7 +145,7 @@ class _WalletNetworkSettingsViewState if (mounted) { // pop rescanning dialog - Navigator.pop(context); + Navigator.of(context, rootNavigator: isDesktop).pop(); // show error await showDialog( @@ -162,7 +164,7 @@ class _WalletNetworkSettingsViewState style: STextStyles.itemSubtitle12(context), ), onPressed: () { - Navigator.of(context).pop(); + Navigator.of(context, rootNavigator: isDesktop).pop(); }, ), ), @@ -183,6 +185,7 @@ class _WalletNetworkSettingsViewState @override void initState() { + isDesktop = Util.isDesktop; _currentSyncStatus = widget.initialSyncStatus; // _currentNodeStatus = widget.initialNodeStatus; if (_currentSyncStatus == WalletSyncStatus.synced) { @@ -270,7 +273,6 @@ class _WalletNetworkSettingsViewState @override Widget build(BuildContext context) { final screenWidth = MediaQuery.of(context).size.width; - final bool isDesktop = Util.isDesktop; final progressLength = isDesktop ? 430.0