mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-18 02:07:43 +00:00
linter warning clean up and update process dialog popups
This commit is contained in:
parent
48bfabf74e
commit
ceaaa0a4f0
3 changed files with 162 additions and 79 deletions
|
@ -7,6 +7,7 @@ import 'package:stackwallet/pages/settings_views/global_settings_view/stack_back
|
||||||
import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart';
|
import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/home/settings_menu/backup_and_restore/create_auto_backup.dart';
|
import 'package:stackwallet/pages_desktop_specific/home/settings_menu/backup_and_restore/create_auto_backup.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/home/settings_menu/backup_and_restore/enable_backup_dialog.dart';
|
import 'package:stackwallet/pages_desktop_specific/home/settings_menu/backup_and_restore/enable_backup_dialog.dart';
|
||||||
|
import 'package:stackwallet/providers/global/auto_swb_service_provider.dart';
|
||||||
import 'package:stackwallet/providers/global/locale_provider.dart';
|
import 'package:stackwallet/providers/global/locale_provider.dart';
|
||||||
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
|
@ -15,6 +16,7 @@ import 'package:stackwallet/utilities/format.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';
|
||||||
import 'package:stackwallet/utilities/util.dart';
|
import 'package:stackwallet/utilities/util.dart';
|
||||||
|
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
||||||
import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart';
|
import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
||||||
|
@ -23,9 +25,6 @@ import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||||
import 'package:stackwallet/widgets/stack_dialog.dart';
|
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
import '../../../../providers/global/auto_swb_service_provider.dart';
|
|
||||||
import '../../../../widgets/custom_buttons/blue_text_button.dart';
|
|
||||||
|
|
||||||
class BackupRestoreSettings extends ConsumerStatefulWidget {
|
class BackupRestoreSettings extends ConsumerStatefulWidget {
|
||||||
const BackupRestoreSettings({Key? key}) : super(key: key);
|
const BackupRestoreSettings({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@ -99,7 +98,7 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
|
||||||
useSafeArea: false,
|
useSafeArea: false,
|
||||||
barrierDismissible: true,
|
barrierDismissible: true,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return CreateAutoBackup();
|
return const CreateAutoBackup();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -428,6 +427,7 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
|
||||||
width: 190,
|
width: 190,
|
||||||
label: "Edit auto backup",
|
label: "Edit auto backup",
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
createAutoBackup();
|
createAutoBackup();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
@ -22,8 +23,8 @@ import 'package:stackwallet/utilities/logger.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';
|
||||||
import 'package:stackwallet/utilities/util.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.dart';
|
||||||
|
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||||
import 'package:stackwallet/widgets/progress_bar.dart';
|
import 'package:stackwallet/widgets/progress_bar.dart';
|
||||||
|
@ -119,10 +120,9 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
debugPrint("BUILD: $runtimeType ");
|
debugPrint("BUILD: $runtimeType ");
|
||||||
|
|
||||||
bool isEnabledAutoBackup = ref.watch(prefsChangeNotifierProvider
|
// bool isEnabledAutoBackup = ref.watch(prefsChangeNotifierProvider
|
||||||
.select((value) => value.isAutoBackupEnabled));
|
// .select((value) => value.isAutoBackupEnabled));
|
||||||
|
|
||||||
String? selectedItem = "Every 10 minutes";
|
|
||||||
final isDesktop = Util.isDesktop;
|
final isDesktop = Util.isDesktop;
|
||||||
return DesktopDialog(
|
return DesktopDialog(
|
||||||
maxHeight: 680,
|
maxHeight: 680,
|
||||||
|
@ -140,25 +140,7 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
const DesktopDialogCloseButton(),
|
||||||
padding: const EdgeInsets.all(20.0),
|
|
||||||
child: AppBarIconButton(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.extension<StackColors>()!
|
|
||||||
.textFieldDefaultBG,
|
|
||||||
size: 40,
|
|
||||||
icon: SvgPicture.asset(
|
|
||||||
Assets.svg.x,
|
|
||||||
color: Theme.of(context).extension<StackColors>()!.textDark,
|
|
||||||
width: 22,
|
|
||||||
height: 22,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
int count = 0;
|
|
||||||
Navigator.of(context).popUntil((_) => count++ >= 2);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
@ -487,7 +469,7 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
||||||
child: isDesktop
|
child: isDesktop
|
||||||
? DropdownButtonHideUnderline(
|
? DropdownButtonHideUnderline(
|
||||||
child: DropdownButton2(
|
child: DropdownButton2(
|
||||||
offset: Offset(0, -10),
|
offset: const Offset(0, -10),
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
dropdownElevation: 0,
|
dropdownElevation: 0,
|
||||||
value: _currentDropDownValue,
|
value: _currentDropDownValue,
|
||||||
|
@ -570,12 +552,8 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SecondaryButton(
|
child: SecondaryButton(
|
||||||
label: "Cancel",
|
label: "Cancel",
|
||||||
onPressed: () {
|
desktopMed: true,
|
||||||
int count = 0;
|
onPressed: Navigator.of(context).pop,
|
||||||
!isEnabledAutoBackup
|
|
||||||
? Navigator.of(context).popUntil((_) => count++ >= 2)
|
|
||||||
: Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
@ -583,6 +561,7 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: PrimaryButton(
|
child: PrimaryButton(
|
||||||
|
desktopMed: true,
|
||||||
label: "Enable Auto Backup",
|
label: "Enable Auto Backup",
|
||||||
enabled: shouldEnableCreate,
|
enabled: shouldEnableCreate,
|
||||||
onPressed: !shouldEnableCreate
|
onPressed: !shouldEnableCreate
|
||||||
|
@ -595,44 +574,89 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
||||||
passphraseRepeatController.text;
|
passphraseRepeatController.text;
|
||||||
|
|
||||||
if (pathToSave.isEmpty) {
|
if (pathToSave.isEmpty) {
|
||||||
showFloatingFlushBar(
|
unawaited(
|
||||||
type: FlushBarType.warning,
|
showFloatingFlushBar(
|
||||||
message: "Directory not chosen",
|
type: FlushBarType.warning,
|
||||||
context: context,
|
message: "Directory not chosen",
|
||||||
|
context: context,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(await Directory(pathToSave).exists())) {
|
if (!(await Directory(pathToSave).exists())) {
|
||||||
showFloatingFlushBar(
|
unawaited(
|
||||||
type: FlushBarType.warning,
|
showFloatingFlushBar(
|
||||||
message: "Directory does not exist",
|
type: FlushBarType.warning,
|
||||||
context: context,
|
message: "Directory does not exist",
|
||||||
|
context: context,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (passphrase.isEmpty) {
|
if (passphrase.isEmpty) {
|
||||||
showFloatingFlushBar(
|
unawaited(
|
||||||
type: FlushBarType.warning,
|
showFloatingFlushBar(
|
||||||
message: "A passphrase is required",
|
type: FlushBarType.warning,
|
||||||
context: context,
|
message: "A passphrase is required",
|
||||||
|
context: context,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (passphrase != repeatPassphrase) {
|
if (passphrase != repeatPassphrase) {
|
||||||
showFloatingFlushBar(
|
unawaited(
|
||||||
type: FlushBarType.warning,
|
showFloatingFlushBar(
|
||||||
message: "Passphrase does not match",
|
type: FlushBarType.warning,
|
||||||
context: context,
|
message: "Passphrase does not match",
|
||||||
|
context: context,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
showDialog<dynamic>(
|
unawaited(
|
||||||
context: context,
|
showDialog<dynamic>(
|
||||||
barrierDismissible: false,
|
context: context,
|
||||||
builder: (_) => const StackDialog(
|
barrierDismissible: false,
|
||||||
title: "Encrypting initial backup",
|
builder: (_) {
|
||||||
message: "This shouldn't take long",
|
if (Util.isDesktop) {
|
||||||
|
return DesktopDialog(
|
||||||
|
maxHeight: double.infinity,
|
||||||
|
maxWidth: 450,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(
|
||||||
|
32,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Encrypting initial backup",
|
||||||
|
style: STextStyles.desktopH3(
|
||||||
|
context),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 40,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"This shouldn't take long",
|
||||||
|
style: STextStyles
|
||||||
|
.desktopTextExtraExtraSmall(
|
||||||
|
context),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const StackDialog(
|
||||||
|
title: "Encrypting initial backup",
|
||||||
|
message: "This shouldn't take long",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -653,10 +677,12 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
||||||
.log("$err\n$s", level: LogLevel.Error);
|
.log("$err\n$s", level: LogLevel.Error);
|
||||||
// pop encryption progress dialog
|
// pop encryption progress dialog
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
showFloatingFlushBar(
|
unawaited(
|
||||||
type: FlushBarType.warning,
|
showFloatingFlushBar(
|
||||||
message: err,
|
type: FlushBarType.warning,
|
||||||
context: context,
|
message: err,
|
||||||
|
context: context,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
|
@ -664,10 +690,12 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
||||||
.log("$e\n$s", level: LogLevel.Error);
|
.log("$e\n$s", level: LogLevel.Error);
|
||||||
// pop encryption progress dialog
|
// pop encryption progress dialog
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
showFloatingFlushBar(
|
unawaited(
|
||||||
type: FlushBarType.warning,
|
showFloatingFlushBar(
|
||||||
message: "$e",
|
type: FlushBarType.warning,
|
||||||
context: context,
|
message: "$e",
|
||||||
|
context: context,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -698,9 +726,7 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
// pop encryption progress dialog
|
// pop encryption progress dialog
|
||||||
int count = 0;
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context)
|
|
||||||
.popUntil((_) => count++ >= 2);
|
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
ref
|
ref
|
||||||
|
@ -717,22 +743,76 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
||||||
await showDialog<dynamic>(
|
await showDialog<dynamic>(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
builder: (_) => Platform.isAndroid
|
builder: (context) {
|
||||||
? StackOkDialog(
|
if (Platform.isAndroid) {
|
||||||
title:
|
return StackOkDialog(
|
||||||
"Stack Auto Backup enabled and saved to:",
|
title:
|
||||||
message: fileToSave,
|
"Stack Auto Backup enabled and saved to:",
|
||||||
)
|
message: fileToSave,
|
||||||
: const StackOkDialog(
|
);
|
||||||
title: "Stack Auto Backup enabled!"),
|
} else if (Util.isDesktop) {
|
||||||
|
return DesktopDialog(
|
||||||
|
maxHeight: double.infinity,
|
||||||
|
maxWidth: 500,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 32,
|
||||||
|
right: 32,
|
||||||
|
bottom: 32,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment
|
||||||
|
.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Stack Auto Backup enabled!",
|
||||||
|
style:
|
||||||
|
STextStyles.desktopH3(
|
||||||
|
context),
|
||||||
|
),
|
||||||
|
const DesktopDialogCloseButton(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 40,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
const Spacer(),
|
||||||
|
Expanded(
|
||||||
|
child: PrimaryButton(
|
||||||
|
label: "Ok",
|
||||||
|
desktopMed: true,
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context)
|
||||||
|
.pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const StackOkDialog(
|
||||||
|
title: "Stack Auto Backup enabled!",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
);
|
);
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
passphraseController.text = "";
|
passphraseController.text = "";
|
||||||
passphraseRepeatController.text = "";
|
passphraseRepeatController.text = "";
|
||||||
|
|
||||||
int count = 0;
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context)
|
|
||||||
.popUntil((_) => count++ >= 2);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await showDialog<dynamic>(
|
await showDialog<dynamic>(
|
||||||
|
|
|
@ -18,7 +18,7 @@ class EnableBackupDialog extends StatelessWidget {
|
||||||
useSafeArea: false,
|
useSafeArea: false,
|
||||||
barrierDismissible: true,
|
barrierDismissible: true,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return CreateAutoBackup();
|
return const CreateAutoBackup();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ class EnableBackupDialog extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SecondaryButton(
|
child: SecondaryButton(
|
||||||
|
desktopMed: true,
|
||||||
label: "Cancel",
|
label: "Cancel",
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
@ -70,8 +71,10 @@ class EnableBackupDialog extends StatelessWidget {
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: PrimaryButton(
|
child: PrimaryButton(
|
||||||
|
desktopMed: true,
|
||||||
label: "Continue",
|
label: "Continue",
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
createAutoBackup();
|
createAutoBackup();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue