mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +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/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/cashfusion/sub_widgets/fusion_progress.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/themes/stack_colors.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/widgets/background.dart';
|
import 'package:stackwallet/widgets/background.dart';
|
||||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||||
|
|
||||||
class FusionProgressView extends StatefulWidget {
|
class FusionProgressView extends ConsumerStatefulWidget {
|
||||||
const FusionProgressView({
|
const FusionProgressView({
|
||||||
super.key,
|
super.key,
|
||||||
required this.walletId,
|
required this.walletId,
|
||||||
|
@ -27,14 +30,13 @@ class FusionProgressView extends StatefulWidget {
|
||||||
final String walletId;
|
final String walletId;
|
||||||
|
|
||||||
@override
|
@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
|
/// return true on will cancel, false if cancel cancelled
|
||||||
Future<bool> _requestCancel() async {
|
Future<bool> _requestCancel() async {
|
||||||
//
|
// TODO
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,8 +90,16 @@ class _FusionProgressViewState extends State<FusionProgressView> {
|
||||||
// TODO: various button states
|
// TODO: various button states
|
||||||
// tempt only show cancel button
|
// tempt only show cancel button
|
||||||
SecondaryButton(
|
SecondaryButton(
|
||||||
label: "Cancel",
|
label: "Cancela",
|
||||||
onPressed: () async {
|
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 (await _requestCancel()) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
|
@ -568,7 +568,7 @@ class _DesktopCashFusion extends ConsumerState<DesktopCashFusionView> {
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return FusionDialog(
|
return FusionDialogView(
|
||||||
walletId: widget.walletId,
|
walletId: widget.walletId,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
import 'package:flutter/material.dart';
|
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/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/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
||||||
|
@ -14,14 +17,19 @@ class CashFusionState {
|
||||||
CashFusionState({required this.status, this.info});
|
CashFusionState({required this.status, this.info});
|
||||||
}
|
}
|
||||||
|
|
||||||
class FusionDialog extends StatelessWidget {
|
class FusionDialogView extends ConsumerStatefulWidget {
|
||||||
const FusionDialog({
|
const FusionDialogView({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.walletId,
|
required this.walletId,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final String walletId;
|
final String walletId;
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<FusionDialogView> createState() => _FusionDialogViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FusionDialogViewState extends ConsumerState<FusionDialogView> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return DesktopDialog(
|
return DesktopDialog(
|
||||||
|
@ -59,7 +67,7 @@ class FusionDialog extends StatelessWidget {
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
FusionProgress(
|
FusionProgress(
|
||||||
walletId: walletId,
|
walletId: widget.walletId,
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 12,
|
height: 12,
|
||||||
|
@ -72,8 +80,20 @@ class FusionDialog extends StatelessWidget {
|
||||||
buttonHeight: ButtonHeight.m,
|
buttonHeight: ButtonHeight.m,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
label: "Cancel",
|
label: "Cancel",
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
Navigator.of(context).pop(true);
|
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