Skip to content

Commit

Permalink
simplify the notification when modal is dismissed
Browse files Browse the repository at this point in the history
  • Loading branch information
pictos committed Jul 25, 2024
1 parent 2dedb42 commit 5b70755
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ internal class ModalFragment : DialogFragment
IMauiContext _mauiWindowContext;
NavigationRootManager? _navigationRootManager;
static readonly ColorDrawable TransparentColorDrawable = new(AColor.Transparent);
bool _pendingAnimation = true;

public event EventHandler? AnimationEnded;

Expand Down Expand Up @@ -301,7 +302,7 @@ void OnAnimationEnded(object? sender, AAnimation.AnimationEndEventArgs e)
}

animation.AnimationEnd -= OnAnimationEnded;
AnimationEnded?.Invoke(this, EventArgs.Empty);
FireAnimationEnded();
}
}

Expand All @@ -320,6 +321,23 @@ public override void OnDismiss(IDialogInterface dialog)
base.OnDismiss(dialog);
}

public override void OnDestroy()
{
base.OnDestroy();
FireAnimationEnded();
}

void FireAnimationEnded()
{
if (!_pendingAnimation)
{
return;
}

_pendingAnimation = false;
AnimationEnded?.Invoke(this, EventArgs.Empty);
}


sealed class CustomComponentDialog : ComponentDialog
{
Expand Down

0 comments on commit 5b70755

Please sign in to comment.