mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-12 09:27:01 +00:00
WIP: wallet will be deleted dialog
This commit is contained in:
parent
c9e2c4abb7
commit
78186358b9
4 changed files with 369 additions and 85 deletions
|
@ -0,0 +1,195 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.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';
|
||||
|
||||
class DeleteWalletKeysPopup extends ConsumerStatefulWidget {
|
||||
const DeleteWalletKeysPopup({
|
||||
Key? key,
|
||||
required this.walletId,
|
||||
required this.words,
|
||||
}) : super(key: key);
|
||||
|
||||
final String walletId;
|
||||
final List<String> words;
|
||||
|
||||
static const String routeName = "/desktopDeleteWalletKeysPopup";
|
||||
|
||||
@override
|
||||
ConsumerState<DeleteWalletKeysPopup> createState() =>
|
||||
_DeleteWalletKeysPopup();
|
||||
}
|
||||
|
||||
class _DeleteWalletKeysPopup extends ConsumerState<DeleteWalletKeysPopup> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DesktopDialog(
|
||||
maxWidth: 614,
|
||||
maxHeight: double.infinity,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 32,
|
||||
),
|
||||
child: Text(
|
||||
"Wallet keys",
|
||||
style: STextStyles.desktopH3(context),
|
||||
),
|
||||
),
|
||||
DesktopDialogCloseButton(
|
||||
onPressedOverride: () {
|
||||
int count = 0;
|
||||
Navigator.of(context).popUntil((_) => count++ >= 2);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 28,
|
||||
),
|
||||
Text(
|
||||
"Recovery phrase",
|
||||
style: STextStyles.desktopTextMedium(context),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 32,
|
||||
),
|
||||
child: Text(
|
||||
"Please write down your recovery phrase in the correct order and save it to keep your funds secure. You will also be asked to verify the words on the next screen.",
|
||||
style: STextStyles.desktopTextExtraExtraSmall(context),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 32,
|
||||
),
|
||||
child: MnemonicTable(
|
||||
words: widget.words,
|
||||
isDesktop: true,
|
||||
itemBorderColor: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.buttonBackSecondary,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 32,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: PrimaryButton(
|
||||
label: "Continue",
|
||||
onPressed: () async {
|
||||
int count = 0;
|
||||
Navigator.of(context).popUntil((_) => count++ >= 2);
|
||||
|
||||
unawaited(
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return DesktopDialog(
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
DesktopDialogCloseButton(
|
||||
onPressedOverride: () {
|
||||
int count = 0;
|
||||
Navigator.of(context)
|
||||
.popUntil((_) => count++ >= 2);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
"Thanks! "
|
||||
"\n\nYour wallet will be deleted.",
|
||||
style: STextStyles.desktopH2(context),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
SecondaryButton(
|
||||
width: 250,
|
||||
buttonHeight: ButtonHeight.xl,
|
||||
label: "Cancel",
|
||||
onPressed: () {
|
||||
int count = 0;
|
||||
Navigator.of(context)
|
||||
.popUntil(
|
||||
(_) => count++ >= 2);
|
||||
}),
|
||||
const SizedBox(width: 16),
|
||||
PrimaryButton(
|
||||
width: 250,
|
||||
buttonHeight: ButtonHeight.xl,
|
||||
label: "Continue",
|
||||
onPressed: () async {
|
||||
// final walletsInstance =
|
||||
// ref.read(walletsChangeNotifierProvider);
|
||||
// await ref
|
||||
// .read(walletsServiceChangeNotifierProvider)
|
||||
// .deleteWallet(walletId, true);
|
||||
//
|
||||
// if (mounted) {
|
||||
// Navigator.of(context).popUntil(
|
||||
// ModalRoute.withName(HomeView.routeName));
|
||||
// }
|
||||
|
||||
// // wait for widget tree to dispose of any widgets watching the manager
|
||||
// await Future<void>.delayed(const Duration(seconds: 1));
|
||||
// walletsInstance.removeWallet(walletId: walletId);
|
||||
}),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 32,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.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/rounded_container.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
import 'delete_wallet_keys_popup.dart';
|
||||
|
||||
class DesktopAttentionDeleteWallet extends ConsumerStatefulWidget {
|
||||
const DesktopAttentionDeleteWallet({
|
||||
Key? key,
|
||||
required this.walletId,
|
||||
}) : super(key: key);
|
||||
|
||||
final String walletId;
|
||||
|
||||
static const String routeName = "/desktopAttentionDeleteWallet";
|
||||
|
||||
@override
|
||||
ConsumerState<DesktopAttentionDeleteWallet> createState() =>
|
||||
_DesktopAttentionDeleteWallet();
|
||||
}
|
||||
|
||||
class _DesktopAttentionDeleteWallet
|
||||
extends ConsumerState<DesktopAttentionDeleteWallet> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DesktopDialog(
|
||||
maxWidth: 610,
|
||||
maxHeight: 530,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
DesktopDialogCloseButton(
|
||||
onPressedOverride: () {
|
||||
int count = 0;
|
||||
Navigator.of(context).popUntil((_) => count++ >= 2);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 26),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Attention!",
|
||||
style: STextStyles.desktopH2(context),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
RoundedContainer(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.snackBarBackError,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Text(
|
||||
"You are going to permanently delete you wallet.\n\nIf you delete your wallet, "
|
||||
"the only way you can have access to your funds is by using your backup key."
|
||||
"\n\nStack Wallet does not keep nor is able to restore your backup key or your wallet."
|
||||
"\n\nPLEASE SAVE YOUR BACKUP KEY.",
|
||||
style: STextStyles.desktopTextExtraExtraSmall(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textDark3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SecondaryButton(
|
||||
width: 250,
|
||||
buttonHeight: ButtonHeight.xl,
|
||||
label: "Cancel",
|
||||
onPressed: () {
|
||||
int count = 0;
|
||||
Navigator.of(context).popUntil((_) => count++ >= 2);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
PrimaryButton(
|
||||
width: 250,
|
||||
buttonHeight: ButtonHeight.xl,
|
||||
label: "View Backup Key",
|
||||
onPressed: () async {
|
||||
final words = await ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManager(widget.walletId)
|
||||
.mnemonic;
|
||||
|
||||
await Navigator.of(context)
|
||||
.pushNamed(DeleteWalletKeysPopup.routeName,
|
||||
arguments: Tuple2(
|
||||
widget.walletId,
|
||||
words,
|
||||
));
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
|
@ -12,7 +13,6 @@ 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/rounded_container.dart';
|
||||
import 'package:stackwallet/widgets/stack_text_field.dart';
|
||||
|
||||
import '../../../../../providers/desktop/storage_crypto_handler_provider.dart';
|
||||
|
@ -41,89 +41,6 @@ class _DesktopDeleteWalletDialog
|
|||
bool hidePassword = true;
|
||||
bool _continueEnabled = false;
|
||||
|
||||
Future<void> attentionDelete() async {
|
||||
await showDialog<dynamic>(
|
||||
context: context,
|
||||
useSafeArea: false,
|
||||
barrierDismissible: true,
|
||||
builder: (context) => DesktopDialog(
|
||||
maxWidth: 610,
|
||||
maxHeight: 530,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
DesktopDialogCloseButton(
|
||||
onPressedOverride: () {
|
||||
int count = 0;
|
||||
Navigator.of(context).popUntil((_) => count++ >= 2);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 26),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Attention!",
|
||||
style: STextStyles.desktopH2(context),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
RoundedContainer(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.snackBarBackError,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Text(
|
||||
"You are going to permanently delete you wallet.\n\nIf you delete your wallet, "
|
||||
"the only way you can have access to your funds is by using your backup key."
|
||||
"\n\nStack Wallet does not keep nor is able to restore your backup key or your wallet."
|
||||
"\n\nPLEASE SAVE YOUR BACKUP KEY.",
|
||||
style: STextStyles.desktopTextExtraExtraSmall(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textDark3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SecondaryButton(
|
||||
width: 250,
|
||||
buttonHeight: ButtonHeight.xl,
|
||||
label: "Cancel",
|
||||
onPressed: () {
|
||||
int count = 0;
|
||||
Navigator.of(context).popUntil((_) => count++ >= 2);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
PrimaryButton(
|
||||
width: 250,
|
||||
buttonHeight: ButtonHeight.xl,
|
||||
label: "View Backup Key",
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
passwordController = TextEditingController();
|
||||
|
@ -273,7 +190,10 @@ class _DesktopDeleteWalletDialog
|
|||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
|
||||
attentionDelete();
|
||||
await Navigator.of(context).pushNamed(
|
||||
DesktopAttentionDeleteWallet.routeName,
|
||||
arguments: widget.walletId,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
unawaited(
|
||||
|
|
|
@ -92,6 +92,8 @@ import 'package:stackwallet/pages_desktop_specific/home/desktop_home_view.dart';
|
|||
import 'package:stackwallet/pages_desktop_specific/home/desktop_settings_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/my_stack_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/desktop_wallet_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/delete_wallet_keys_popup.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/desktop_delete_wallet_dialog.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/qr_code_desktop_popup_content.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/wallet_keys_desktop_popup.dart';
|
||||
|
@ -1193,6 +1195,51 @@ class RouteGenerator {
|
|||
}
|
||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
case DesktopAttentionDeleteWallet.routeName:
|
||||
if (args is String) {
|
||||
return FadePageRoute(
|
||||
DesktopAttentionDeleteWallet(
|
||||
walletId: args,
|
||||
),
|
||||
RouteSettings(
|
||||
name: settings.name,
|
||||
),
|
||||
);
|
||||
// return getRoute(
|
||||
// shouldUseMaterialRoute: useMaterialPageRoute,
|
||||
// builder: (_) => WalletKeysDesktopPopup(
|
||||
// words: args,
|
||||
// ),
|
||||
// settings: RouteSettings(
|
||||
// name: settings.name,
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
case DeleteWalletKeysPopup.routeName:
|
||||
if (args is Tuple2<String, List<String>>) {
|
||||
return FadePageRoute(
|
||||
DeleteWalletKeysPopup(
|
||||
walletId: args.item1,
|
||||
words: args.item2,
|
||||
),
|
||||
RouteSettings(
|
||||
name: settings.name,
|
||||
),
|
||||
);
|
||||
// return getRoute(
|
||||
// shouldUseMaterialRoute: useMaterialPageRoute,
|
||||
// builder: (_) => WalletKeysDesktopPopup(
|
||||
// words: args,
|
||||
// ),
|
||||
// settings: RouteSettings(
|
||||
// name: settings.name,
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
case QRCodeDesktopPopupContent.routeName:
|
||||
if (args is String) {
|
||||
return FadePageRoute(
|
||||
|
|
Loading…
Reference in a new issue