From fb0908840d6c97f83c24cd419cee59c8e49b2083 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 26 Sep 2022 10:13:15 -0600 Subject: [PATCH] finished up desktop restore from mnemonic flow --- .../confirm_recovery_dialog.dart | 27 +--- .../sub_widgets/restore_succeeded_dialog.dart | 101 +++++++++++--- .../sub_widgets/restoring_dialog.dart | 130 ++++++++++++++---- .../desktop/desktop_dialog_close_button.dart | 44 ++++++ 4 files changed, 227 insertions(+), 75 deletions(-) create mode 100644 lib/widgets/desktop/desktop_dialog_close_button.dart diff --git a/lib/pages/add_wallet_views/restore_wallet_view/confirm_recovery_dialog.dart b/lib/pages/add_wallet_views/restore_wallet_view/confirm_recovery_dialog.dart index 05d951962..8c50b75b4 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/confirm_recovery_dialog.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/confirm_recovery_dialog.dart @@ -4,8 +4,8 @@ import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; @@ -22,30 +22,7 @@ class ConfirmRecoveryDialog extends StatelessWidget { return DesktopDialog( child: Column( children: [ - Padding( - padding: const EdgeInsets.all(20.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - AppBarIconButton( - color: Theme.of(context) - .extension()! - .textFieldDefaultBG, - size: 40, - icon: SvgPicture.asset( - Assets.svg.x, - color: - Theme.of(context).extension()!.textDark, - width: 22, - height: 22, - ), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ], - ), - ), + const DesktopDialogCloseButton(), const SizedBox( height: 5, ), diff --git a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_succeeded_dialog.dart b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_succeeded_dialog.dart index 2cd539c0c..51bb8f2d7 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_succeeded_dialog.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_succeeded_dialog.dart @@ -3,6 +3,10 @@ import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; +import 'package:stackwallet/widgets/desktop/primary_button.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; class RestoreSucceededDialog extends StatelessWidget { @@ -10,27 +14,82 @@ class RestoreSucceededDialog extends StatelessWidget { @override Widget build(BuildContext context) { - return StackDialog( - title: "Wallet restored", - message: "You can use your wallet now.", - icon: SvgPicture.asset( - Assets.svg.checkCircle, - width: 24, - height: 24, - color: Theme.of(context).extension()!.accentColorGreen, - ), - rightButton: TextButton( - style: Theme.of(context) - .extension()! - .getSecondaryEnabledButtonColor(context), - child: Text( - "Ok", - style: STextStyles.itemSubtitle12(context), + if (Util.isDesktop) { + return DesktopDialog( + child: Column( + children: [ + const DesktopDialogCloseButton(), + const Spacer( + flex: 1, + ), + SvgPicture.asset( + Assets.svg.checkCircle, + width: 40, + height: 40, + color: + Theme.of(context).extension()!.accentColorDark, + ), + const Spacer( + flex: 2, + ), + Text( + "Wallet restored", + style: STextStyles.desktopH2(context), + textAlign: TextAlign.center, + ), + const SizedBox( + height: 16, + ), + Text( + "You can use your wallet now.", + style: STextStyles.desktopTextMedium(context).copyWith( + color: Theme.of(context).extension()!.textDark3, + ), + textAlign: TextAlign.center, + ), + const Spacer( + flex: 2, + ), + Padding( + padding: const EdgeInsets.only( + left: 32, + right: 32, + bottom: 32, + ), + child: PrimaryButton( + width: 272.5, + label: "OK", + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ), + ], ), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ); + ); + } else { + return StackDialog( + title: "Wallet restored", + message: "You can use your wallet now.", + icon: SvgPicture.asset( + Assets.svg.checkCircle, + width: 24, + height: 24, + color: Theme.of(context).extension()!.accentColorGreen, + ), + rightButton: TextButton( + style: Theme.of(context) + .extension()! + .getSecondaryEnabledButtonColor(context), + child: Text( + "Ok", + style: STextStyles.itemSubtitle12(context), + ), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ); + } } } diff --git a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restoring_dialog.dart b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restoring_dialog.dart index 80a688d03..001fff6c0 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restoring_dialog.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restoring_dialog.dart @@ -3,6 +3,10 @@ import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; +import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; class RestoringDialog extends StatefulWidget { @@ -50,37 +54,105 @@ class _RestoringDialogState extends State @override Widget build(BuildContext context) { - return WillPopScope( - onWillPop: () async { - return false; - }, - child: StackDialog( - title: "Restoring wallet", - 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), + if (Util.isDesktop) { + return DesktopDialog( + child: Column( + children: [ + DesktopDialogCloseButton( + onPressedOverride: () async { + await onCancel.call(); + if (mounted) { + Navigator.of(context).pop(); + } + }, + ), + const Spacer( + flex: 1, + ), + RotationTransition( + turns: _spinAnimation, + child: SvgPicture.asset(Assets.svg.arrowRotate3, + width: 40, + height: 40, + color: Theme.of(context) + .extension()! + .accentColorDark), + ), + const Spacer( + flex: 2, + ), + Text( + "Restoring wallet...", + style: STextStyles.desktopH2(context), + textAlign: TextAlign.center, + ), + const SizedBox( + height: 16, + ), + Text( + "Restoring your wallet may take a while.\nPlease do not exit this screen.", + style: STextStyles.desktopTextMedium(context).copyWith( + color: Theme.of(context).extension()!.textDark3, + ), + textAlign: TextAlign.center, + ), + const Spacer( + flex: 2, + ), + Padding( + padding: const EdgeInsets.only( + left: 32, + right: 32, + bottom: 32, + ), + child: SecondaryButton( + label: "Cancel", + width: 272.5, + onPressed: () async { + await onCancel.call(); + if (mounted) { + Navigator.of(context).pop(); + } + }, + ), + ), + ], ), - rightButton: TextButton( - style: Theme.of(context) - .extension()! - .getSecondaryEnabledButtonColor(context), - child: Text( - "Cancel", - style: STextStyles.itemSubtitle12(context), + ); + } else { + return WillPopScope( + onWillPop: () async { + return false; + }, + child: StackDialog( + title: "Restoring wallet", + 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) + .extension()! + .getSecondaryEnabledButtonColor(context), + child: Text( + "Cancel", + style: STextStyles.itemSubtitle12(context), + ), + onPressed: () async { + await onCancel.call(); + if (mounted) { + Navigator.of(context).pop(); + } + }, ), - onPressed: () async { - await onCancel.call(); - if (mounted) { - Navigator.of(context).pop(); - } - }, ), - ), - ); + ); + } } } diff --git a/lib/widgets/desktop/desktop_dialog_close_button.dart b/lib/widgets/desktop/desktop_dialog_close_button.dart new file mode 100644 index 000000000..da992d5f6 --- /dev/null +++ b/lib/widgets/desktop/desktop_dialog_close_button.dart @@ -0,0 +1,44 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; + +class DesktopDialogCloseButton extends StatelessWidget { + const DesktopDialogCloseButton({ + Key? key, + this.onPressedOverride, + }) : super(key: key); + + final VoidCallback? onPressedOverride; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(20.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + AppBarIconButton( + color: + Theme.of(context).extension()!.textFieldDefaultBG, + size: 40, + icon: SvgPicture.asset( + Assets.svg.x, + color: Theme.of(context).extension()!.textDark, + width: 22, + height: 22, + ), + onPressed: () { + if (onPressedOverride == null) { + Navigator.of(context).pop(); + } else { + onPressedOverride!.call(); + } + }, + ), + ], + ), + ); + } +}