mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-23 19:05:51 +00:00
add possibility to skip per wallet migration with warning
This commit is contained in:
parent
808927a0d1
commit
643ef07066
3 changed files with 201 additions and 59 deletions
|
@ -53,6 +53,7 @@ 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/custom_buttons/blue_text_button.dart';
|
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
||||||
import 'package:stackwallet/widgets/custom_loading_overlay.dart';
|
import 'package:stackwallet/widgets/custom_loading_overlay.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_dialog.dart';
|
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||||
import 'package:stackwallet/widgets/wallet_navigation_bar/components/icons/buy_nav_icon.dart';
|
import 'package:stackwallet/widgets/wallet_navigation_bar/components/icons/buy_nav_icon.dart';
|
||||||
|
@ -420,6 +421,33 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
||||||
eventBus: null,
|
eventBus: null,
|
||||||
textColor:
|
textColor:
|
||||||
Theme.of(context).extension<StackColors>()!.textDark,
|
Theme.of(context).extension<StackColors>()!.textDark,
|
||||||
|
actionButton: SecondaryButton(
|
||||||
|
label: "Cancel",
|
||||||
|
onPressed: () async {
|
||||||
|
await showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => StackDialog(
|
||||||
|
title: "Warning!",
|
||||||
|
message: "Skipping this process can completely"
|
||||||
|
" break your wallet. It is only meant to be done in"
|
||||||
|
" emergency situations where the migration fails"
|
||||||
|
" and will not let you continue. Still skip?",
|
||||||
|
leftButton: SecondaryButton(
|
||||||
|
label: "Cancel",
|
||||||
|
onPressed:
|
||||||
|
Navigator.of(context, rootNavigator: true).pop,
|
||||||
|
),
|
||||||
|
rightButton: SecondaryButton(
|
||||||
|
label: "Ok",
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
setState(() => _rescanningOnOpen = false);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
@ -790,7 +818,6 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
||||||
label: "Receive",
|
label: "Receive",
|
||||||
icon: const ReceiveNavIcon(),
|
icon: const ReceiveNavIcon(),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
final coin = ref.read(managerProvider).coin;
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
unawaited(
|
unawaited(
|
||||||
Navigator.of(context).pushNamed(
|
Navigator.of(context).pushNamed(
|
||||||
|
|
|
@ -31,7 +31,11 @@ import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||||
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
||||||
import 'package:stackwallet/widgets/custom_loading_overlay.dart';
|
import 'package:stackwallet/widgets/custom_loading_overlay.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
||||||
|
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||||
|
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
||||||
|
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
||||||
|
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||||
import 'package:stackwallet/widgets/hover_text_field.dart';
|
import 'package:stackwallet/widgets/hover_text_field.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||||
|
|
||||||
|
@ -150,6 +154,83 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
|
||||||
subMessage: "This only needs to run once per wallet",
|
subMessage: "This only needs to run once per wallet",
|
||||||
eventBus: null,
|
eventBus: null,
|
||||||
textColor: Theme.of(context).extension<StackColors>()!.textDark,
|
textColor: Theme.of(context).extension<StackColors>()!.textDark,
|
||||||
|
actionButton: SecondaryButton(
|
||||||
|
label: "Skip",
|
||||||
|
buttonHeight: ButtonHeight.l,
|
||||||
|
onPressed: () async {
|
||||||
|
await showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => DesktopDialog(
|
||||||
|
maxWidth: 500,
|
||||||
|
maxHeight: double.infinity,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 32),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Warning!",
|
||||||
|
style: STextStyles.desktopH3(context),
|
||||||
|
),
|
||||||
|
const DesktopDialogCloseButton(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 32),
|
||||||
|
child: Text(
|
||||||
|
"Skipping this process can completely"
|
||||||
|
" break your wallet. It is only meant to be done in"
|
||||||
|
" emergency situations where the migration fails"
|
||||||
|
" and will not let you continue. Still skip?",
|
||||||
|
style: STextStyles.desktopTextSmall(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 32,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(32),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: SecondaryButton(
|
||||||
|
label: "Cancel",
|
||||||
|
buttonHeight: ButtonHeight.l,
|
||||||
|
onPressed: Navigator.of(context,
|
||||||
|
rootNavigator: true)
|
||||||
|
.pop,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 16,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: PrimaryButton(
|
||||||
|
label: "Ok",
|
||||||
|
buttonHeight: ButtonHeight.l,
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context,
|
||||||
|
rootNavigator: true)
|
||||||
|
.pop();
|
||||||
|
setState(
|
||||||
|
() => _rescanningOnOpen = false);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|
|
@ -5,6 +5,8 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.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/conditional_parent.dart';
|
||||||
import 'package:stackwallet/widgets/loading_indicator.dart';
|
import 'package:stackwallet/widgets/loading_indicator.dart';
|
||||||
|
|
||||||
class CustomLoadingOverlay extends ConsumerStatefulWidget {
|
class CustomLoadingOverlay extends ConsumerStatefulWidget {
|
||||||
|
@ -14,12 +16,14 @@ class CustomLoadingOverlay extends ConsumerStatefulWidget {
|
||||||
this.subMessage,
|
this.subMessage,
|
||||||
required this.eventBus,
|
required this.eventBus,
|
||||||
this.textColor,
|
this.textColor,
|
||||||
|
this.actionButton,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final String message;
|
final String message;
|
||||||
final String? subMessage;
|
final String? subMessage;
|
||||||
final EventBus? eventBus;
|
final EventBus? eventBus;
|
||||||
final Color? textColor;
|
final Color? textColor;
|
||||||
|
final Widget? actionButton;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ConsumerState<CustomLoadingOverlay> createState() =>
|
ConsumerState<CustomLoadingOverlay> createState() =>
|
||||||
|
@ -30,6 +34,7 @@ class _CustomLoadingOverlayState extends ConsumerState<CustomLoadingOverlay> {
|
||||||
double _percent = 0;
|
double _percent = 0;
|
||||||
|
|
||||||
late final StreamSubscription<double>? subscription;
|
late final StreamSubscription<double>? subscription;
|
||||||
|
final bool isDesktop = Util.isDesktop;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -49,68 +54,97 @@ class _CustomLoadingOverlayState extends ConsumerState<CustomLoadingOverlay> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Material(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
color: Colors.transparent,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
child: ConditionalParent(
|
||||||
children: [
|
condition: widget.actionButton != null,
|
||||||
Material(
|
builder: (child) => Stack(
|
||||||
color: Colors.transparent,
|
children: [
|
||||||
child: Center(
|
child,
|
||||||
child: Column(
|
if (isDesktop)
|
||||||
children: [
|
Row(
|
||||||
Text(
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
widget.message,
|
children: [
|
||||||
textAlign: TextAlign.center,
|
Padding(
|
||||||
style: STextStyles.pageTitleH2(context).copyWith(
|
padding: const EdgeInsets.all(16),
|
||||||
color: widget.textColor ??
|
child: SizedBox(
|
||||||
Theme.of(context)
|
width: 100,
|
||||||
.extension<StackColors>()!
|
child: widget.actionButton!,
|
||||||
.loadingOverlayTextColor,
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (!isDesktop)
|
||||||
|
Positioned(
|
||||||
|
bottom: 1,
|
||||||
|
left: 0,
|
||||||
|
right: 1,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(child: widget.actionButton!),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (widget.eventBus != null)
|
),
|
||||||
const SizedBox(
|
],
|
||||||
height: 10,
|
),
|
||||||
),
|
child: Column(
|
||||||
if (widget.eventBus != null)
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
Text(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
"${(_percent * 100).toStringAsFixed(2)}%",
|
children: [
|
||||||
style: STextStyles.pageTitleH2(context).copyWith(
|
Text(
|
||||||
color: widget.textColor ??
|
widget.message,
|
||||||
Theme.of(context)
|
textAlign: TextAlign.center,
|
||||||
.extension<StackColors>()!
|
style: STextStyles.pageTitleH2(context).copyWith(
|
||||||
.loadingOverlayTextColor,
|
color: widget.textColor ??
|
||||||
),
|
Theme.of(context)
|
||||||
),
|
.extension<StackColors>()!
|
||||||
if (widget.subMessage != null)
|
.loadingOverlayTextColor,
|
||||||
const SizedBox(
|
),
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
if (widget.subMessage != null)
|
|
||||||
Text(
|
|
||||||
widget.subMessage!,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: STextStyles.pageTitleH2(context).copyWith(
|
|
||||||
fontSize: 14,
|
|
||||||
color: widget.textColor ??
|
|
||||||
Theme.of(context)
|
|
||||||
.extension<StackColors>()!
|
|
||||||
.loadingOverlayTextColor,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
if (widget.eventBus != null)
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
if (widget.eventBus != null)
|
||||||
|
Text(
|
||||||
|
"${(_percent * 100).toStringAsFixed(2)}%",
|
||||||
|
style: STextStyles.pageTitleH2(context).copyWith(
|
||||||
|
color: widget.textColor ??
|
||||||
|
Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.loadingOverlayTextColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (widget.subMessage != null)
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
if (widget.subMessage != null)
|
||||||
|
Text(
|
||||||
|
widget.subMessage!,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: STextStyles.pageTitleH2(context).copyWith(
|
||||||
|
fontSize: 14,
|
||||||
|
color: widget.textColor ??
|
||||||
|
Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.loadingOverlayTextColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 64,
|
||||||
|
),
|
||||||
|
const Center(
|
||||||
|
child: LoadingIndicator(
|
||||||
|
width: 100,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(
|
),
|
||||||
height: 64,
|
|
||||||
),
|
|
||||||
const Center(
|
|
||||||
child: LoadingIndicator(
|
|
||||||
width: 100,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue