diff --git a/lib/ui/actions/collection/collection_sharing_actions.dart b/lib/ui/actions/collection/collection_sharing_actions.dart index 439257f23..f2ed5c399 100644 --- a/lib/ui/actions/collection/collection_sharing_actions.dart +++ b/lib/ui/actions/collection/collection_sharing_actions.dart @@ -50,13 +50,13 @@ class CollectionActions { ), const ButtonWidget( buttonType: ButtonType.secondary, - buttonAction: ButtonAction.second, + buttonAction: ButtonAction.cancel, isInAlert: true, shouldStickToDarkTheme: true, labelText: "Cancel", ) ], - title: "Remove public link?", + title: "Remove public link", body: 'This will remove the public link for accessing "${collection.name}".', ); @@ -64,19 +64,18 @@ class CollectionActions { if (result == ButtonAction.error) { showGenericErrorDialog(context: context); } - // return return result == ButtonAction.first; + } else { + return false; } } final dialog = createProgressDialog( context, - enable ? "Creating link..." : "Disabling link...", + "Creating link...", ); try { await dialog.show(); - enable - ? await CollectionsService.instance.createShareUrl(collection) - : await CollectionsService.instance.disableShareUrl(collection); + await CollectionsService.instance.createShareUrl(collection); dialog.hide(); return true; } catch (e) { diff --git a/lib/ui/components/button_widget.dart b/lib/ui/components/button_widget.dart index 8109ad491..64276f99b 100644 --- a/lib/ui/components/button_widget.dart +++ b/lib/ui/components/button_widget.dart @@ -443,8 +443,7 @@ class _ButtonChildWidgetState extends State { : 0, ), () { widget.isInAlert - ? Navigator.of(context, rootNavigator: true) - .pop(widget.buttonAction) + ? _popWithButtonAction(context, widget.buttonAction) : null; if (mounted) { setState(() { @@ -461,9 +460,7 @@ class _ButtonChildWidgetState extends State { widget.isInAlert ? Future.delayed( const Duration(seconds: 0), - () => Navigator.of(context, rootNavigator: true).pop( - ButtonAction.error, - ), + () => _popWithButtonAction(context, ButtonAction.error), ) : null; }); @@ -472,12 +469,20 @@ class _ButtonChildWidgetState extends State { if (widget.isInAlert) { Future.delayed( Duration(seconds: widget.shouldShowSuccessConfirmation ? 1 : 0), - () => Navigator.of(context).pop(widget.buttonAction), + () => _popWithButtonAction(context, widget.buttonAction), ); } } } + void _popWithButtonAction(BuildContext context, ButtonAction? buttonAction) { + Navigator.of(context).canPop() + ? Navigator.of(context).pop( + buttonAction, + ) + : null; + } + void _onTapDown(details) { setState(() { buttonColor = widget.buttonStyle.pressedButtonColor ??