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:
julian 2022-11-11 13:23:24 -06:00
commit bfe1b7e291
10 changed files with 920 additions and 383 deletions

View file

@ -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

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 6.2 KiB

View file

@ -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,38 +19,95 @@ class CancelStackRestoreDialog extends StatelessWidget {
onWillPop: () async {
return false;
},
child: StackDialog(
title: "Cancel restore process",
message:
"Cancelling will revert any changes that may have been applied",
leftButton: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.getSecondaryEnabledButtonColor(context),
child: Text(
"Back",
style: STextStyles.itemSubtitle12(context),
),
onPressed: () {
Navigator.of(context).pop(false);
},
),
rightButton: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.getPrimaryEnabledButtonColor(context),
child: Text(
"Yes, cancel",
style: STextStyles.itemSubtitle12(context).copyWith(
color:
Theme.of(context).extension<StackColors>()!.buttonTextPrimary,
child: !Util.isDesktop
? StackDialog(
title: "Cancel restore process",
message:
"Cancelling will revert any changes that may have been applied",
leftButton: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.getSecondaryEnabledButtonColor(context),
child: Text(
"Back",
style: STextStyles.itemSubtitle12(context),
),
onPressed: () {
Navigator.of(context).pop(false);
},
),
rightButton: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.getPrimaryEnabledButtonColor(context),
child: Text(
"Yes, cancel",
style: STextStyles.itemSubtitle12(context).copyWith(
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);
},
)
],
),
],
),
),
),
),
onPressed: () {
Navigator.of(context).pop(true);
},
),
),
);
}
}

View file

@ -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,12 +535,10 @@ class _RestoreFromFileViewState extends ConsumerState<RestoreFromFileView> {
const DesktopDialogCloseButton(),
],
),
const SizedBox(
height: 30,
),
Padding(
padding: EdgeInsets
.symmetric(
padding:
const EdgeInsets
.symmetric(
horizontal:
32),
child:
@ -560,6 +547,9 @@ class _RestoreFromFileViewState extends ConsumerState<RestoreFromFileView> {
jsonString,
),
),
const SizedBox(
height: 32,
),
],
),
),

View file

@ -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,40 +285,84 @@ class _StackRestoreProgressViewState
builder: (_, ref, __) {
final state = ref.watch(stackRestoringUIStateProvider
.select((value) => value.preferences));
return 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,
return !isDesktop
? 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,
);
right: SizedBox(
width: 20,
height: 20,
child: _getIconForState(state),
),
title: "Preferences",
subTitle: state == StackRestoringStatus.failed
? Text(
"Something went wrong",
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,
),
);
},
),
const SizedBox(
@ -300,39 +372,82 @@ class _StackRestoreProgressViewState
builder: (_, ref, __) {
final state = ref.watch(stackRestoringUIStateProvider
.select((value) => value.addressBook));
return 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,
return !isDesktop
? 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,
);
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,
)
: 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,
),
);
},
),
const SizedBox(
@ -342,40 +457,83 @@ class _StackRestoreProgressViewState
builder: (_, ref, __) {
final state = ref.watch(stackRestoringUIStateProvider
.select((value) => value.nodes));
return 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,
return !isDesktop
? 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,
);
right: SizedBox(
width: 20,
height: 20,
child: _getIconForState(state),
),
title: "Nodes",
subTitle: state == StackRestoringStatus.failed
? Text(
"Something went wrong",
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,40 +543,86 @@ class _StackRestoreProgressViewState
builder: (_, ref, __) {
final state = ref.watch(stackRestoringUIStateProvider
.select((value) => value.trades));
return 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,
return !isDesktop
? Container(
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,
),
),
),
),
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,
);
)
: 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,
),
);
},
),
const SizedBox(
@ -448,28 +652,55 @@ class _StackRestoreProgressViewState
),
SizedBox(
width: MediaQuery.of(context).size.width - 32,
child: TextButton(
onPressed: () async {
if (_success) {
Navigator.of(context).pop();
} else {
if (await _requestCancel()) {
await _cancel();
}
}
},
style: Theme.of(context)
.extension<StackColors>()!
.getPrimaryEnabledButtonColor(context),
child: Text(
_success ? "OK" : "Cancel restore process",
style: STextStyles.button(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.buttonTextPrimary,
),
),
),
child: !isDesktop
? TextButton(
onPressed: () async {
if (_success) {
Navigator.of(context).pop();
} else {
if (await _requestCancel()) {
await _cancel();
}
}
},
style: Theme.of(context)
.extension<StackColors>()!
.getPrimaryEnabledButtonColor(context),
child: Text(
_success ? "OK" : "Cancel restore process",
style: STextStyles.button(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.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();
}
},
),
],
),
),
],
),

View file

@ -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,140 +69,287 @@ 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(
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(
return !Util.isDesktop
? RestoringItemCard(
left: SizedBox(
width: 32,
height: 32,
child: RoundedContainer(
padding: const EdgeInsets.all(0),
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,
.colorForCoin(coin),
child: Center(
child: SvgPicture.asset(
Assets.svg.iconFor(
coin: coin,
),
height: 20,
width: 20,
),
),
onPressed: () async {
final mnemonic = ref.read(provider).mnemonic;
),
),
onRightTapped: restoringStatus == StackRestoringStatus.failed
? () async {
final manager = ref.read(provider).manager!;
if (mnemonic != null) {
Navigator.of(context).push(
RouteGenerator.getRoute(
builder: (_) => RecoverPhraseView(
walletName: ref.read(provider).walletName,
mnemonic: mnemonic.split(" "),
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,
),
),
);
}
},
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),
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,
)
: 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,
),
),
),
),
)
: null,
);
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,
),
);
}
}

View file

@ -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,48 +93,120 @@ 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(
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.",
leftButton: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.getSecondaryEnabledButtonColor(context),
child: Text(
"Back",
style: STextStyles.button(context).copyWith(
color:
Theme.of(context).extension<StackColors>()!.accentColorDark,
),
),
onPressed: () {
Navigator.of(context).pop();
},
),
rightButton: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.getPrimaryEnabledButtonColor(context),
child: Text(
"Disable",
style: STextStyles.button(context),
),
onPressed: () {
Navigator.of(context).pop();
setState(() {
ref.watch(prefsChangeNotifierProvider).isAutoBackupEnabled =
false;
});
},
),
);
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.",
leftButton: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.getSecondaryEnabledButtonColor(context),
child: Text(
"Back",
style: STextStyles.button(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
),
onPressed: () {
Navigator.of(context).pop();
},
),
rightButton: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.getPrimaryEnabledButtonColor(context),
child: Text(
"Disable",
style: STextStyles.button(context),
),
onPressed: () {
Navigator.of(context).pop();
setState(() {
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;
});
},
)
],
),
],
),
),
);
},
);
if (mounted) {
@ -208,10 +282,25 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SvgPicture.asset(
Assets.svg.backupAuto,
width: 48,
height: 48,
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(
@ -338,7 +427,9 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
desktopMed: true,
width: 190,
label: "Edit auto backup",
onPressed: () {},
onPressed: () {
createAutoBackup();
},
),
],
)
@ -362,11 +453,14 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SvgPicture.asset(
Assets.svg.backupAdd,
width: 48,
height: 48,
alignment: Alignment.topLeft,
Padding(
padding: const EdgeInsets.all(8.0),
child: SvgPicture.asset(
Assets.svg.backupAdd,
width: 48,
height: 48,
alignment: Alignment.topLeft,
),
),
Center(
child: Row(
@ -441,11 +535,14 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SvgPicture.asset(
Assets.svg.backupRestore,
width: 48,
height: 48,
alignment: Alignment.topLeft,
Padding(
padding: const EdgeInsets.all(8.0),
child: SvgPicture.asset(
Assets.svg.backupRestore,
width: 48,
height: 48,
alignment: Alignment.topLeft,
),
),
Center(
child: Row(

View file

@ -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();
},
),
),

View file

@ -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";

View file

@ -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