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_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/providers/global/auto_swb_service_provider.dart';
|
||||
import 'package:stackwallet/providers/global/locale_provider.dart';
|
||||
import 'package:stackwallet/providers/global/prefs_provider.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/theme/stack_colors.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/desktop/desktop_dialog.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: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 {
|
||||
const BackupRestoreSettings({Key? key}) : super(key: key);
|
||||
|
||||
|
@ -99,7 +98,7 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
|
|||
useSafeArea: false,
|
||||
barrierDismissible: true,
|
||||
builder: (context) {
|
||||
return CreateAutoBackup();
|
||||
return const CreateAutoBackup();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -428,6 +427,7 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
|
|||
width: 190,
|
||||
label: "Edit auto backup",
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
createAutoBackup();
|
||||
},
|
||||
),
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
|
@ -22,8 +23,8 @@ import 'package:stackwallet/utilities/logger.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/progress_bar.dart';
|
||||
|
@ -119,10 +120,9 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
|||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType ");
|
||||
|
||||
bool isEnabledAutoBackup = ref.watch(prefsChangeNotifierProvider
|
||||
.select((value) => value.isAutoBackupEnabled));
|
||||
// bool isEnabledAutoBackup = ref.watch(prefsChangeNotifierProvider
|
||||
// .select((value) => value.isAutoBackupEnabled));
|
||||
|
||||
String? selectedItem = "Every 10 minutes";
|
||||
final isDesktop = Util.isDesktop;
|
||||
return DesktopDialog(
|
||||
maxHeight: 680,
|
||||
|
@ -140,25 +140,7 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
|||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
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 DesktopDialogCloseButton(),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
|
@ -487,7 +469,7 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
|||
child: isDesktop
|
||||
? DropdownButtonHideUnderline(
|
||||
child: DropdownButton2(
|
||||
offset: Offset(0, -10),
|
||||
offset: const Offset(0, -10),
|
||||
isExpanded: true,
|
||||
dropdownElevation: 0,
|
||||
value: _currentDropDownValue,
|
||||
|
@ -570,12 +552,8 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
|||
Expanded(
|
||||
child: SecondaryButton(
|
||||
label: "Cancel",
|
||||
onPressed: () {
|
||||
int count = 0;
|
||||
!isEnabledAutoBackup
|
||||
? Navigator.of(context).popUntil((_) => count++ >= 2)
|
||||
: Navigator.of(context).pop();
|
||||
},
|
||||
desktopMed: true,
|
||||
onPressed: Navigator.of(context).pop,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
|
@ -583,6 +561,7 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
|||
),
|
||||
Expanded(
|
||||
child: PrimaryButton(
|
||||
desktopMed: true,
|
||||
label: "Enable Auto Backup",
|
||||
enabled: shouldEnableCreate,
|
||||
onPressed: !shouldEnableCreate
|
||||
|
@ -595,44 +574,89 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
|||
passphraseRepeatController.text;
|
||||
|
||||
if (pathToSave.isEmpty) {
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.warning,
|
||||
message: "Directory not chosen",
|
||||
context: context,
|
||||
unawaited(
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.warning,
|
||||
message: "Directory not chosen",
|
||||
context: context,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (!(await Directory(pathToSave).exists())) {
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.warning,
|
||||
message: "Directory does not exist",
|
||||
context: context,
|
||||
unawaited(
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.warning,
|
||||
message: "Directory does not exist",
|
||||
context: context,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (passphrase.isEmpty) {
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.warning,
|
||||
message: "A passphrase is required",
|
||||
context: context,
|
||||
unawaited(
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.warning,
|
||||
message: "A passphrase is required",
|
||||
context: context,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (passphrase != repeatPassphrase) {
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.warning,
|
||||
message: "Passphrase does not match",
|
||||
context: context,
|
||||
unawaited(
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.warning,
|
||||
message: "Passphrase does not match",
|
||||
context: context,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
showDialog<dynamic>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => const StackDialog(
|
||||
title: "Encrypting initial backup",
|
||||
message: "This shouldn't take long",
|
||||
unawaited(
|
||||
showDialog<dynamic>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) {
|
||||
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);
|
||||
// pop encryption progress dialog
|
||||
Navigator.of(context).pop();
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.warning,
|
||||
message: err,
|
||||
context: context,
|
||||
unawaited(
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.warning,
|
||||
message: err,
|
||||
context: context,
|
||||
),
|
||||
);
|
||||
return;
|
||||
} catch (e, s) {
|
||||
|
@ -664,10 +690,12 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
|||
.log("$e\n$s", level: LogLevel.Error);
|
||||
// pop encryption progress dialog
|
||||
Navigator.of(context).pop();
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.warning,
|
||||
message: "$e",
|
||||
context: context,
|
||||
unawaited(
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.warning,
|
||||
message: "$e",
|
||||
context: context,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -698,9 +726,7 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
|||
|
||||
if (mounted) {
|
||||
// pop encryption progress dialog
|
||||
int count = 0;
|
||||
Navigator.of(context)
|
||||
.popUntil((_) => count++ >= 2);
|
||||
Navigator.of(context).pop();
|
||||
|
||||
if (result) {
|
||||
ref
|
||||
|
@ -717,22 +743,76 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
|||
await showDialog<dynamic>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => Platform.isAndroid
|
||||
? StackOkDialog(
|
||||
title:
|
||||
"Stack Auto Backup enabled and saved to:",
|
||||
message: fileToSave,
|
||||
)
|
||||
: const StackOkDialog(
|
||||
title: "Stack Auto Backup enabled!"),
|
||||
builder: (context) {
|
||||
if (Platform.isAndroid) {
|
||||
return StackOkDialog(
|
||||
title:
|
||||
"Stack Auto Backup enabled and saved to:",
|
||||
message: fileToSave,
|
||||
);
|
||||
} 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) {
|
||||
passphraseController.text = "";
|
||||
passphraseRepeatController.text = "";
|
||||
|
||||
int count = 0;
|
||||
Navigator.of(context)
|
||||
.popUntil((_) => count++ >= 2);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
} else {
|
||||
await showDialog<dynamic>(
|
||||
|
|
|
@ -18,7 +18,7 @@ class EnableBackupDialog extends StatelessWidget {
|
|||
useSafeArea: false,
|
||||
barrierDismissible: true,
|
||||
builder: (context) {
|
||||
return CreateAutoBackup();
|
||||
return const CreateAutoBackup();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ class EnableBackupDialog extends StatelessWidget {
|
|||
children: [
|
||||
Expanded(
|
||||
child: SecondaryButton(
|
||||
desktopMed: true,
|
||||
label: "Cancel",
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
|
@ -70,8 +71,10 @@ class EnableBackupDialog extends StatelessWidget {
|
|||
),
|
||||
Expanded(
|
||||
child: PrimaryButton(
|
||||
desktopMed: true,
|
||||
label: "Continue",
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
createAutoBackup();
|
||||
},
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue