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: | run: |
cargo install cargo-ndk cargo install cargo-ndk
rustup target add x86_64-unknown-linux-gnu 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 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 debhelper libclang-dev cargo rustc opencl-headers libssl-dev ocl-icd-opencl-dev
sudo apt install -y libc6-dev-i386 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:flutter/material.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/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'; import 'package:stackwallet/widgets/stack_dialog.dart';
class CancelStackRestoreDialog extends StatelessWidget { class CancelStackRestoreDialog extends StatelessWidget {
@ -14,38 +19,95 @@ class CancelStackRestoreDialog extends StatelessWidget {
onWillPop: () async { onWillPop: () async {
return false; return false;
}, },
child: StackDialog( child: !Util.isDesktop
title: "Cancel restore process", ? StackDialog(
message: title: "Cancel restore process",
"Cancelling will revert any changes that may have been applied", message:
leftButton: TextButton( "Cancelling will revert any changes that may have been applied",
style: Theme.of(context) leftButton: TextButton(
.extension<StackColors>()! style: Theme.of(context)
.getSecondaryEnabledButtonColor(context), .extension<StackColors>()!
child: Text( .getSecondaryEnabledButtonColor(context),
"Back", child: Text(
style: STextStyles.itemSubtitle12(context), "Back",
), style: STextStyles.itemSubtitle12(context),
onPressed: () { ),
Navigator.of(context).pop(false); onPressed: () {
}, Navigator.of(context).pop(false);
), },
rightButton: TextButton( ),
style: Theme.of(context) rightButton: TextButton(
.extension<StackColors>()! style: Theme.of(context)
.getPrimaryEnabledButtonColor(context), .extension<StackColors>()!
child: Text( .getPrimaryEnabledButtonColor(context),
"Yes, cancel", child: Text(
style: STextStyles.itemSubtitle12(context).copyWith( "Yes, cancel",
color: style: STextStyles.itemSubtitle12(context).copyWith(
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);
},
)
],
),
],
),
),
), ),
),
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/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/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/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/route_generator.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.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/conditional_parent.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.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/loading_indicator.dart'; import 'package:stackwallet/widgets/loading_indicator.dart';
import 'package:stackwallet/widgets/stack_text_field.dart'; import 'package:stackwallet/widgets/stack_text_field.dart';
import 'package:tuple/tuple.dart'; import 'package:tuple/tuple.dart';
import '../../../../widgets/desktop/desktop_dialog_close_button.dart';
class RestoreFromFileView extends ConsumerStatefulWidget { class RestoreFromFileView extends ConsumerStatefulWidget {
const RestoreFromFileView({Key? key}) : super(key: key); const RestoreFromFileView({Key? key}) : super(key: key);
@ -48,17 +48,6 @@ class _RestoreFromFileViewState extends ConsumerState<RestoreFromFileView> {
bool hidePassword = true; bool hidePassword = true;
Future<void> restoreBackupPopup(BuildContext context) async {
// await showDialog<dynamic>(
// context: context,
// useSafeArea: false,
// barrierDismissible: true,
// builder: (context) {
// return const RestoreBackupDialog();
// },
// );
}
@override @override
void initState() { void initState() {
stackFileSystem = StackFileSystem(); stackFileSystem = StackFileSystem();
@ -237,7 +226,7 @@ class _RestoreFromFileViewState extends ConsumerState<RestoreFromFileView> {
enableSuggestions: false, enableSuggestions: false,
autocorrect: false, autocorrect: false,
decoration: standardInputDecoration( decoration: standardInputDecoration(
"Enter password", "Enter passphrase",
passwordFocusNode, passwordFocusNode,
context, context,
).copyWith( ).copyWith(
@ -534,7 +523,7 @@ class _RestoreFromFileViewState extends ConsumerState<RestoreFromFileView> {
const EdgeInsets const EdgeInsets
.all(32), .all(32),
child: Text( child: Text(
"Restoring Stack Wallet", "Restore Stack Wallet",
style: STextStyles style: STextStyles
.desktopH3( .desktopH3(
context), context),
@ -546,12 +535,10 @@ class _RestoreFromFileViewState extends ConsumerState<RestoreFromFileView> {
const DesktopDialogCloseButton(), const DesktopDialogCloseButton(),
], ],
), ),
const SizedBox(
height: 30,
),
Padding( Padding(
padding: EdgeInsets padding:
.symmetric( const EdgeInsets
.symmetric(
horizontal: horizontal:
32), 32),
child: child:
@ -560,6 +547,9 @@ class _RestoreFromFileViewState extends ConsumerState<RestoreFromFileView> {
jsonString, 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/utilities/util.dart';
import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.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/icon_widgets/addressbook_icon.dart';
import 'package:stackwallet/widgets/loading_indicator.dart'; import 'package:stackwallet/widgets/loading_indicator.dart';
import 'package:stackwallet/widgets/rounded_container.dart'; import 'package:stackwallet/widgets/rounded_container.dart';
import '../../../../../widgets/desktop/primary_button.dart';
class StackRestoreProgressView extends ConsumerStatefulWidget { class StackRestoreProgressView extends ConsumerStatefulWidget {
const StackRestoreProgressView({ const StackRestoreProgressView({
Key? key, Key? key,
@ -101,6 +104,30 @@ class _StackRestoreProgressViewState
context: context, context: context,
builder: (_) => const CancelStackRestoreDialog(), 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) { if (result is bool && result) {
return true; return true;
} }
@ -130,6 +157,7 @@ class _StackRestoreProgressViewState
} }
bool _success = false; bool _success = false;
bool pendingCancel = false;
Future<bool> _onWillPop() async { Future<bool> _onWillPop() async {
if (_success) { if (_success) {
@ -241,7 +269,7 @@ class _StackRestoreProgressViewState
left: 4, left: 4,
top: 4, top: 4,
right: 4, right: 4,
bottom: 0, bottom: 4,
), ),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -257,40 +285,84 @@ class _StackRestoreProgressViewState
builder: (_, ref, __) { builder: (_, ref, __) {
final state = ref.watch(stackRestoringUIStateProvider final state = ref.watch(stackRestoringUIStateProvider
.select((value) => value.preferences)); .select((value) => value.preferences));
return RestoringItemCard( return !isDesktop
left: SizedBox( ? RestoringItemCard(
width: 32, left: SizedBox(
height: 32, width: 32,
child: RoundedContainer( height: 32,
padding: const EdgeInsets.all(0), child: RoundedContainer(
color: Theme.of(context) padding: const EdgeInsets.all(0),
.extension<StackColors>()! color: Theme.of(context)
.buttonBackSecondary, .extension<StackColors>()!
child: Center( .buttonBackSecondary,
child: SvgPicture.asset( child: Center(
Assets.svg.gear, child: SvgPicture.asset(
width: 16, Assets.svg.gear,
height: 16, width: 16,
color: Theme.of(context) height: 16,
.extension<StackColors>()! color: Theme.of(context)
.accentColorDark, .extension<StackColors>()!
.accentColorDark,
),
),
),
), ),
), right: SizedBox(
), width: 20,
), height: 20,
right: SizedBox( child: _getIconForState(state),
width: 20, ),
height: 20, title: "Preferences",
child: _getIconForState(state), subTitle: state == StackRestoringStatus.failed
), ? Text(
title: "Preferences", "Something went wrong",
subTitle: state == StackRestoringStatus.failed style: STextStyles.errorSmall(context),
? Text( )
"Something went wrong", : null,
style: STextStyles.errorSmall(context), )
) : RoundedContainer(
: null, 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( const SizedBox(
@ -300,39 +372,82 @@ class _StackRestoreProgressViewState
builder: (_, ref, __) { builder: (_, ref, __) {
final state = ref.watch(stackRestoringUIStateProvider final state = ref.watch(stackRestoringUIStateProvider
.select((value) => value.addressBook)); .select((value) => value.addressBook));
return RestoringItemCard( return !isDesktop
left: SizedBox( ? RestoringItemCard(
width: 32, left: SizedBox(
height: 32, width: 32,
child: RoundedContainer( height: 32,
padding: const EdgeInsets.all(0), child: RoundedContainer(
color: Theme.of(context) padding: const EdgeInsets.all(0),
.extension<StackColors>()! color: Theme.of(context)
.buttonBackSecondary, .extension<StackColors>()!
child: Center( .buttonBackSecondary,
child: AddressBookIcon( child: Center(
width: 16, child: AddressBookIcon(
height: 16, width: 16,
color: Theme.of(context) height: 16,
.extension<StackColors>()! color: Theme.of(context)
.accentColorDark, .extension<StackColors>()!
.accentColorDark,
),
),
),
), ),
), right: SizedBox(
), width: 20,
), height: 20,
right: SizedBox( child: _getIconForState(state),
width: 20, ),
height: 20, title: "Address book",
child: _getIconForState(state), subTitle: state == StackRestoringStatus.failed
), ? Text(
title: "Address book", "Something went wrong",
subTitle: state == StackRestoringStatus.failed style: STextStyles.errorSmall(context),
? Text( )
"Something went wrong", : null,
style: STextStyles.errorSmall(context), )
) : RoundedContainer(
: null, 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( const SizedBox(
@ -342,40 +457,83 @@ class _StackRestoreProgressViewState
builder: (_, ref, __) { builder: (_, ref, __) {
final state = ref.watch(stackRestoringUIStateProvider final state = ref.watch(stackRestoringUIStateProvider
.select((value) => value.nodes)); .select((value) => value.nodes));
return RestoringItemCard( return !isDesktop
left: SizedBox( ? RestoringItemCard(
width: 32, left: SizedBox(
height: 32, width: 32,
child: RoundedContainer( height: 32,
padding: const EdgeInsets.all(0), child: RoundedContainer(
color: Theme.of(context) padding: const EdgeInsets.all(0),
.extension<StackColors>()! color: Theme.of(context)
.buttonBackSecondary, .extension<StackColors>()!
child: Center( .buttonBackSecondary,
child: SvgPicture.asset( child: Center(
Assets.svg.node, child: SvgPicture.asset(
width: 16, Assets.svg.node,
height: 16, width: 16,
color: Theme.of(context) height: 16,
.extension<StackColors>()! color: Theme.of(context)
.accentColorDark, .extension<StackColors>()!
.accentColorDark,
),
),
),
), ),
), right: SizedBox(
), width: 20,
), height: 20,
right: SizedBox( child: _getIconForState(state),
width: 20, ),
height: 20, title: "Nodes",
child: _getIconForState(state), subTitle: state == StackRestoringStatus.failed
), ? Text(
title: "Nodes", "Something went wrong",
subTitle: state == StackRestoringStatus.failed style: STextStyles.errorSmall(context),
? Text( )
"Something went wrong", : null,
style: STextStyles.errorSmall(context), )
) : RoundedContainer(
: null, 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( const SizedBox(
@ -385,40 +543,86 @@ class _StackRestoreProgressViewState
builder: (_, ref, __) { builder: (_, ref, __) {
final state = ref.watch(stackRestoringUIStateProvider final state = ref.watch(stackRestoringUIStateProvider
.select((value) => value.trades)); .select((value) => value.trades));
return RestoringItemCard( return !isDesktop
left: SizedBox( ? Container(
width: 32, child: RestoringItemCard(
height: 32, left: SizedBox(
child: RoundedContainer( width: 32,
padding: const EdgeInsets.all(0), height: 32,
color: Theme.of(context) child: RoundedContainer(
.extension<StackColors>()! padding: const EdgeInsets.all(0),
.buttonBackSecondary, color: Theme.of(context)
child: Center( .extension<StackColors>()!
child: SvgPicture.asset( .buttonBackSecondary,
Assets.svg.arrowRotate2, child: Center(
width: 16, child: SvgPicture.asset(
height: 16, Assets.svg.arrowRotate2,
color: Theme.of(context) width: 16,
.extension<StackColors>()! height: 16,
.accentColorDark, 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,
), ),
), )
), : RoundedContainer(
), padding: EdgeInsets.all(0),
right: SizedBox( color: Theme.of(context)
width: 20, .extension<StackColors>()!
height: 20, .popupBG,
child: _getIconForState(state), borderColor: Theme.of(context)
), .extension<StackColors>()!
title: "Exchange history", .background,
subTitle: state == StackRestoringStatus.failed child: RestoringItemCard(
? Text( left: SizedBox(
"Something went wrong", width: 32,
style: STextStyles.errorSmall(context), height: 32,
) child: RoundedContainer(
: null, 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( const SizedBox(
@ -448,28 +652,55 @@ class _StackRestoreProgressViewState
), ),
SizedBox( SizedBox(
width: MediaQuery.of(context).size.width - 32, width: MediaQuery.of(context).size.width - 32,
child: TextButton( child: !isDesktop
onPressed: () async { ? TextButton(
if (_success) { onPressed: () async {
Navigator.of(context).pop(); if (_success) {
} else { Navigator.of(context).pop();
if (await _requestCancel()) { } else {
await _cancel(); if (await _requestCancel()) {
} await _cancel();
} }
}, }
style: Theme.of(context) },
.extension<StackColors>()! style: Theme.of(context)
.getPrimaryEnabledButtonColor(context), .extension<StackColors>()!
child: Text( .getPrimaryEnabledButtonColor(context),
_success ? "OK" : "Cancel restore process", child: Text(
style: STextStyles.button(context).copyWith( _success ? "OK" : "Cancel restore process",
color: Theme.of(context) style: STextStyles.button(context).copyWith(
.extension<StackColors>()! color: Theme.of(context)
.buttonTextPrimary, .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/enums/stack_restoring_status.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/widgets/loading_indicator.dart'; import 'package:stackwallet/widgets/loading_indicator.dart';
import 'package:stackwallet/widgets/rounded_container.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 coin = ref.watch(provider.select((value) => value.coin));
final restoringStatus = final restoringStatus =
ref.watch(provider.select((value) => value.restoringState)); ref.watch(provider.select((value) => value.restoringState));
return RestoringItemCard( return !Util.isDesktop
left: SizedBox( ? RestoringItemCard(
width: 32, left: SizedBox(
height: 32, width: 32,
child: RoundedContainer( height: 32,
padding: const EdgeInsets.all(0), child: RoundedContainer(
color: Theme.of(context).extension<StackColors>()!.colorForCoin(coin), padding: const EdgeInsets.all(0),
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) color: Theme.of(context)
.extension<StackColors>()! .extension<StackColors>()!
.buttonBackSecondary, .colorForCoin(coin),
borderRadius: BorderRadius.circular( child: Center(
1000, child: SvgPicture.asset(
), Assets.svg.iconFor(
), coin: coin,
child: RawMaterialButton( ),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, height: 20,
splashColor: width: 20,
Theme.of(context).extension<StackColors>()!.highlight,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
1000,
), ),
), ),
onPressed: () async { ),
final mnemonic = ref.read(provider).mnemonic; ),
onRightTapped: restoringStatus == StackRestoringStatus.failed
? () async {
final manager = ref.read(provider).manager!;
if (mnemonic != null) { ref.read(stackRestoringUIStateProvider).update(
Navigator.of(context).push( walletId: manager.walletId,
RouteGenerator.getRoute( restoringStatus: StackRestoringStatus.restoring);
builder: (_) => RecoverPhraseView(
walletName: ref.read(provider).walletName, try {
mnemonic: mnemonic.split(" "), 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;
},
child: Padding( if (mnemonic != null) {
padding: const EdgeInsets.symmetric(horizontal: 8.0), Navigator.of(context).push(
child: Text( RouteGenerator.getRoute(
"Show recovery phrase", builder: (_) => RecoverPhraseView(
style: STextStyles.infoSmall(context).copyWith( walletName: ref.read(provider).walletName,
color: Theme.of(context) mnemonic: mnemonic.split(" "),
.extension<StackColors>()! ),
.accentColorDark), ),
);
}
},
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,
),
), ),
), ),
), ),
) onRightTapped: restoringStatus == StackRestoringStatus.failed
: null, ? () 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: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/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/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/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/locale_provider.dart';
import 'package:stackwallet/providers/global/prefs_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/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/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/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/rounded_white_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart';
@ -36,7 +39,6 @@ class BackupRestoreSettings extends ConsumerStatefulWidget {
class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> { class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
late bool createBackup = false; late bool createBackup = false;
late bool restoreBackup = false; late bool restoreBackup = false;
// late bool isEnabledAutoBackup;
final toggleController = DSBController(); 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 { Future<void> attemptDisable() async {
final result = await showDialog<bool?>( final result = await showDialog<bool?>(
context: context, context: context,
useSafeArea: false, useSafeArea: false,
barrierDismissible: true, barrierDismissible: true,
builder: (context) { builder: (context) {
return StackDialog( return !Util.isDesktop
title: "Disable Auto Backup", ? StackDialog(
message: title: "Disable Auto Backup",
"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.", message:
leftButton: TextButton( "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: Theme.of(context) leftButton: TextButton(
.extension<StackColors>()! style: Theme.of(context)
.getSecondaryEnabledButtonColor(context), .extension<StackColors>()!
child: Text( .getSecondaryEnabledButtonColor(context),
"Back", child: Text(
style: STextStyles.button(context).copyWith( "Back",
color: style: STextStyles.button(context).copyWith(
Theme.of(context).extension<StackColors>()!.accentColorDark, color: Theme.of(context)
), .extension<StackColors>()!
), .accentColorDark,
onPressed: () { ),
Navigator.of(context).pop(); ),
}, onPressed: () {
), Navigator.of(context).pop();
rightButton: TextButton( },
style: Theme.of(context) ),
.extension<StackColors>()! rightButton: TextButton(
.getPrimaryEnabledButtonColor(context), style: Theme.of(context)
child: Text( .extension<StackColors>()!
"Disable", .getPrimaryEnabledButtonColor(context),
style: STextStyles.button(context), child: Text(
), "Disable",
onPressed: () { style: STextStyles.button(context),
Navigator.of(context).pop(); ),
setState(() { onPressed: () {
ref.watch(prefsChangeNotifierProvider).isAutoBackupEnabled = Navigator.of(context).pop();
false; 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) { if (mounted) {
@ -208,10 +282,25 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SvgPicture.asset( Padding(
Assets.svg.backupAuto, padding: const EdgeInsets.all(8.0),
width: 48, child: Row(
height: 48, 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( Center(
child: Row( child: Row(
@ -338,7 +427,9 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
desktopMed: true, desktopMed: true,
width: 190, width: 190,
label: "Edit auto backup", label: "Edit auto backup",
onPressed: () {}, onPressed: () {
createAutoBackup();
},
), ),
], ],
) )
@ -362,11 +453,14 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SvgPicture.asset( Padding(
Assets.svg.backupAdd, padding: const EdgeInsets.all(8.0),
width: 48, child: SvgPicture.asset(
height: 48, Assets.svg.backupAdd,
alignment: Alignment.topLeft, width: 48,
height: 48,
alignment: Alignment.topLeft,
),
), ),
Center( Center(
child: Row( child: Row(
@ -441,11 +535,14 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SvgPicture.asset( Padding(
Assets.svg.backupRestore, padding: const EdgeInsets.all(8.0),
width: 48, child: SvgPicture.asset(
height: 48, Assets.svg.backupRestore,
alignment: Alignment.topLeft, width: 48,
height: 48,
alignment: Alignment.topLeft,
),
), ),
Center( Center(
child: Row( child: Row(

View file

@ -573,7 +573,9 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
label: "Cancel", label: "Cancel",
onPressed: () { onPressed: () {
int count = 0; 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 circleLanguage => "assets/svg/language-circle.svg";
String get circleDollarSign => "assets/svg/dollar-sign-circle.svg"; String get circleDollarSign => "assets/svg/dollar-sign-circle.svg";
String get circleLock => "assets/svg/lock-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 disableButton => "assets/svg/Button.svg";
String get polygon => "assets/svg/Polygon.svg"; String get polygon => "assets/svg/Polygon.svg";
String get personaIncognito => "assets/svg/persona-incognito-1.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-easy-1.svg
- assets/svg/persona-incognito-1.svg - assets/svg/persona-incognito-1.svg
- assets/svg/Button.svg - assets/svg/Button.svg
- assets/svg/enabled-button.svg
- assets/svg/lock-circle.svg - assets/svg/lock-circle.svg
- assets/svg/dollar-sign-circle.svg - assets/svg/dollar-sign-circle.svg
- assets/svg/language-circle.svg - assets/svg/language-circle.svg