mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-04-28 00:44:49 +00:00
frost flow interruption dialog
This commit is contained in:
parent
48e05919d5
commit
ccca53f3d8
11 changed files with 81 additions and 81 deletions
lib
frost_route_generator.dart
pages
add_wallet_views/frost_ms
new
reshare
send_view/frost_ms
settings_views/wallet_settings_view/frost_ms
wallet_view
pages_desktop_specific/my_stack_view/wallet_view/sub_widgets
widgets
|
@ -26,6 +26,12 @@ import 'package:stackwallet/wallets/crypto_currency/intermediate/frost_currency.
|
|||
|
||||
typedef FrostStepRoute = ({String routeName, String title});
|
||||
|
||||
enum FrostInterruptionDialogType {
|
||||
walletCreation,
|
||||
resharing,
|
||||
transactionCreation;
|
||||
}
|
||||
|
||||
final pFrostCreateCurrentStep = StateProvider.autoDispose((ref) => 1);
|
||||
final pFrostScaffoldArgs = StateProvider<
|
||||
({
|
||||
|
@ -33,6 +39,7 @@ final pFrostScaffoldArgs = StateProvider<
|
|||
String? walletId,
|
||||
List<FrostStepRoute> stepRoutes,
|
||||
VoidCallback onSuccess,
|
||||
FrostInterruptionDialogType frostInterruptionDialogType,
|
||||
})?>((ref) => null);
|
||||
|
||||
abstract class FrostRouteGenerator {
|
||||
|
|
|
@ -445,7 +445,9 @@ class _NewFrostMsWalletViewState
|
|||
context: context,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
frostInterruptionDialogType:
|
||||
FrostInterruptionDialogType.walletCreation,
|
||||
);
|
||||
|
||||
await Navigator.of(context).pushNamed(
|
||||
|
|
|
@ -177,7 +177,9 @@ class _SelectNewFrostImportTypeViewState
|
|||
context: context,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
frostInterruptionDialogType:
|
||||
FrostInterruptionDialogType.walletCreation,
|
||||
);
|
||||
break;
|
||||
|
||||
|
@ -191,7 +193,9 @@ class _SelectNewFrostImportTypeViewState
|
|||
stepRoutes: FrostRouteGenerator.joinReshareStepRoutes,
|
||||
onSuccess: () {
|
||||
// successful completion of steps
|
||||
}
|
||||
},
|
||||
frostInterruptionDialogType:
|
||||
FrostInterruptionDialogType.resharing,
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -215,6 +215,8 @@ class _FrostReshareStep1cState extends ConsumerState<FrostReshareStep1c> {
|
|||
walletId: wallet.walletId,
|
||||
stepRoutes: data.stepRoutes,
|
||||
onSuccess: data.onSuccess,
|
||||
frostInterruptionDialogType:
|
||||
FrostInterruptionDialogType.resharing,
|
||||
);
|
||||
ref.read(pFrostCreateCurrentStep.state).state = 2;
|
||||
await Navigator.of(context).pushNamed(
|
||||
|
|
|
@ -139,7 +139,9 @@ class _FrostSendViewState extends ConsumerState<FrostSendView> {
|
|||
// TODO ?
|
||||
|
||||
ref.read(pFrostScaffoldArgs.state).state = null;
|
||||
}
|
||||
},
|
||||
frostInterruptionDialogType:
|
||||
FrostInterruptionDialogType.transactionCreation,
|
||||
);
|
||||
|
||||
await Navigator.of(context).pushNamed(
|
||||
|
|
|
@ -164,7 +164,9 @@ class FrostMSWalletOptionsView extends ConsumerWidget {
|
|||
// TODO
|
||||
|
||||
ref.read(pFrostScaffoldArgs.state).state = null;
|
||||
}
|
||||
},
|
||||
frostInterruptionDialogType:
|
||||
FrostInterruptionDialogType.resharing,
|
||||
);
|
||||
|
||||
Navigator.of(context).pushNamed(
|
||||
|
|
|
@ -139,7 +139,8 @@ class _CompleteReshareConfigViewState
|
|||
onSuccess: () {
|
||||
// successful completion of steps
|
||||
// TODO
|
||||
}
|
||||
},
|
||||
frostInterruptionDialogType: FrostInterruptionDialogType.resharing,
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
|
|
|
@ -373,7 +373,9 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
// TODO ?
|
||||
|
||||
ref.read(pFrostScaffoldArgs.state).state = null;
|
||||
}
|
||||
},
|
||||
frostInterruptionDialogType:
|
||||
FrostInterruptionDialogType.transactionCreation,
|
||||
);
|
||||
|
||||
await Navigator.of(context).pushNamed(
|
||||
|
|
|
@ -107,7 +107,10 @@ class _MyWalletState extends ConsumerState<MyWallet> {
|
|||
ref
|
||||
.read(pFrostScaffoldArgs.state)
|
||||
.state = null;
|
||||
}
|
||||
},
|
||||
frostInterruptionDialogType:
|
||||
FrostInterruptionDialogType
|
||||
.transactionCreation,
|
||||
);
|
||||
|
||||
await Navigator.of(context).pushNamed(
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||
|
||||
enum FrostInterruptionDialogType {
|
||||
walletCreation,
|
||||
resharing,
|
||||
transactionCreation;
|
||||
}
|
||||
|
||||
class FrostInterruptionDialog extends StatelessWidget {
|
||||
const FrostInterruptionDialog({
|
||||
super.key,
|
||||
required this.type,
|
||||
required this.popUntilOnYesRouteName,
|
||||
this.onNoPressedOverride,
|
||||
this.onYesPressedOverride,
|
||||
});
|
||||
|
||||
final FrostInterruptionDialogType type;
|
||||
final String popUntilOnYesRouteName;
|
||||
final VoidCallback? onNoPressedOverride;
|
||||
final VoidCallback? onYesPressedOverride;
|
||||
|
||||
String get message {
|
||||
switch (type) {
|
||||
case FrostInterruptionDialogType.walletCreation:
|
||||
return "wallet creation";
|
||||
case FrostInterruptionDialogType.resharing:
|
||||
return "resharing";
|
||||
case FrostInterruptionDialogType.transactionCreation:
|
||||
return "transaction signing";
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StackDialog(
|
||||
title: "Cancel $message process",
|
||||
message: "Are you sure you want to cancel the $message process?",
|
||||
leftButton: SecondaryButton(
|
||||
label: "No",
|
||||
onPressed: onNoPressedOverride ??
|
||||
Navigator.of(
|
||||
context,
|
||||
rootNavigator: Util.isDesktop,
|
||||
).pop,
|
||||
),
|
||||
rightButton: PrimaryButton(
|
||||
label: "Yes",
|
||||
onPressed: onYesPressedOverride ??
|
||||
() {
|
||||
// pop dialog
|
||||
Navigator.of(
|
||||
context,
|
||||
rootNavigator: Util.isDesktop,
|
||||
).pop();
|
||||
|
||||
Navigator.of(context).popUntil(
|
||||
ModalRoute.withName(
|
||||
popUntilOnYesRouteName,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -7,7 +7,10 @@ import 'package:stackwallet/utilities/util.dart';
|
|||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||
import 'package:stackwallet/widgets/progress_bar.dart';
|
||||
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||
|
||||
class FrostStepScaffold extends ConsumerStatefulWidget {
|
||||
const FrostStepScaffold({super.key});
|
||||
|
@ -25,18 +28,60 @@ class _FrostScaffoldState extends ConsumerState<FrostStepScaffold> {
|
|||
late final List<FrostStepRoute> _routes;
|
||||
|
||||
bool _requestPopLock = false;
|
||||
|
||||
String get _message {
|
||||
switch (ref.read(pFrostScaffoldArgs)!.frostInterruptionDialogType) {
|
||||
case FrostInterruptionDialogType.walletCreation:
|
||||
return "wallet creation";
|
||||
case FrostInterruptionDialogType.resharing:
|
||||
return "resharing";
|
||||
case FrostInterruptionDialogType.transactionCreation:
|
||||
return "transaction signing";
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _requestPop(BuildContext context) async {
|
||||
if (_requestPopLock) {
|
||||
return;
|
||||
}
|
||||
_requestPopLock = true;
|
||||
|
||||
// TODO: dialog to confirm exit
|
||||
final resultFuture = showDialog<String?>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => StackDialog(
|
||||
title: "Cancel $_message process",
|
||||
message: "Are you sure you want to cancel the $_message process?",
|
||||
leftButton: SecondaryButton(
|
||||
label: "No",
|
||||
onPressed: () {
|
||||
// pop dialog
|
||||
Navigator.of(
|
||||
context,
|
||||
rootNavigator: Util.isDesktop,
|
||||
).pop("no");
|
||||
},
|
||||
),
|
||||
rightButton: PrimaryButton(
|
||||
label: "Yes",
|
||||
onPressed: () {
|
||||
// pop dialog
|
||||
Navigator.of(
|
||||
context,
|
||||
rootNavigator: Util.isDesktop,
|
||||
).pop("yes");
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// make sure to at least delay some time otherwise flutter pops back more than a single route lol...
|
||||
await Future<void>.delayed(const Duration(milliseconds: 200));
|
||||
final minTimeFuture =
|
||||
Future<void>.delayed(const Duration(milliseconds: 200));
|
||||
|
||||
if (context.mounted) {
|
||||
final result = await Future.wait<dynamic>([resultFuture, minTimeFuture]);
|
||||
|
||||
if (context.mounted && result[0] == "yes") {
|
||||
Navigator.of(context).pop();
|
||||
ref.read(pFrostScaffoldArgs.state).state = null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue