don't showLoading on fusion cancel or close if not running

This commit is contained in:
sneurlax 2023-10-20 13:23:46 -05:00
parent a4891d8a64
commit 27f8f86b8a

View file

@ -40,100 +40,106 @@ class FusionDialogView extends ConsumerStatefulWidget {
class _FusionDialogViewState extends ConsumerState<FusionDialogView> { class _FusionDialogViewState extends ConsumerState<FusionDialogView> {
Future<bool> _requestAndProcessCancel() async { Future<bool> _requestAndProcessCancel() async {
final shouldCancel = await showDialog<bool?>( if (!ref
context: context, .read(fusionProgressUIStateProvider(widget.walletId).notifier)
barrierDismissible: false, .running) {
builder: (_) => DesktopDialog( return true;
maxWidth: 580, } else {
maxHeight: double.infinity, bool? shouldCancel = await showDialog<bool?>(
child: Padding( context: context,
padding: const EdgeInsets.only( barrierDismissible: false,
left: 32, builder: (_) => DesktopDialog(
right: 0, maxWidth: 580,
top: 0, maxHeight: double.infinity,
bottom: 32, child: Padding(
), padding: const EdgeInsets.only(
child: Column( left: 32,
children: [ right: 0,
Row( top: 0,
mainAxisAlignment: MainAxisAlignment.spaceBetween, bottom: 32,
children: [ ),
Text( child: Column(
"Cancel fusion?", children: [
style: STextStyles.desktopH3(context), Row(
), mainAxisAlignment: MainAxisAlignment.spaceBetween,
DesktopDialogCloseButton(
onPressedOverride: () => Navigator.of(context).pop(false),
),
],
),
Padding(
padding: const EdgeInsets.only(
left: 0,
right: 32,
top: 0,
bottom: 0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
"Do you really want to cancel the fusion process?", "Cancel fusion?",
style: STextStyles.smallMed14(context), style: STextStyles.desktopH3(context),
textAlign: TextAlign.left,
), ),
const SizedBox(height: 40), DesktopDialogCloseButton(
Row( onPressedOverride: () => Navigator.of(context).pop(false),
children: [
Expanded(
child: SecondaryButton(
label: "No",
buttonHeight: ButtonHeight.l,
onPressed: () {
Navigator.of(context).pop(false);
},
),
),
const SizedBox(width: 16),
Expanded(
child: PrimaryButton(
label: "Yes",
buttonHeight: ButtonHeight.l,
onPressed: () {
Navigator.of(context).pop(true);
},
),
),
],
), ),
], ],
), ),
), Padding(
], padding: const EdgeInsets.only(
left: 0,
right: 32,
top: 0,
bottom: 0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Do you really want to cancel the fusion process?",
style: STextStyles.smallMed14(context),
textAlign: TextAlign.left,
),
const SizedBox(height: 40),
Row(
children: [
Expanded(
child: SecondaryButton(
label: "No",
buttonHeight: ButtonHeight.l,
onPressed: () {
Navigator.of(context).pop(false);
},
),
),
const SizedBox(width: 16),
Expanded(
child: PrimaryButton(
label: "Yes",
buttonHeight: ButtonHeight.l,
onPressed: () {
Navigator.of(context).pop(true);
},
),
),
],
),
],
),
),
],
),
), ),
), ),
),
);
if (shouldCancel == true && mounted) {
final fusionWallet = ref
.read(walletsChangeNotifierProvider)
.getManager(widget.walletId)
.wallet as FusionWalletInterface;
await showLoading(
whileFuture: Future.wait([
fusionWallet.stop(),
Future<void>.delayed(const Duration(seconds: 2)),
]),
context: context,
isDesktop: true,
message: "Stopping fusion",
); );
return true; if (shouldCancel == true && mounted) {
} else { final fusionWallet = ref
return false; .read(walletsChangeNotifierProvider)
.getManager(widget.walletId)
.wallet as FusionWalletInterface;
await showLoading(
whileFuture: Future.wait([
fusionWallet.stop(),
Future<void>.delayed(const Duration(seconds: 2)),
]),
context: context,
isDesktop: true,
message: "Stopping fusion",
);
return true;
} else {
return false;
}
} }
} }