Merge pull request #819 from ente-io/dialogs-bug-fix

Dialogs bug fix
This commit is contained in:
Ashil 2023-01-25 19:55:38 +05:30 committed by GitHub
commit 115d50c3d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 13 deletions

View file

@ -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) {

View file

@ -443,8 +443,7 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
: 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<ButtonChildWidget> {
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<ButtonChildWidget> {
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 ??