mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
hook cancel buttons up to stop fn
This commit is contained in:
parent
e9f00582d8
commit
ed2a637e5e
4 changed files with 43 additions and 13 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 0d634a48e180458456aa6bc822bb82098380d114
|
||||
Subproject commit 1f98575c58d5b3144ac6e5e613311307c22e53b2
|
|
@ -9,14 +9,17 @@
|
|||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/cashfusion/sub_widgets/fusion_progress.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/services/mixins/fusion_wallet_interface.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||
|
||||
class FusionProgressView extends StatefulWidget {
|
||||
class FusionProgressView extends ConsumerStatefulWidget {
|
||||
const FusionProgressView({
|
||||
super.key,
|
||||
required this.walletId,
|
||||
|
@ -27,14 +30,13 @@ class FusionProgressView extends StatefulWidget {
|
|||
final String walletId;
|
||||
|
||||
@override
|
||||
State<FusionProgressView> createState() => _FusionProgressViewState();
|
||||
ConsumerState<FusionProgressView> createState() => _FusionProgressViewState();
|
||||
}
|
||||
|
||||
class _FusionProgressViewState extends State<FusionProgressView> {
|
||||
class _FusionProgressViewState extends ConsumerState<FusionProgressView> {
|
||||
/// return true on will cancel, false if cancel cancelled
|
||||
Future<bool> _requestCancel() async {
|
||||
//
|
||||
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -88,8 +90,16 @@ class _FusionProgressViewState extends State<FusionProgressView> {
|
|||
// TODO: various button states
|
||||
// tempt only show cancel button
|
||||
SecondaryButton(
|
||||
label: "Cancel",
|
||||
label: "Cancela",
|
||||
onPressed: () async {
|
||||
final fusionWallet = ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManager(widget.walletId)
|
||||
.wallet as FusionWalletInterface;
|
||||
|
||||
await fusionWallet.stop();
|
||||
// TODO should this stop be unawaited?
|
||||
|
||||
if (await _requestCancel()) {
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
|
|
|
@ -568,7 +568,7 @@ class _DesktopCashFusion extends ConsumerState<DesktopCashFusionView> {
|
|||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return FusionDialog(
|
||||
return FusionDialogView(
|
||||
walletId: widget.walletId,
|
||||
);
|
||||
},
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/cashfusion/sub_widgets/fusion_progress.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/services/mixins/fusion_wallet_interface.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
||||
|
@ -14,14 +17,19 @@ class CashFusionState {
|
|||
CashFusionState({required this.status, this.info});
|
||||
}
|
||||
|
||||
class FusionDialog extends StatelessWidget {
|
||||
const FusionDialog({
|
||||
class FusionDialogView extends ConsumerStatefulWidget {
|
||||
const FusionDialogView({
|
||||
Key? key,
|
||||
required this.walletId,
|
||||
}) : super(key: key);
|
||||
|
||||
final String walletId;
|
||||
|
||||
@override
|
||||
ConsumerState<FusionDialogView> createState() => _FusionDialogViewState();
|
||||
}
|
||||
|
||||
class _FusionDialogViewState extends ConsumerState<FusionDialogView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DesktopDialog(
|
||||
|
@ -59,7 +67,7 @@ class FusionDialog extends StatelessWidget {
|
|||
height: 20,
|
||||
),
|
||||
FusionProgress(
|
||||
walletId: walletId,
|
||||
walletId: widget.walletId,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
|
@ -72,8 +80,20 @@ class FusionDialog extends StatelessWidget {
|
|||
buttonHeight: ButtonHeight.m,
|
||||
enabled: true,
|
||||
label: "Cancel",
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(true);
|
||||
onPressed: () async {
|
||||
final fusionWallet = ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManager(widget.walletId)
|
||||
.wallet as FusionWalletInterface;
|
||||
|
||||
await fusionWallet.stop();
|
||||
// TODO should this stop be unawaited?
|
||||
|
||||
// if (await _requestCancel()) {
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
// }
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue