Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Invoke AnimationFinished from fragment if no animation has been added #13260

Merged
merged 1 commit into from
Jan 1, 2021

Conversation

PureWeen
Copy link
Contributor

Description of Change

ShellItemRenederer on Android let's users override SetupAnimation to define custom animations. The navigation code on android subscribes to "AnimationFinished" to know when the animation has finished and complete the navigation Task. The problem here is that if the SetupAnimation doesn't actually setup an animation then "AnimationFinished" never gets called from ShellContentFragment. The real fix here will be to add a better API for the SetupAnimation override. Currently it's just

SetupAnimation(ShellNavigationSource navSource, AndroidX.Fragment.App.FragmentTransaction t, Page page)

But it should really be something like

SetupAnimation(ShellNavigationSource navSource, AndroidX.Fragment.App.FragmentTransaction t, Page page, Action callMeWhenAnimationHasFinished)

Or something similar to indicate to the caller that they need to tell the calling code when the animation has completed.

Platforms Affected

  • Android

Testing Procedure

  • UI Test Included

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)

@PureWeen PureWeen added this to the 5.0.0 milestone Dec 31, 2020
@PureWeen PureWeen added this to To do in vNext+1 (5.0.0) via automation Dec 31, 2020
@PureWeen PureWeen added this to In Review in Shell via automation Dec 31, 2020
@PureWeen PureWeen moved this from To do to In Progress in vNext+1 (5.0.0) Dec 31, 2020
@PureWeen PureWeen added the blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. label Dec 31, 2020
@@ -82,7 +82,10 @@ public override AndroidAnimation OnCreateAnimation(int transit, bool enter, int
}

if (result == null)
{
AnimationFinished?.Invoke(this, EventArgs.Empty);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically if the user creates a custom renderer that doesn't actually add an animation then the following code

https://github.com/xamarin/Xamarin.Forms/blob/5.0.0/Xamarin.Forms.Platform.Android/Renderers/ShellItemRendererBase.cs#L254

will never execute and the "async push" operation will never complete

This invokes the AnimationFinished event so the calling code can continue on and complete the animation Task

@rmarinho
Copy link
Member

rmarinho commented Jan 1, 2021

Failing tests not related

@rmarinho rmarinho merged commit afce413 into 5.0.0 Jan 1, 2021
Shell automation moved this from In Review to Done Jan 1, 2021
vNext+1 (5.0.0) automation moved this from In Progress to Done Jan 1, 2021
@rmarinho rmarinho deleted the shell_fix_custom_navigation_animations branch January 1, 2021 22:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue.
Projects
Shell
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants