From 9186be7fb644cf9516388263df503fb12f1d544c Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 2 Nov 2022 17:29:26 -0600 Subject: [PATCH] WIP: desktop dialog transitions --- .../wallet_network_settings_view.dart | 21 ++- .../sub_widgets/network_info_button.dart | 126 +++++++++++++----- .../unlock_wallet_keys_desktop.dart | 59 +++++--- .../sub_widgets/wallet_keys_button.dart | 24 +++- lib/route_generator.dart | 89 +++++++++++-- 5 files changed, 248 insertions(+), 71 deletions(-) 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 322d67d74..accf244eb 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 @@ -10,6 +10,7 @@ import 'package:stackwallet/pages/settings_views/sub_widgets/nodes_list.dart'; import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/confirm_full_rescan.dart'; import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/rescanning_dialog.dart'; import 'package:stackwallet/providers/providers.dart'; +import 'package:stackwallet/route_generator.dart'; import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart'; import 'package:stackwallet/services/coins/monero/monero_wallet.dart'; import 'package:stackwallet/services/coins/wownero/wownero_wallet.dart'; @@ -875,14 +876,22 @@ class _WalletNetworkSettingsViewState child: BlueTextButton( text: "Rescan", onTap: () async { - await showDialog( - context: context, - builder: (context) { - return ConfirmFullRescanDialog( + await Navigator.of(context).push( + FadePageRoute( + ConfirmFullRescanDialog( onConfirm: _attemptRescan, - ); - }, + ), + const RouteSettings(), + ), ); + // await showDialog( + // context: context, + // builder: (context) { + // return ConfirmFullRescanDialog( + // onConfirm: _attemptRescan, + // ); + // }, + // ); }, ), ), diff --git a/lib/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/network_info_button.dart b/lib/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/network_info_button.dart index 5dc8c4723..c001f9bf3 100644 --- a/lib/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/network_info_button.dart +++ b/lib/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/network_info_button.dart @@ -6,6 +6,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart'; import 'package:stackwallet/providers/providers.dart'; +import 'package:stackwallet/route_generator.dart'; import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; import 'package:stackwallet/services/event_bus/global_event_bus.dart'; @@ -154,44 +155,103 @@ class _NetworkInfoButtonState extends ConsumerState { return GestureDetector( onTap: () { if (Util.isDesktop) { + // showDialog( + // context: context, + // builder: (context) => DesktopDialog( + // maxHeight: MediaQuery.of(context).size.height - 64, + // maxWidth: 580, + // child: Column( + // mainAxisSize: MainAxisSize.min, + // children: [ + // Padding( + // padding: const EdgeInsets.only( + // left: 32, + // ), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // "Network", + // style: STextStyles.desktopH3(context), + // ), + // const DesktopDialogCloseButton(), + // ], + // ), + // ), + // Padding( + // padding: const EdgeInsets.only( + // top: 16, + // left: 32, + // right: 32, + // bottom: 32, + // ), + // child: WalletNetworkSettingsView( + // walletId: walletId, + // initialSyncStatus: _currentSyncStatus, + // initialNodeStatus: _currentNodeStatus, + // ), + // ), + // ], + // ), + // ), + // ); + showDialog( context: context, - builder: (context) => DesktopDialog( - maxHeight: MediaQuery.of(context).size.height - 64, - maxWidth: 580, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: const EdgeInsets.only( - left: 32, + builder: (context) => Navigator( + initialRoute: WalletNetworkSettingsView.routeName, + onGenerateRoute: RouteGenerator.generateRoute, + onGenerateInitialRoutes: (_, __) { + return [ + FadePageRoute( + DesktopDialog( + maxHeight: MediaQuery.of(context).size.height - 64, + maxWidth: 580, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: const EdgeInsets.only( + left: 32, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Network", + style: STextStyles.desktopH3(context), + ), + DesktopDialogCloseButton( + onPressedOverride: Navigator.of( + context, + rootNavigator: true, + ).pop, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.only( + top: 16, + left: 32, + right: 32, + bottom: 32, + ), + child: WalletNetworkSettingsView( + walletId: walletId, + initialSyncStatus: _currentSyncStatus, + initialNodeStatus: _currentNodeStatus, + ), + ), + ], + ), ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Network", - style: STextStyles.desktopH3(context), - ), - const DesktopDialogCloseButton(), - ], + const RouteSettings( + name: WalletNetworkSettingsView.routeName, ), ), - Padding( - padding: const EdgeInsets.only( - top: 16, - left: 32, - right: 32, - bottom: 32, - ), - child: WalletNetworkSettingsView( - walletId: walletId, - initialSyncStatus: _currentSyncStatus, - initialNodeStatus: _currentNodeStatus, - ), - ), - ], - ), + ]; + }, ), ); } else { diff --git a/lib/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart b/lib/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart index 37f047eed..e65820737 100644 --- a/lib/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart +++ b/lib/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart @@ -3,7 +3,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/wallet_keys_desktop_popup.dart'; import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/route_generator.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -22,6 +21,8 @@ class UnlockWalletKeysDesktop extends ConsumerStatefulWidget { final String walletId; + static const String routeName = "/desktopUnlockWalletKeys"; + @override ConsumerState createState() => _UnlockWalletKeysDesktopState(); @@ -59,8 +60,13 @@ class _UnlockWalletKeysDesktopState children: [ Row( mainAxisAlignment: MainAxisAlignment.end, - children: const [ - DesktopDialogCloseButton(), + children: [ + DesktopDialogCloseButton( + onPressedOverride: Navigator.of( + context, + rootNavigator: true, + ).pop, + ), ], ), const SizedBox( @@ -175,7 +181,10 @@ class _UnlockWalletKeysDesktopState Expanded( child: SecondaryButton( label: "Cancel", - onPressed: Navigator.of(context).pop, + onPressed: Navigator.of( + context, + rootNavigator: true, + ).pop, ), ), const SizedBox( @@ -188,29 +197,35 @@ class _UnlockWalletKeysDesktopState onPressed: continueEnabled ? () async { // todo: check password - Navigator.of(context).pop(); + // Navigator.of(context).pop(); final words = await ref .read(walletsChangeNotifierProvider) .getManager(widget.walletId) .mnemonic; - await showDialog( - context: context, - barrierDismissible: false, - builder: (context) => Navigator( - initialRoute: WalletKeysDesktopPopup.routeName, - onGenerateRoute: RouteGenerator.generateRoute, - onGenerateInitialRoutes: (_, __) { - return [ - RouteGenerator.generateRoute( - RouteSettings( - name: WalletKeysDesktopPopup.routeName, - arguments: words, - ), - ) - ]; - }, - ), + + await Navigator.of(context).pushReplacementNamed( + WalletKeysDesktopPopup.routeName, + arguments: words, ); + // + // await showDialog( + // context: context, + // barrierDismissible: false, + // builder: (context) => Navigator( + // initialRoute: WalletKeysDesktopPopup.routeName, + // onGenerateRoute: RouteGenerator.generateRoute, + // onGenerateInitialRoutes: (_, __) { + // return [ + // RouteGenerator.generateRoute( + // RouteSettings( + // name: WalletKeysDesktopPopup.routeName, + // arguments: words, + // ), + // ) + // ]; + // }, + // ), + // ); } : null, ), diff --git a/lib/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/wallet_keys_button.dart b/lib/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/wallet_keys_button.dart index d4921276d..649433d52 100644 --- a/lib/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/wallet_keys_button.dart +++ b/lib/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/wallet_keys_button.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart'; +import 'package:stackwallet/route_generator.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; @@ -20,10 +21,29 @@ class WalletKeysButton extends StatelessWidget { showDialog( context: context, barrierDismissible: false, - builder: (context) => UnlockWalletKeysDesktop( - walletId: walletId, + builder: (context) => Navigator( + initialRoute: UnlockWalletKeysDesktop.routeName, + onGenerateRoute: RouteGenerator.generateRoute, + onGenerateInitialRoutes: (_, __) { + return [ + RouteGenerator.generateRoute( + RouteSettings( + name: UnlockWalletKeysDesktop.routeName, + arguments: walletId, + ), + ) + ]; + }, ), ); + + // showDialog( + // context: context, + // barrierDismissible: false, + // builder: (context) => UnlockWalletKeysDesktop( + // walletId: walletId, + // ), + // ); }, child: Container( color: Colors.transparent, diff --git a/lib/route_generator.dart b/lib/route_generator.dart index d5a38c0fd..a6f23ffdc 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -106,6 +106,7 @@ import 'package:stackwallet/utilities/enums/add_wallet_type_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:tuple/tuple.dart'; +import 'pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart'; import 'pages_desktop_specific/home/settings_menu/language_settings/language_settings.dart'; class RouteGenerator { @@ -1085,29 +1086,67 @@ class RouteGenerator { case WalletKeysDesktopPopup.routeName: if (args is List) { - return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => WalletKeysDesktopPopup( + return FadePageRoute( + WalletKeysDesktopPopup( words: args, ), - settings: RouteSettings( + RouteSettings( name: settings.name, ), ); + // return getRoute( + // shouldUseMaterialRoute: useMaterialPageRoute, + // builder: (_) => WalletKeysDesktopPopup( + // words: args, + // ), + // settings: RouteSettings( + // name: settings.name, + // ), + // ); + } + return _routeError("${settings.name} invalid args: ${args.toString()}"); + + case UnlockWalletKeysDesktop.routeName: + if (args is String) { + return FadePageRoute( + UnlockWalletKeysDesktop( + walletId: args, + ), + RouteSettings( + name: settings.name, + ), + ); + // return getRoute( + // shouldUseMaterialRoute: useMaterialPageRoute, + // builder: (_) => WalletKeysDesktopPopup( + // words: args, + // ), + // settings: RouteSettings( + // name: settings.name, + // ), + // ); } return _routeError("${settings.name} invalid args: ${args.toString()}"); case QRCodeDesktopPopupContent.routeName: if (args is String) { - return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => QRCodeDesktopPopupContent( + return FadePageRoute( + QRCodeDesktopPopupContent( value: args, ), - settings: RouteSettings( + RouteSettings( name: settings.name, ), ); + // return getRoute( + // shouldUseMaterialRoute: useMaterialPageRoute, + // builder: (_) => QRCodeDesktopPopupContent( + // value: args, + // ), + // settings: RouteSettings( + // name: settings.name, + // ), + // ); } return _routeError("${settings.name} invalid args: ${args.toString()}"); @@ -1181,3 +1220,37 @@ class RouteGenerator { builder: (_) => errorView); } } + +class FadePageRoute extends PageRoute { + FadePageRoute(this.child, RouteSettings settings) : _settings = settings; + + final Widget child; + final RouteSettings _settings; + + @override + Color? get barrierColor => null; + + @override + String? get barrierLabel => null; + + @override + Widget buildPage( + BuildContext context, + Animation animation, + Animation secondaryAnimation, + ) { + return FadeTransition( + opacity: animation, + child: child, + ); + } + + @override + bool get maintainState => true; + + @override + Duration get transitionDuration => const Duration(milliseconds: 100); + + @override + RouteSettings get settings => _settings; +}