mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-26 09:08:53 +00:00
Merge branch 'desktop' into desktop-testing
# Conflicts: # lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart
This commit is contained in:
commit
bfe1b7e291
10 changed files with 920 additions and 383 deletions
1
.github/workflows/test.yaml
vendored
1
.github/workflows/test.yaml
vendored
|
@ -23,6 +23,7 @@ jobs:
|
|||
run: |
|
||||
cargo install cargo-ndk
|
||||
rustup target add x86_64-unknown-linux-gnu
|
||||
sudo apt update
|
||||
sudo apt install -y unzip automake build-essential file pkg-config git python libtool libtinfo5 cmake openjdk-8-jre-headless libgit2-dev clang libncurses5-dev libncursesw5-dev zlib1g-dev llvm
|
||||
sudo apt install -y debhelper libclang-dev cargo rustc opencl-headers libssl-dev ocl-icd-opencl-dev
|
||||
sudo apt install -y libc6-dev-i386
|
||||
|
|
4
assets/svg/enabled-button.svg
Normal file
4
assets/svg/enabled-button.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 6.2 KiB |
|
@ -1,6 +1,11 @@
|
|||
import 'package:flutter/material.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/primary_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||
|
||||
class CancelStackRestoreDialog extends StatelessWidget {
|
||||
|
@ -14,7 +19,8 @@ class CancelStackRestoreDialog extends StatelessWidget {
|
|||
onWillPop: () async {
|
||||
return false;
|
||||
},
|
||||
child: StackDialog(
|
||||
child: !Util.isDesktop
|
||||
? StackDialog(
|
||||
title: "Cancel restore process",
|
||||
message:
|
||||
"Cancelling will revert any changes that may have been applied",
|
||||
|
@ -37,14 +43,70 @@ class CancelStackRestoreDialog extends StatelessWidget {
|
|||
child: Text(
|
||||
"Yes, cancel",
|
||||
style: STextStyles.itemSubtitle12(context).copyWith(
|
||||
color:
|
||||
Theme.of(context).extension<StackColors>()!.buttonTextPrimary,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.buttonTextPrimary,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(true);
|
||||
},
|
||||
),
|
||||
)
|
||||
: DesktopDialog(
|
||||
maxHeight: 250,
|
||||
maxWidth: 600,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 20, left: 32, right: 32, bottom: 20),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Cancel Restore Process",
|
||||
style: STextStyles.desktopH3(context),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(
|
||||
width: 500,
|
||||
child: RoundedContainer(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.snackBarBackError,
|
||||
child: Text(
|
||||
"If you cancel, the restore will not complete, and "
|
||||
"the wallets will not appear in your Stack.",
|
||||
style: STextStyles.desktopTextMedium(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SecondaryButton(
|
||||
width: 248,
|
||||
desktopMed: true,
|
||||
enabled: true,
|
||||
label: "Keep restoring",
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(false);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
PrimaryButton(
|
||||
width: 248,
|
||||
desktopMed: true,
|
||||
enabled: true,
|
||||
label: "Cancel anyway",
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(true);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import 'package:stackwallet/notifications/show_flush_bar.dart';
|
|||
import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart';
|
||||
import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/stack_file_system.dart';
|
||||
import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart';
|
||||
// import 'package:stackwallet/pages_desktop_specific/home/settings_menu/backup_and_restore/restore_backup_dialog.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
|
@ -21,13 +20,14 @@ import 'package:stackwallet/utilities/util.dart';
|
|||
import 'package:stackwallet/widgets/conditional_parent.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/loading_indicator.dart';
|
||||
import 'package:stackwallet/widgets/stack_text_field.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
import '../../../../widgets/desktop/desktop_dialog_close_button.dart';
|
||||
|
||||
class RestoreFromFileView extends ConsumerStatefulWidget {
|
||||
const RestoreFromFileView({Key? key}) : super(key: key);
|
||||
|
||||
|
@ -48,17 +48,6 @@ class _RestoreFromFileViewState extends ConsumerState<RestoreFromFileView> {
|
|||
|
||||
bool hidePassword = true;
|
||||
|
||||
Future<void> restoreBackupPopup(BuildContext context) async {
|
||||
// await showDialog<dynamic>(
|
||||
// context: context,
|
||||
// useSafeArea: false,
|
||||
// barrierDismissible: true,
|
||||
// builder: (context) {
|
||||
// return const RestoreBackupDialog();
|
||||
// },
|
||||
// );
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
stackFileSystem = StackFileSystem();
|
||||
|
@ -237,7 +226,7 @@ class _RestoreFromFileViewState extends ConsumerState<RestoreFromFileView> {
|
|||
enableSuggestions: false,
|
||||
autocorrect: false,
|
||||
decoration: standardInputDecoration(
|
||||
"Enter password",
|
||||
"Enter passphrase",
|
||||
passwordFocusNode,
|
||||
context,
|
||||
).copyWith(
|
||||
|
@ -534,7 +523,7 @@ class _RestoreFromFileViewState extends ConsumerState<RestoreFromFileView> {
|
|||
const EdgeInsets
|
||||
.all(32),
|
||||
child: Text(
|
||||
"Restoring Stack Wallet",
|
||||
"Restore Stack Wallet",
|
||||
style: STextStyles
|
||||
.desktopH3(
|
||||
context),
|
||||
|
@ -546,11 +535,9 @@ class _RestoreFromFileViewState extends ConsumerState<RestoreFromFileView> {
|
|||
const DesktopDialogCloseButton(),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets
|
||||
padding:
|
||||
const EdgeInsets
|
||||
.symmetric(
|
||||
horizontal:
|
||||
32),
|
||||
|
@ -560,6 +547,9 @@ class _RestoreFromFileViewState extends ConsumerState<RestoreFromFileView> {
|
|||
jsonString,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 32,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -20,10 +20,13 @@ import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
|||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||
import 'package:stackwallet/widgets/icon_widgets/addressbook_icon.dart';
|
||||
import 'package:stackwallet/widgets/loading_indicator.dart';
|
||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||
|
||||
import '../../../../../widgets/desktop/primary_button.dart';
|
||||
|
||||
class StackRestoreProgressView extends ConsumerStatefulWidget {
|
||||
const StackRestoreProgressView({
|
||||
Key? key,
|
||||
|
@ -101,6 +104,30 @@ class _StackRestoreProgressViewState
|
|||
context: context,
|
||||
builder: (_) => const CancelStackRestoreDialog(),
|
||||
);
|
||||
// : await Row(
|
||||
// children: [
|
||||
// SecondaryButton(
|
||||
// width: 248,
|
||||
// desktopMed: true,
|
||||
// enabled: true,
|
||||
// label: "Keep restoring",
|
||||
// onPressed: () {
|
||||
// false;
|
||||
// },
|
||||
// ),
|
||||
// const SizedBox(width: 16),
|
||||
// PrimaryButton(
|
||||
// width: 248,
|
||||
// desktopMed: true,
|
||||
// enabled: true,
|
||||
// label: "Cancel anyway",
|
||||
// onPressed: () {
|
||||
// true;
|
||||
// },
|
||||
// )
|
||||
// ],
|
||||
// );
|
||||
|
||||
if (result is bool && result) {
|
||||
return true;
|
||||
}
|
||||
|
@ -130,6 +157,7 @@ class _StackRestoreProgressViewState
|
|||
}
|
||||
|
||||
bool _success = false;
|
||||
bool pendingCancel = false;
|
||||
|
||||
Future<bool> _onWillPop() async {
|
||||
if (_success) {
|
||||
|
@ -241,7 +269,7 @@ class _StackRestoreProgressViewState
|
|||
left: 4,
|
||||
top: 4,
|
||||
right: 4,
|
||||
bottom: 0,
|
||||
bottom: 4,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
@ -257,7 +285,8 @@ class _StackRestoreProgressViewState
|
|||
builder: (_, ref, __) {
|
||||
final state = ref.watch(stackRestoringUIStateProvider
|
||||
.select((value) => value.preferences));
|
||||
return RestoringItemCard(
|
||||
return !isDesktop
|
||||
? RestoringItemCard(
|
||||
left: SizedBox(
|
||||
width: 32,
|
||||
height: 32,
|
||||
|
@ -290,6 +319,49 @@ class _StackRestoreProgressViewState
|
|||
style: STextStyles.errorSmall(context),
|
||||
)
|
||||
: null,
|
||||
)
|
||||
: RoundedContainer(
|
||||
padding: EdgeInsets.all(0),
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.popupBG,
|
||||
borderColor: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.background,
|
||||
child: RestoringItemCard(
|
||||
left: SizedBox(
|
||||
width: 32,
|
||||
height: 32,
|
||||
child: RoundedContainer(
|
||||
padding: const EdgeInsets.all(0),
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.buttonBackSecondary,
|
||||
child: Center(
|
||||
child: SvgPicture.asset(
|
||||
Assets.svg.gear,
|
||||
width: 16,
|
||||
height: 16,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
right: SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: _getIconForState(state),
|
||||
),
|
||||
title: "Preferences",
|
||||
subTitle: state == StackRestoringStatus.failed
|
||||
? Text(
|
||||
"Something went wrong",
|
||||
style: STextStyles.errorSmall(context),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
@ -300,7 +372,8 @@ class _StackRestoreProgressViewState
|
|||
builder: (_, ref, __) {
|
||||
final state = ref.watch(stackRestoringUIStateProvider
|
||||
.select((value) => value.addressBook));
|
||||
return RestoringItemCard(
|
||||
return !isDesktop
|
||||
? RestoringItemCard(
|
||||
left: SizedBox(
|
||||
width: 32,
|
||||
height: 32,
|
||||
|
@ -332,6 +405,48 @@ class _StackRestoreProgressViewState
|
|||
style: STextStyles.errorSmall(context),
|
||||
)
|
||||
: null,
|
||||
)
|
||||
: RoundedContainer(
|
||||
padding: EdgeInsets.all(0),
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.popupBG,
|
||||
borderColor: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.background,
|
||||
child: RestoringItemCard(
|
||||
left: SizedBox(
|
||||
width: 32,
|
||||
height: 32,
|
||||
child: RoundedContainer(
|
||||
padding: const EdgeInsets.all(0),
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.buttonBackSecondary,
|
||||
child: Center(
|
||||
child: AddressBookIcon(
|
||||
width: 16,
|
||||
height: 16,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
right: SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: _getIconForState(state),
|
||||
),
|
||||
title: "Address book",
|
||||
subTitle: state == StackRestoringStatus.failed
|
||||
? Text(
|
||||
"Something went wrong",
|
||||
style: STextStyles.errorSmall(context),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
@ -342,7 +457,8 @@ class _StackRestoreProgressViewState
|
|||
builder: (_, ref, __) {
|
||||
final state = ref.watch(stackRestoringUIStateProvider
|
||||
.select((value) => value.nodes));
|
||||
return RestoringItemCard(
|
||||
return !isDesktop
|
||||
? RestoringItemCard(
|
||||
left: SizedBox(
|
||||
width: 32,
|
||||
height: 32,
|
||||
|
@ -375,7 +491,49 @@ class _StackRestoreProgressViewState
|
|||
style: STextStyles.errorSmall(context),
|
||||
)
|
||||
: null,
|
||||
);
|
||||
)
|
||||
: RoundedContainer(
|
||||
padding: EdgeInsets.all(0),
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.popupBG,
|
||||
borderColor: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.background,
|
||||
child: RestoringItemCard(
|
||||
left: SizedBox(
|
||||
width: 32,
|
||||
height: 32,
|
||||
child: RoundedContainer(
|
||||
padding: const EdgeInsets.all(0),
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.buttonBackSecondary,
|
||||
child: Center(
|
||||
child: SvgPicture.asset(
|
||||
Assets.svg.node,
|
||||
width: 16,
|
||||
height: 16,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
right: SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: _getIconForState(state),
|
||||
),
|
||||
title: "Nodes",
|
||||
subTitle: state == StackRestoringStatus.failed
|
||||
? Text(
|
||||
"Something went wrong",
|
||||
style: STextStyles.errorSmall(context),
|
||||
)
|
||||
: null,
|
||||
));
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
|
@ -385,7 +543,9 @@ class _StackRestoreProgressViewState
|
|||
builder: (_, ref, __) {
|
||||
final state = ref.watch(stackRestoringUIStateProvider
|
||||
.select((value) => value.trades));
|
||||
return RestoringItemCard(
|
||||
return !isDesktop
|
||||
? Container(
|
||||
child: RestoringItemCard(
|
||||
left: SizedBox(
|
||||
width: 32,
|
||||
height: 32,
|
||||
|
@ -418,6 +578,50 @@ class _StackRestoreProgressViewState
|
|||
style: STextStyles.errorSmall(context),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
)
|
||||
: RoundedContainer(
|
||||
padding: EdgeInsets.all(0),
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.popupBG,
|
||||
borderColor: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.background,
|
||||
child: RestoringItemCard(
|
||||
left: SizedBox(
|
||||
width: 32,
|
||||
height: 32,
|
||||
child: RoundedContainer(
|
||||
padding: const EdgeInsets.all(0),
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.buttonBackSecondary,
|
||||
child: Center(
|
||||
child: SvgPicture.asset(
|
||||
Assets.svg.arrowRotate2,
|
||||
width: 16,
|
||||
height: 16,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
right: SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: _getIconForState(state),
|
||||
),
|
||||
title: "Exchange history",
|
||||
subTitle: state == StackRestoringStatus.failed
|
||||
? Text(
|
||||
"Something went wrong",
|
||||
style: STextStyles.errorSmall(context),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
@ -448,7 +652,8 @@ class _StackRestoreProgressViewState
|
|||
),
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width - 32,
|
||||
child: TextButton(
|
||||
child: !isDesktop
|
||||
? TextButton(
|
||||
onPressed: () async {
|
||||
if (_success) {
|
||||
Navigator.of(context).pop();
|
||||
|
@ -469,6 +674,32 @@ class _StackRestoreProgressViewState
|
|||
.buttonTextPrimary,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
_success
|
||||
? PrimaryButton(
|
||||
width: 248,
|
||||
desktopMed: true,
|
||||
enabled: true,
|
||||
label: "Done",
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
)
|
||||
: SecondaryButton(
|
||||
width: 248,
|
||||
desktopMed: true,
|
||||
enabled: true,
|
||||
label: "Cancel restore process",
|
||||
onPressed: () async {
|
||||
if (await _requestCancel()) {
|
||||
await _cancel();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -11,6 +11,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|||
import 'package:stackwallet/utilities/enums/stack_restoring_status.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/loading_indicator.dart';
|
||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||
|
||||
|
@ -68,13 +69,16 @@ class _RestoringWalletCardState extends ConsumerState<RestoringWalletCard> {
|
|||
final coin = ref.watch(provider.select((value) => value.coin));
|
||||
final restoringStatus =
|
||||
ref.watch(provider.select((value) => value.restoringState));
|
||||
return RestoringItemCard(
|
||||
return !Util.isDesktop
|
||||
? RestoringItemCard(
|
||||
left: SizedBox(
|
||||
width: 32,
|
||||
height: 32,
|
||||
child: RoundedContainer(
|
||||
padding: const EdgeInsets.all(0),
|
||||
color: Theme.of(context).extension<StackColors>()!.colorForCoin(coin),
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.colorForCoin(coin),
|
||||
child: Center(
|
||||
child: SvgPicture.asset(
|
||||
Assets.svg.iconFor(
|
||||
|
@ -202,6 +206,150 @@ class _RestoringWalletCardState extends ConsumerState<RestoringWalletCard> {
|
|||
),
|
||||
)
|
||||
: null,
|
||||
)
|
||||
: RoundedContainer(
|
||||
padding: EdgeInsets.all(0),
|
||||
color: Theme.of(context).extension<StackColors>()!.popupBG,
|
||||
borderColor: Theme.of(context).extension<StackColors>()!.background,
|
||||
child: RestoringItemCard(
|
||||
left: SizedBox(
|
||||
width: 32,
|
||||
height: 32,
|
||||
child: RoundedContainer(
|
||||
padding: const EdgeInsets.all(0),
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.colorForCoin(coin),
|
||||
child: Center(
|
||||
child: SvgPicture.asset(
|
||||
Assets.svg.iconFor(
|
||||
coin: coin,
|
||||
),
|
||||
height: 20,
|
||||
width: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
onRightTapped: restoringStatus == StackRestoringStatus.failed
|
||||
? () async {
|
||||
final manager = ref.read(provider).manager!;
|
||||
|
||||
ref.read(stackRestoringUIStateProvider).update(
|
||||
walletId: manager.walletId,
|
||||
restoringStatus: StackRestoringStatus.restoring);
|
||||
|
||||
try {
|
||||
final mnemonicList = await manager.mnemonic;
|
||||
int maxUnusedAddressGap = 20;
|
||||
if (coin == Coin.firo) {
|
||||
maxUnusedAddressGap = 50;
|
||||
}
|
||||
const maxNumberOfIndexesToCheck = 1000;
|
||||
|
||||
if (mnemonicList.isEmpty) {
|
||||
await manager.recoverFromMnemonic(
|
||||
mnemonic: ref.read(provider).mnemonic!,
|
||||
maxUnusedAddressGap: maxUnusedAddressGap,
|
||||
maxNumberOfIndexesToCheck:
|
||||
maxNumberOfIndexesToCheck,
|
||||
height: ref.read(provider).height ?? 0,
|
||||
);
|
||||
} else {
|
||||
await manager.fullRescan(
|
||||
maxUnusedAddressGap,
|
||||
maxNumberOfIndexesToCheck,
|
||||
);
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
final address = await manager.currentReceivingAddress;
|
||||
|
||||
ref.read(stackRestoringUIStateProvider).update(
|
||||
walletId: manager.walletId,
|
||||
restoringStatus: StackRestoringStatus.success,
|
||||
address: address,
|
||||
);
|
||||
}
|
||||
} catch (_) {
|
||||
if (mounted) {
|
||||
ref.read(stackRestoringUIStateProvider).update(
|
||||
walletId: manager.walletId,
|
||||
restoringStatus: StackRestoringStatus.failed,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
: null,
|
||||
right: SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: _getIconForState(
|
||||
ref.watch(provider.select((value) => value.restoringState)),
|
||||
),
|
||||
),
|
||||
title:
|
||||
"${ref.watch(provider.select((value) => value.walletName))} (${coin.ticker})",
|
||||
subTitle: restoringStatus == StackRestoringStatus.failed
|
||||
? Text(
|
||||
"Unable to restore. Tap icon to retry.",
|
||||
style: STextStyles.errorSmall(context),
|
||||
)
|
||||
: ref.watch(provider.select((value) => value.address)) != null
|
||||
? Text(
|
||||
ref.watch(provider.select((value) => value.address))!,
|
||||
style: STextStyles.infoSmall(context),
|
||||
)
|
||||
: null,
|
||||
button: restoringStatus == StackRestoringStatus.failed
|
||||
? Container(
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.buttonBackSecondary,
|
||||
borderRadius: BorderRadius.circular(
|
||||
1000,
|
||||
),
|
||||
),
|
||||
child: RawMaterialButton(
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
splashColor: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.highlight,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
1000,
|
||||
),
|
||||
),
|
||||
onPressed: () async {
|
||||
final mnemonic = ref.read(provider).mnemonic;
|
||||
|
||||
if (mnemonic != null) {
|
||||
Navigator.of(context).push(
|
||||
RouteGenerator.getRoute(
|
||||
builder: (_) => RecoverPhraseView(
|
||||
walletName: ref.read(provider).walletName,
|
||||
mnemonic: mnemonic.split(" "),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Text(
|
||||
"Show recovery phrase",
|
||||
style: STextStyles.infoSmall(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:flutter_svg/flutter_svg.dart';
|
|||
import 'package:intl/intl.dart';
|
||||
import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/create_backup_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/enable_backup_dialog.dart';
|
||||
import 'package:stackwallet/providers/global/locale_provider.dart';
|
||||
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
||||
|
@ -13,7 +14,9 @@ import 'package:stackwallet/utilities/enums/backup_frequency_type.dart';
|
|||
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/draggable_switch_button.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 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
|
@ -36,7 +39,6 @@ class BackupRestoreSettings extends ConsumerStatefulWidget {
|
|||
class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
|
||||
late bool createBackup = false;
|
||||
late bool restoreBackup = false;
|
||||
// late bool isEnabledAutoBackup;
|
||||
|
||||
final toggleController = DSBController();
|
||||
|
||||
|
@ -91,13 +93,25 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
|
|||
);
|
||||
}
|
||||
|
||||
Future<void> createAutoBackup() async {
|
||||
await showDialog<dynamic>(
|
||||
context: context,
|
||||
useSafeArea: false,
|
||||
barrierDismissible: true,
|
||||
builder: (context) {
|
||||
return CreateAutoBackup();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> attemptDisable() async {
|
||||
final result = await showDialog<bool?>(
|
||||
context: context,
|
||||
useSafeArea: false,
|
||||
barrierDismissible: true,
|
||||
builder: (context) {
|
||||
return StackDialog(
|
||||
return !Util.isDesktop
|
||||
? StackDialog(
|
||||
title: "Disable Auto Backup",
|
||||
message:
|
||||
"You are turning off Auto Backup. You can turn it back on at any time. Your previous Auto Backup file will not be deleted. Remember to backup your wallets manually so you don't lose important information.",
|
||||
|
@ -108,8 +122,9 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
|
|||
child: Text(
|
||||
"Back",
|
||||
style: STextStyles.button(context).copyWith(
|
||||
color:
|
||||
Theme.of(context).extension<StackColors>()!.accentColorDark,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
|
@ -127,11 +142,70 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
|
|||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
setState(() {
|
||||
ref.watch(prefsChangeNotifierProvider).isAutoBackupEnabled =
|
||||
false;
|
||||
ref
|
||||
.watch(prefsChangeNotifierProvider)
|
||||
.isAutoBackupEnabled = false;
|
||||
});
|
||||
},
|
||||
),
|
||||
)
|
||||
: DesktopDialog(
|
||||
maxHeight: 270,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 20, horizontal: 32),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Disable Auto Backup",
|
||||
style: STextStyles.desktopH3(context),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(
|
||||
width: 600,
|
||||
child: Text(
|
||||
"You are turning off Auto Backup. You can turn it back on at any time. "
|
||||
"Your previous Auto Backup file will not be deleted. Remember to backup your wallets "
|
||||
"manually so you don't lose important information.",
|
||||
style: STextStyles.desktopTextSmall(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textDark3,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SecondaryButton(
|
||||
width: 248,
|
||||
desktopMed: true,
|
||||
enabled: true,
|
||||
label: "Back",
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
PrimaryButton(
|
||||
width: 248,
|
||||
desktopMed: true,
|
||||
enabled: true,
|
||||
label: "Disable",
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
setState(() {
|
||||
ref
|
||||
.watch(prefsChangeNotifierProvider)
|
||||
.isAutoBackupEnabled = false;
|
||||
});
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -207,12 +281,27 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
|
|||
child: RoundedWhiteContainer(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.svg.backupAuto,
|
||||
width: 48,
|
||||
height: 48,
|
||||
),
|
||||
isEnabledAutoBackup
|
||||
? SvgPicture.asset(
|
||||
Assets.svg.enableButton,
|
||||
)
|
||||
: SvgPicture.asset(
|
||||
Assets.svg.disableButton,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Row(
|
||||
children: [
|
||||
|
@ -338,7 +427,9 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
|
|||
desktopMed: true,
|
||||
width: 190,
|
||||
label: "Edit auto backup",
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
createAutoBackup();
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
|
@ -362,12 +453,15 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
|
|||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: SvgPicture.asset(
|
||||
Assets.svg.backupAdd,
|
||||
width: 48,
|
||||
height: 48,
|
||||
alignment: Alignment.topLeft,
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Row(
|
||||
children: [
|
||||
|
@ -441,12 +535,15 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
|
|||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: SvgPicture.asset(
|
||||
Assets.svg.backupRestore,
|
||||
width: 48,
|
||||
height: 48,
|
||||
alignment: Alignment.topLeft,
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Row(
|
||||
children: [
|
||||
|
|
|
@ -573,7 +573,9 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
|
|||
label: "Cancel",
|
||||
onPressed: () {
|
||||
int count = 0;
|
||||
Navigator.of(context).popUntil((_) => count++ >= 2);
|
||||
!isEnabledAutoBackup
|
||||
? Navigator.of(context).popUntil((_) => count++ >= 2)
|
||||
: Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
),
|
||||
|
|
|
@ -69,6 +69,7 @@ class _SVG {
|
|||
String get circleLanguage => "assets/svg/language-circle.svg";
|
||||
String get circleDollarSign => "assets/svg/dollar-sign-circle.svg";
|
||||
String get circleLock => "assets/svg/lock-circle.svg";
|
||||
String get enableButton => "assets/svg/enabled-button.svg";
|
||||
String get disableButton => "assets/svg/Button.svg";
|
||||
String get polygon => "assets/svg/Polygon.svg";
|
||||
String get personaIncognito => "assets/svg/persona-incognito-1.svg";
|
||||
|
|
|
@ -298,6 +298,7 @@ flutter:
|
|||
- assets/svg/persona-easy-1.svg
|
||||
- assets/svg/persona-incognito-1.svg
|
||||
- assets/svg/Button.svg
|
||||
- assets/svg/enabled-button.svg
|
||||
- assets/svg/lock-circle.svg
|
||||
- assets/svg/dollar-sign-circle.svg
|
||||
- assets/svg/language-circle.svg
|
||||
|
|
Loading…
Reference in a new issue