WIP: desktop dialog transitions

This commit is contained in:
julian 2022-11-02 17:29:26 -06:00
parent 75d9ca6912
commit 9186be7fb6
5 changed files with 248 additions and 71 deletions

View file

@ -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/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/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/rescanning_dialog.dart';
import 'package:stackwallet/providers/providers.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/epiccash/epiccash_wallet.dart';
import 'package:stackwallet/services/coins/monero/monero_wallet.dart'; import 'package:stackwallet/services/coins/monero/monero_wallet.dart';
import 'package:stackwallet/services/coins/wownero/wownero_wallet.dart'; import 'package:stackwallet/services/coins/wownero/wownero_wallet.dart';
@ -875,14 +876,22 @@ class _WalletNetworkSettingsViewState
child: BlueTextButton( child: BlueTextButton(
text: "Rescan", text: "Rescan",
onTap: () async { onTap: () async {
await showDialog<dynamic>( await Navigator.of(context).push(
context: context, FadePageRoute<void>(
builder: (context) { ConfirmFullRescanDialog(
return ConfirmFullRescanDialog(
onConfirm: _attemptRescan, onConfirm: _attemptRescan,
); ),
}, const RouteSettings(),
),
); );
// await showDialog<dynamic>(
// context: context,
// builder: (context) {
// return ConfirmFullRescanDialog(
// onConfirm: _attemptRescan,
// );
// },
// );
}, },
), ),
), ),

View file

@ -6,6 +6,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.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/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart';
import 'package:stackwallet/providers/providers.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/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/events/global/wallet_sync_status_changed_event.dart';
import 'package:stackwallet/services/event_bus/global_event_bus.dart'; import 'package:stackwallet/services/event_bus/global_event_bus.dart';
@ -154,44 +155,103 @@ class _NetworkInfoButtonState extends ConsumerState<NetworkInfoButton> {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
if (Util.isDesktop) { if (Util.isDesktop) {
// showDialog<void>(
// 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<void>( showDialog<void>(
context: context, context: context,
builder: (context) => DesktopDialog( builder: (context) => Navigator(
maxHeight: MediaQuery.of(context).size.height - 64, initialRoute: WalletNetworkSettingsView.routeName,
maxWidth: 580, onGenerateRoute: RouteGenerator.generateRoute,
child: Column( onGenerateInitialRoutes: (_, __) {
mainAxisSize: MainAxisSize.min, return [
children: [ FadePageRoute(
Padding( DesktopDialog(
padding: const EdgeInsets.only( maxHeight: MediaQuery.of(context).size.height - 64,
left: 32, 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( const RouteSettings(
mainAxisAlignment: MainAxisAlignment.spaceBetween, name: WalletNetworkSettingsView.routeName,
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,
),
),
],
),
), ),
); );
} else { } else {

View file

@ -3,7 +3,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.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/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/providers/providers.dart';
import 'package:stackwallet/route_generator.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
@ -22,6 +21,8 @@ class UnlockWalletKeysDesktop extends ConsumerStatefulWidget {
final String walletId; final String walletId;
static const String routeName = "/desktopUnlockWalletKeys";
@override @override
ConsumerState<UnlockWalletKeysDesktop> createState() => ConsumerState<UnlockWalletKeysDesktop> createState() =>
_UnlockWalletKeysDesktopState(); _UnlockWalletKeysDesktopState();
@ -59,8 +60,13 @@ class _UnlockWalletKeysDesktopState
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: const [ children: [
DesktopDialogCloseButton(), DesktopDialogCloseButton(
onPressedOverride: Navigator.of(
context,
rootNavigator: true,
).pop,
),
], ],
), ),
const SizedBox( const SizedBox(
@ -175,7 +181,10 @@ class _UnlockWalletKeysDesktopState
Expanded( Expanded(
child: SecondaryButton( child: SecondaryButton(
label: "Cancel", label: "Cancel",
onPressed: Navigator.of(context).pop, onPressed: Navigator.of(
context,
rootNavigator: true,
).pop,
), ),
), ),
const SizedBox( const SizedBox(
@ -188,29 +197,35 @@ class _UnlockWalletKeysDesktopState
onPressed: continueEnabled onPressed: continueEnabled
? () async { ? () async {
// todo: check password // todo: check password
Navigator.of(context).pop(); // Navigator.of(context).pop();
final words = await ref final words = await ref
.read(walletsChangeNotifierProvider) .read(walletsChangeNotifierProvider)
.getManager(widget.walletId) .getManager(widget.walletId)
.mnemonic; .mnemonic;
await showDialog<void>(
context: context, await Navigator.of(context).pushReplacementNamed(
barrierDismissible: false, WalletKeysDesktopPopup.routeName,
builder: (context) => Navigator( arguments: words,
initialRoute: WalletKeysDesktopPopup.routeName,
onGenerateRoute: RouteGenerator.generateRoute,
onGenerateInitialRoutes: (_, __) {
return [
RouteGenerator.generateRoute(
RouteSettings(
name: WalletKeysDesktopPopup.routeName,
arguments: words,
),
)
];
},
),
); );
//
// await showDialog<void>(
// context: context,
// barrierDismissible: false,
// builder: (context) => Navigator(
// initialRoute: WalletKeysDesktopPopup.routeName,
// onGenerateRoute: RouteGenerator.generateRoute,
// onGenerateInitialRoutes: (_, __) {
// return [
// RouteGenerator.generateRoute(
// RouteSettings(
// name: WalletKeysDesktopPopup.routeName,
// arguments: words,
// ),
// )
// ];
// },
// ),
// );
} }
: null, : null,
), ),

View file

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.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/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/assets.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart';
@ -20,10 +21,29 @@ class WalletKeysButton extends StatelessWidget {
showDialog<void>( showDialog<void>(
context: context, context: context,
barrierDismissible: false, barrierDismissible: false,
builder: (context) => UnlockWalletKeysDesktop( builder: (context) => Navigator(
walletId: walletId, initialRoute: UnlockWalletKeysDesktop.routeName,
onGenerateRoute: RouteGenerator.generateRoute,
onGenerateInitialRoutes: (_, __) {
return [
RouteGenerator.generateRoute(
RouteSettings(
name: UnlockWalletKeysDesktop.routeName,
arguments: walletId,
),
)
];
},
), ),
); );
// showDialog<void>(
// context: context,
// barrierDismissible: false,
// builder: (context) => UnlockWalletKeysDesktop(
// walletId: walletId,
// ),
// );
}, },
child: Container( child: Container(
color: Colors.transparent, color: Colors.transparent,

View file

@ -106,6 +106,7 @@ import 'package:stackwallet/utilities/enums/add_wallet_type_enum.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:tuple/tuple.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'; import 'pages_desktop_specific/home/settings_menu/language_settings/language_settings.dart';
class RouteGenerator { class RouteGenerator {
@ -1085,29 +1086,67 @@ class RouteGenerator {
case WalletKeysDesktopPopup.routeName: case WalletKeysDesktopPopup.routeName:
if (args is List<String>) { if (args is List<String>) {
return getRoute( return FadePageRoute(
shouldUseMaterialRoute: useMaterialPageRoute, WalletKeysDesktopPopup(
builder: (_) => WalletKeysDesktopPopup(
words: args, words: args,
), ),
settings: RouteSettings( RouteSettings(
name: settings.name, 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()}"); return _routeError("${settings.name} invalid args: ${args.toString()}");
case QRCodeDesktopPopupContent.routeName: case QRCodeDesktopPopupContent.routeName:
if (args is String) { if (args is String) {
return getRoute( return FadePageRoute(
shouldUseMaterialRoute: useMaterialPageRoute, QRCodeDesktopPopupContent(
builder: (_) => QRCodeDesktopPopupContent(
value: args, value: args,
), ),
settings: RouteSettings( RouteSettings(
name: settings.name, name: settings.name,
), ),
); );
// return getRoute(
// shouldUseMaterialRoute: useMaterialPageRoute,
// builder: (_) => QRCodeDesktopPopupContent(
// value: args,
// ),
// settings: RouteSettings(
// name: settings.name,
// ),
// );
} }
return _routeError("${settings.name} invalid args: ${args.toString()}"); return _routeError("${settings.name} invalid args: ${args.toString()}");
@ -1181,3 +1220,37 @@ class RouteGenerator {
builder: (_) => errorView); builder: (_) => errorView);
} }
} }
class FadePageRoute<T> extends PageRoute<T> {
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<double> animation,
Animation<double> 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;
}