mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-02-02 03:06:29 +00:00
hook back and close buttons up to fusion's stop
This commit is contained in:
parent
9d4cdb31bd
commit
5809687116
2 changed files with 41 additions and 13 deletions
|
@ -85,17 +85,6 @@ class _CashFusionViewState extends ConsumerState<CashFusionView> {
|
|||
|
||||
@override
|
||||
void dispose() {
|
||||
// Stop the fusion process on dispose.
|
||||
//
|
||||
// Hack to stop fusion when a mobile user clicks back.
|
||||
final fusionWallet = ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManager(widget.walletId)
|
||||
.wallet as FusionWalletInterface;
|
||||
|
||||
// We probably want to await this and showLoading while it stops.
|
||||
unawaited(fusionWallet.stop());
|
||||
|
||||
serverController.dispose();
|
||||
portController.dispose();
|
||||
fusionRoundController.dispose();
|
||||
|
@ -116,7 +105,9 @@ class _CashFusionViewState extends ConsumerState<CashFusionView> {
|
|||
Theme.of(context).extension<StackColors>()!.background,
|
||||
appBar: AppBar(
|
||||
automaticallyImplyLeading: false,
|
||||
leading: const AppBarBackButton(),
|
||||
leading: AppBarBackButton(onPressed: () {
|
||||
_stop();
|
||||
}),
|
||||
title: Text(
|
||||
"CashFusion",
|
||||
style: STextStyles.navBarTitle(context),
|
||||
|
@ -457,4 +448,21 @@ class _CashFusionViewState extends ConsumerState<CashFusionView> {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Stops the fusion process.
|
||||
///
|
||||
/// This is called when the user presses the back button.
|
||||
void _stop() async {
|
||||
final fusionWallet = ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManager(widget.walletId)
|
||||
.wallet as FusionWalletInterface;
|
||||
|
||||
await fusionWallet.stop();
|
||||
// TODO await successful cancellation and showLoading while it stops.
|
||||
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,9 @@ class _FusionDialogViewState extends ConsumerState<FusionDialogView> {
|
|||
),
|
||||
),
|
||||
DesktopDialogCloseButton(
|
||||
onPressedOverride: () => Navigator.of(context).pop(true),
|
||||
onPressedOverride: () {
|
||||
_stop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -107,4 +109,22 @@ class _FusionDialogViewState extends ConsumerState<FusionDialogView> {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Stops the fusion process.
|
||||
///
|
||||
/// This is called when the user presses the back button.
|
||||
void _stop() async {
|
||||
print(12121212);
|
||||
final fusionWallet = ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManager(widget.walletId)
|
||||
.wallet as FusionWalletInterface;
|
||||
|
||||
await fusionWallet.stop();
|
||||
// TODO await successful cancellation and showLoading while it stops.
|
||||
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue