mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 20:09:23 +00:00
desktop delete routing fixes
This commit is contained in:
parent
04b982fb25
commit
f75e4ea2fa
3 changed files with 207 additions and 137 deletions
|
@ -1,13 +1,13 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/desktop_delete_wallet_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/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
|
|
||||||
import 'desktop_delete_wallet_dialog.dart';
|
|
||||||
|
|
||||||
class DeleteWalletButton extends ConsumerStatefulWidget {
|
class DeleteWalletButton extends ConsumerStatefulWidget {
|
||||||
const DeleteWalletButton({
|
const DeleteWalletButton({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
@ -26,8 +26,6 @@ class _DeleteWalletButton extends ConsumerState<DeleteWalletButton> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
walletId = widget.walletId;
|
walletId = widget.walletId;
|
||||||
final managerProvider =
|
|
||||||
ref.read(walletsChangeNotifierProvider).getManagerProvider(walletId);
|
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
@ -38,25 +36,45 @@ class _DeleteWalletButton extends ConsumerState<DeleteWalletButton> {
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(1000),
|
borderRadius: BorderRadius.circular(1000),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
showDialog<void>(
|
final shouldOpenDeleteDialog = await showDialog<bool?>(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierColor: Colors.transparent,
|
||||||
builder: (context) => Navigator(
|
builder: (context) {
|
||||||
initialRoute: DesktopDeleteWalletDialog.routeName,
|
return DeletePopupButton(
|
||||||
onGenerateRoute: RouteGenerator.generateRoute,
|
onTap: () async {
|
||||||
onGenerateInitialRoutes: (_, __) {
|
Navigator.of(context).pop(true);
|
||||||
return [
|
},
|
||||||
RouteGenerator.generateRoute(
|
);
|
||||||
RouteSettings(
|
},
|
||||||
name: DesktopDeleteWalletDialog.routeName,
|
|
||||||
arguments: walletId,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
];
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (shouldOpenDeleteDialog == true) {
|
||||||
|
final result = await showDialog<bool?>(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (context) => Navigator(
|
||||||
|
initialRoute: DesktopDeleteWalletDialog.routeName,
|
||||||
|
onGenerateRoute: RouteGenerator.generateRoute,
|
||||||
|
onGenerateInitialRoutes: (_, __) {
|
||||||
|
return [
|
||||||
|
RouteGenerator.generateRoute(
|
||||||
|
RouteSettings(
|
||||||
|
name: DesktopDeleteWalletDialog.routeName,
|
||||||
|
arguments: walletId,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result == true) {
|
||||||
|
if (mounted) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
|
@ -79,3 +97,54 @@ class _DeleteWalletButton extends ConsumerState<DeleteWalletButton> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DeletePopupButton extends StatefulWidget {
|
||||||
|
const DeletePopupButton({
|
||||||
|
Key? key,
|
||||||
|
this.onTap,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final VoidCallback? onTap;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<DeletePopupButton> createState() => _DeletePopupButtonState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DeletePopupButtonState extends State<DeletePopupButton> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
Positioned(
|
||||||
|
top: 24,
|
||||||
|
left: MediaQuery.of(context).size.width - 234,
|
||||||
|
child: MouseRegion(
|
||||||
|
cursor: SystemMouseCursors.click,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: widget.onTap,
|
||||||
|
child: Container(
|
||||||
|
width: 210,
|
||||||
|
height: 70,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(
|
||||||
|
Constants.size.circularBorderRadius,
|
||||||
|
),
|
||||||
|
color: Colors.red,
|
||||||
|
boxShadow: [
|
||||||
|
Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.standardBoxShadow,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
"Delete",
|
||||||
|
style: STextStyles.desktopButtonSecondaryEnabled(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.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/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/my_stack_view.dart';
|
|
||||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||||
import 'package:stackwallet/providers/global/wallets_service_provider.dart';
|
import 'package:stackwallet/providers/global/wallets_service_provider.dart';
|
||||||
|
import 'package:stackwallet/route_generator.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/widgets/desktop/desktop_dialog.dart';
|
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||||
|
@ -61,8 +59,10 @@ class _DeleteWalletKeysPopup extends ConsumerState<DeleteWalletKeysPopup> {
|
||||||
),
|
),
|
||||||
DesktopDialogCloseButton(
|
DesktopDialogCloseButton(
|
||||||
onPressedOverride: () {
|
onPressedOverride: () {
|
||||||
int count = 0;
|
Navigator.of(
|
||||||
Navigator.of(context).popUntil((_) => count++ >= 2);
|
context,
|
||||||
|
rootNavigator: true,
|
||||||
|
).pop();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -117,106 +117,17 @@ class _DeleteWalletKeysPopup extends ConsumerState<DeleteWalletKeysPopup> {
|
||||||
child: PrimaryButton(
|
child: PrimaryButton(
|
||||||
label: "Continue",
|
label: "Continue",
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
int count = 0;
|
await Navigator.of(context).push(
|
||||||
Navigator.of(context).popUntil((_) => count++ >= 2);
|
RouteGenerator.getRoute(
|
||||||
|
builder: (context) {
|
||||||
unawaited(
|
return ConfirmDelete(
|
||||||
showDialog(
|
walletId: _walletId,
|
||||||
context: context,
|
);
|
||||||
builder: (context) {
|
},
|
||||||
return DesktopDialog(
|
settings: const RouteSettings(
|
||||||
maxHeight: 350,
|
name: "/desktopConfirmDelete",
|
||||||
child: Column(
|
),
|
||||||
children: [
|
),
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
DesktopDialogCloseButton(
|
|
||||||
onPressedOverride: () {
|
|
||||||
int count = 0;
|
|
||||||
Navigator.of(context)
|
|
||||||
.popUntil((_) => count++ >= 2);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment:
|
|
||||||
CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Thanks! "
|
|
||||||
"\n\nYour wallet will be deleted.",
|
|
||||||
style: STextStyles.desktopH2(context),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 50),
|
|
||||||
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 {
|
|
||||||
// int count = 0;
|
|
||||||
// Navigator.of(context)
|
|
||||||
// .popUntil(
|
|
||||||
// (_) => count++ >= 2);
|
|
||||||
|
|
||||||
final walletsInstance = ref.read(
|
|
||||||
walletsChangeNotifierProvider);
|
|
||||||
final manager = ref
|
|
||||||
.read(
|
|
||||||
walletsChangeNotifierProvider)
|
|
||||||
.getManager(_walletId);
|
|
||||||
|
|
||||||
final _managerWalletId =
|
|
||||||
manager.walletId;
|
|
||||||
|
|
||||||
await ref
|
|
||||||
.read(
|
|
||||||
walletsServiceChangeNotifierProvider)
|
|
||||||
.deleteWallet(
|
|
||||||
manager.walletName,
|
|
||||||
true);
|
|
||||||
|
|
||||||
if (mounted) {
|
|
||||||
Navigator.of(context)
|
|
||||||
.popUntil(
|
|
||||||
ModalRoute.withName(
|
|
||||||
MyStackView
|
|
||||||
.routeName));
|
|
||||||
}
|
|
||||||
|
|
||||||
// wait for widget tree to dispose of any widgets watching the manager
|
|
||||||
await Future<void>.delayed(
|
|
||||||
const Duration(
|
|
||||||
seconds: 1));
|
|
||||||
walletsInstance.removeWallet(
|
|
||||||
walletId:
|
|
||||||
_managerWalletId);
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -232,3 +143,86 @@ class _DeleteWalletKeysPopup extends ConsumerState<DeleteWalletKeysPopup> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ConfirmDelete extends ConsumerStatefulWidget {
|
||||||
|
const ConfirmDelete({
|
||||||
|
Key? key,
|
||||||
|
required this.walletId,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final String walletId;
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<ConfirmDelete> createState() => _ConfirmDeleteState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ConfirmDeleteState extends ConsumerState<ConfirmDelete> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return DesktopDialog(
|
||||||
|
maxHeight: 350,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: const [
|
||||||
|
DesktopDialogCloseButton(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Thanks! "
|
||||||
|
"\n\nYour wallet will be deleted.",
|
||||||
|
style: STextStyles.desktopH2(context),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 50),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
SecondaryButton(
|
||||||
|
width: 250,
|
||||||
|
buttonHeight: ButtonHeight.xl,
|
||||||
|
label: "Cancel",
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
PrimaryButton(
|
||||||
|
width: 250,
|
||||||
|
buttonHeight: ButtonHeight.xl,
|
||||||
|
label: "Continue",
|
||||||
|
onPressed: () async {
|
||||||
|
final walletsInstance =
|
||||||
|
ref.read(walletsChangeNotifierProvider);
|
||||||
|
final manager = ref
|
||||||
|
.read(walletsChangeNotifierProvider)
|
||||||
|
.getManager(widget.walletId);
|
||||||
|
|
||||||
|
final _managerWalletId = manager.walletId;
|
||||||
|
//
|
||||||
|
await ref
|
||||||
|
.read(walletsServiceChangeNotifierProvider)
|
||||||
|
.deleteWallet(manager.walletName, true);
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait for widget tree to dispose of any widgets watching the manager
|
||||||
|
await Future<void>.delayed(const Duration(seconds: 1));
|
||||||
|
walletsInstance.removeWallet(walletId: _managerWalletId);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -41,8 +41,10 @@ class _DesktopAttentionDeleteWallet
|
||||||
children: [
|
children: [
|
||||||
DesktopDialogCloseButton(
|
DesktopDialogCloseButton(
|
||||||
onPressedOverride: () {
|
onPressedOverride: () {
|
||||||
int count = 0;
|
Navigator.of(
|
||||||
Navigator.of(context).popUntil((_) => count++ >= 2);
|
context,
|
||||||
|
rootNavigator: true,
|
||||||
|
).pop();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -87,8 +89,10 @@ class _DesktopAttentionDeleteWallet
|
||||||
buttonHeight: ButtonHeight.xl,
|
buttonHeight: ButtonHeight.xl,
|
||||||
label: "Cancel",
|
label: "Cancel",
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
int count = 0;
|
Navigator.of(
|
||||||
Navigator.of(context).popUntil((_) => count++ >= 2);
|
context,
|
||||||
|
rootNavigator: true,
|
||||||
|
).pop();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
|
@ -102,12 +106,15 @@ class _DesktopAttentionDeleteWallet
|
||||||
.getManager(widget.walletId)
|
.getManager(widget.walletId)
|
||||||
.mnemonic;
|
.mnemonic;
|
||||||
|
|
||||||
await Navigator.of(context)
|
if (mounted) {
|
||||||
.pushNamed(DeleteWalletKeysPopup.routeName,
|
await Navigator.of(context).pushNamed(
|
||||||
arguments: Tuple2(
|
DeleteWalletKeysPopup.routeName,
|
||||||
widget.walletId,
|
arguments: Tuple2(
|
||||||
words,
|
widget.walletId,
|
||||||
));
|
words,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue