WIP: added border to cards; working on cancel restore

This commit is contained in:
ryleedavis 2022-11-10 17:49:49 -07:00
parent 5f106efa4b
commit dac1337a71
3 changed files with 668 additions and 299 deletions
lib/pages/settings_views/global_settings_view/stack_backup_views

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

@ -19,10 +19,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,
@ -100,6 +103,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;
}
@ -128,6 +155,7 @@ class _StackRestoreProgressViewState
}
bool _success = false;
bool pendingCancel = false;
Future<bool> _onWillPop() async {
if (_success) {
@ -239,7 +267,7 @@ class _StackRestoreProgressViewState
left: 4,
top: 4,
right: 4,
bottom: 0,
bottom: 4,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -255,40 +283,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(
@ -298,39 +370,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(
@ -340,40 +455,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(
@ -383,40 +541,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(
@ -446,28 +650,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,
),
);
}
}