diff --git a/lib/pages_desktop_specific/home/desktop_settings_view.dart b/lib/pages_desktop_specific/home/desktop_settings_view.dart index 7aff94b66..719a37a3a 100644 --- a/lib/pages_desktop_specific/home/desktop_settings_view.dart +++ b/lib/pages_desktop_specific/home/desktop_settings_view.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/pages_desktop_specific/home/settings_menu/advanced_settings.dart'; import 'package:stackwallet/pages_desktop_specific/home/settings_menu/appearance_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/home/settings_menu/backup_and_restore_settings.dart'; +import 'package:stackwallet/pages_desktop_specific/home/settings_menu/backup_and_restore/backup_and_restore_settings.dart'; import 'package:stackwallet/pages_desktop_specific/home/settings_menu/currency_settings.dart'; import 'package:stackwallet/pages_desktop_specific/home/settings_menu/language_settings.dart'; import 'package:stackwallet/pages_desktop_specific/home/settings_menu/nodes_settings.dart'; diff --git a/lib/pages_desktop_specific/home/settings_menu/backup_and_restore_settings.dart b/lib/pages_desktop_specific/home/settings_menu/backup_and_restore/backup_and_restore_settings.dart similarity index 91% rename from lib/pages_desktop_specific/home/settings_menu/backup_and_restore_settings.dart rename to lib/pages_desktop_specific/home/settings_menu/backup_and_restore/backup_and_restore_settings.dart index 04c23ee83..6ab82401b 100644 --- a/lib/pages_desktop_specific/home/settings_menu/backup_and_restore_settings.dart +++ b/lib/pages_desktop_specific/home/settings_menu/backup_and_restore/backup_and_restore_settings.dart @@ -2,12 +2,15 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:stackwallet/pages_desktop_specific/home/settings_menu/backup_and_restore/restore_backup_dialog.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/widgets/rounded_white_container.dart'; import 'package:url_launcher/url_launcher.dart'; +import 'enable_backup_dialog.dart'; + class BackupRestoreSettings extends ConsumerStatefulWidget { const BackupRestoreSettings({Key? key}) : super(key: key); @@ -199,7 +202,7 @@ class _BackupRestoreSettings extends ConsumerState { padding: EdgeInsets.all( 10, ), - child: ManualBackupButton(), + child: RestoreBackupButton(), ), ], ), @@ -218,6 +221,17 @@ class AutoBackupButton extends ConsumerWidget { }) : super(key: key); @override Widget build(BuildContext context, WidgetRef ref) { + Future enableAutoBackup() async { + await showDialog( + context: context, + useSafeArea: false, + barrierDismissible: true, + builder: (context) { + return const EnableBackupDialog(); + }, + ); + } + return SizedBox( width: 200, height: 48, @@ -225,7 +239,9 @@ class AutoBackupButton extends ConsumerWidget { style: Theme.of(context) .extension()! .getPrimaryEnabledButtonColor(context), - onPressed: () {}, + onPressed: () { + enableAutoBackup(); + }, child: Text( "Enable auto backup", style: STextStyles.button(context), @@ -264,6 +280,17 @@ class RestoreBackupButton extends ConsumerWidget { }) : super(key: key); @override Widget build(BuildContext context, WidgetRef ref) { + Future restoreBackup() async { + await showDialog( + context: context, + useSafeArea: false, + barrierDismissible: true, + builder: (context) { + return const RestoreBackupDialog(); + }, + ); + } + return SizedBox( width: 200, height: 48, @@ -271,9 +298,11 @@ class RestoreBackupButton extends ConsumerWidget { style: Theme.of(context) .extension()! .getPrimaryEnabledButtonColor(context), - onPressed: () {}, + onPressed: () { + restoreBackup(); + }, child: Text( - "Restore backup", + "Restore", style: STextStyles.button(context), ), ), diff --git a/lib/pages_desktop_specific/home/settings_menu/backup_and_restore/create_auto_backup.dart b/lib/pages_desktop_specific/home/settings_menu/backup_and_restore/create_auto_backup.dart new file mode 100644 index 000000000..29be17228 --- /dev/null +++ b/lib/pages_desktop_specific/home/settings_menu/backup_and_restore/create_auto_backup.dart @@ -0,0 +1,136 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; +import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import 'package:stackwallet/widgets/desktop/secondary_button.dart'; + +import '../../../../utilities/assets.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/stack_text_field.dart'; + +class CreateAutoBackup extends StatelessWidget { + // const CreateAutoBackup({Key? key, required this.chooseFileLocation}) + // : super(key: key); + + late final TextEditingController fileLocationController; + + late final FocusNode chooseFileLocation; + + @override + void initState() { + fileLocationController = TextEditingController(); + // passwordRepeatController = TextEditingController(); + + chooseFileLocation = FocusNode(); + // passwordRepeatFocusNode = FocusNode(); + + super.initState(); + } + + @override + void dispose() { + fileLocationController.dispose(); + // passwordRepeatController.dispose(); + + chooseFileLocation.dispose(); + // passwordRepeatFocusNode.dispose(); + + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return DesktopDialog( + maxHeight: 600, + maxWidth: 600, + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: const EdgeInsets.all(32), + child: Text( + "Create auto backup", + style: STextStyles.desktopH3(context), + textAlign: TextAlign.center, + ), + ), + Padding( + padding: const EdgeInsets.all(20.0), + child: 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: () { + int count = 0; + Navigator.of(context).popUntil((_) => count++ >= 2); + }, + ), + ), + ], + ), + const SizedBox( + height: 30, + ), + Container( + alignment: Alignment.centerLeft, + padding: EdgeInsets.only(left: 32), + child: Text( + "Choose file location", + style: STextStyles.desktopTextExtraSmall(context).copyWith( + color: Theme.of(context).extension()!.textDark3, + ), + textAlign: TextAlign.left, + ), + ), + TextField( + key: const Key("backupChooseFileLocation"), + style: STextStyles.desktopTextMedium(context).copyWith( + height: 2, + ), + enableSuggestions: false, + autocorrect: false, + decoration: standardInputDecoration( + "Save to...", chooseFileLocation, context), + ), + const Spacer(), + Padding( + padding: const EdgeInsets.all(32), + child: Row( + children: [ + Expanded( + child: SecondaryButton( + label: "Cancel", + onPressed: () { + int count = 0; + Navigator.of(context).popUntil((_) => count++ >= 2); + }, + ), + ), + const SizedBox( + width: 16, + ), + Expanded( + child: PrimaryButton( + label: "Enable Auto Backup", + onPressed: () {}, + ), + ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/pages_desktop_specific/home/settings_menu/enable_backup_dialog.dart b/lib/pages_desktop_specific/home/settings_menu/backup_and_restore/enable_backup_dialog.dart similarity index 79% rename from lib/pages_desktop_specific/home/settings_menu/enable_backup_dialog.dart rename to lib/pages_desktop_specific/home/settings_menu/backup_and_restore/enable_backup_dialog.dart index 4925177c3..046d136a8 100644 --- a/lib/pages_desktop_specific/home/settings_menu/enable_backup_dialog.dart +++ b/lib/pages_desktop_specific/home/settings_menu/backup_and_restore/enable_backup_dialog.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:stackwallet/pages_desktop_specific/home/settings_menu/backup_and_restore/create_auto_backup.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; @@ -11,7 +12,20 @@ class EnableBackupDialog extends StatelessWidget { @override Widget build(BuildContext context) { + Future createAutoBackup() async { + await showDialog( + context: context, + useSafeArea: false, + barrierDismissible: true, + builder: (context) { + return CreateAutoBackup(); + }, + ); + } + return DesktopDialog( + maxHeight: 300, + maxWidth: 570, child: Column( children: [ Row( @@ -47,7 +61,8 @@ class EnableBackupDialog extends StatelessWidget { child: SecondaryButton( label: "Cancel", onPressed: () { - Navigator.of(context).pop(); + int count = 0; + Navigator.of(context).popUntil((_) => count++ >= 2); }, ), ), @@ -58,8 +73,7 @@ class EnableBackupDialog extends StatelessWidget { child: PrimaryButton( label: "Continue", onPressed: () { - // Navigator.of(context).pop(); - // onConfirm.call(); + createAutoBackup(); }, ), ) diff --git a/lib/pages_desktop_specific/home/settings_menu/backup_and_restore/restore_backup_dialog.dart b/lib/pages_desktop_specific/home/settings_menu/backup_and_restore/restore_backup_dialog.dart new file mode 100644 index 000000000..07d49274a --- /dev/null +++ b/lib/pages_desktop_specific/home/settings_menu/backup_and_restore/restore_backup_dialog.dart @@ -0,0 +1,93 @@ +import 'package:flutter/material.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.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'; + +class RestoreBackupDialog extends StatelessWidget { + const RestoreBackupDialog({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return DesktopDialog( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: const EdgeInsets.all(32), + child: Text( + "Restoring Stack Wallet", + style: STextStyles.desktopH3(context), + textAlign: TextAlign.center, + ), + ), + const DesktopDialogCloseButton(), + ], + ), + const SizedBox( + height: 30, + ), + Padding( + padding: const EdgeInsets.only( + left: 32, + right: 32, + ), + child: Row( + children: [ + Text( + "Settings", + style: STextStyles.desktopTextExtraSmall(context).copyWith( + color: + Theme.of(context).extension()!.textDark3, + ), + textAlign: TextAlign.left, + ), + ], + ), + ), + // RoundedWhiteContainer( + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Row(), + // ], + // ), + // ), + const Spacer(), + Padding( + padding: const EdgeInsets.all(32), + child: Row( + children: [ + Expanded( + child: SecondaryButton( + label: "Cancel", + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ), + const SizedBox( + width: 16, + ), + Expanded( + child: PrimaryButton( + label: "Continue", + onPressed: () { + // Navigator.of(context).pop(); + // onConfirm.call(); + }, + ), + ) + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/pages_desktop_specific/home/settings_menu/nodes_settings.dart b/lib/pages_desktop_specific/home/settings_menu/nodes_settings.dart index f354927c4..bb60061d8 100644 --- a/lib/pages_desktop_specific/home/settings_menu/nodes_settings.dart +++ b/lib/pages_desktop_specific/home/settings_menu/nodes_settings.dart @@ -2,16 +2,15 @@ import 'package:flutter/material.dart'; import 'package:flutter/src/widgets/framework.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/coin_nodes_view.dart'; import 'package:stackwallet/providers/global/node_service_provider.dart'; import 'package:stackwallet/providers/global/prefs_provider.dart'; import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; -import '../../../pages/settings_views/global_settings_view/manage_nodes_views/coin_nodes_view.dart'; -import '../../../utilities/constants.dart'; - class NodesSettings extends ConsumerStatefulWidget { const NodesSettings({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/home/settings_menu/security_settings.dart b/lib/pages_desktop_specific/home/settings_menu/security_settings.dart index 7c36be8cd..cdcaed49a 100644 --- a/lib/pages_desktop_specific/home/settings_menu/security_settings.dart +++ b/lib/pages_desktop_specific/home/settings_menu/security_settings.dart @@ -2,13 +2,12 @@ import 'package:flutter/material.dart'; import 'package:flutter/src/widgets/framework.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:stackwallet/pages_desktop_specific/home/settings_menu/backup_and_restore/enable_backup_dialog.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/widgets/rounded_white_container.dart'; -import '../../../utilities/theme/stack_colors.dart'; -import 'enable_backup_dialog.dart'; - class SecuritySettings extends ConsumerStatefulWidget { const SecuritySettings({Key? key}) : super(key: key); @@ -104,23 +103,6 @@ class NewPasswordButton extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - Future enableAutoBackup() async { - // wait for keyboard to disappear - FocusScope.of(context).unfocus(); - await Future.delayed( - const Duration(milliseconds: 100), - ); - - await showDialog( - context: context, - useSafeArea: false, - barrierDismissible: true, - builder: (context) { - return EnableBackupDialog(); - }, - ); - } - return SizedBox( width: 200, height: 48, @@ -129,7 +111,27 @@ class NewPasswordButton extends ConsumerWidget { .extension()! .getPrimaryEnabledButtonColor(context), onPressed: () { - enableAutoBackup(); + // Expandable( + // header: Row( + // mainAxisAlignment: MainAxisAlignment.start, + // children: [ + // NewPasswordButton(), + // ], + // ), + // body: Column( + // mainAxisAlignment: MainAxisAlignment.start, + // children: [ + // Text( + // "Current Password", + // style: STextStyles.desktopTextExtraSmall(context).copyWith( + // color: + // Theme.of(context).extension()!.textDark3, + // ), + // textAlign: TextAlign.left, + // ), + // ], + // ), + // ); }, child: Text( "Set up new password", diff --git a/lib/route_generator.dart b/lib/route_generator.dart index c37e0da5c..202edd972 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -89,7 +89,7 @@ import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/my_stack_v import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/desktop_wallet_view.dart'; import 'package:stackwallet/pages_desktop_specific/home/settings_menu/advanced_settings.dart'; import 'package:stackwallet/pages_desktop_specific/home/settings_menu/appearance_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/home/settings_menu/backup_and_restore_settings.dart'; +import 'package:stackwallet/pages_desktop_specific/home/settings_menu/backup_and_restore/backup_and_restore_settings.dart'; import 'package:stackwallet/pages_desktop_specific/home/settings_menu/currency_settings.dart'; import 'package:stackwallet/pages_desktop_specific/home/settings_menu/language_settings.dart'; import 'package:stackwallet/pages_desktop_specific/home/settings_menu/nodes_settings.dart';