This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Invoke AnimationFinished from fragment if no animation has been added #13260
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
....Issues/Xamarin.Forms.Controls.Issues.Shared/ShellWithCustomRendererDisabledAnimations.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Text; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
|
||
|
||
#if UITEST | ||
using Xamarin.UITest; | ||
using NUnit.Framework; | ||
using Xamarin.Forms.Core.UITests; | ||
#endif | ||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
[Preserve(AllMembers = true)] | ||
[Issue(IssueTracker.None, 0, "[Shell] Overriding animation with custom renderer to remove animation breaks next navigation", | ||
PlatformAffected.All)] | ||
#if UITEST | ||
[NUnit.Framework.Category(UITestCategories.Shell)] | ||
#endif | ||
public class ShellWithCustomRendererDisabledAnimations : TestShell | ||
{ | ||
protected override void Init() | ||
{ | ||
ContentPage contentPage = new ContentPage(); | ||
base.AddFlyoutItem(contentPage, "Root"); | ||
|
||
contentPage.Content = new Button() | ||
{ | ||
Text = "Click Me", | ||
AutomationId = "PageLoaded", | ||
Command = new Command(async () => | ||
{ | ||
await Navigation.PushAsync(CreateSecondPage()); | ||
}) | ||
}; | ||
} | ||
|
||
ContentPage CreateSecondPage() | ||
{ | ||
ContentPage page = new ContentPage(); | ||
|
||
page.Content = new StackLayout() | ||
{ | ||
Children = | ||
{ | ||
new Label() | ||
{ | ||
Text = "If clicking `Go Back` goes back to previous page then test has passed" | ||
}, | ||
new Button() | ||
{ | ||
Text = "Go Back", | ||
Command = new Command(async () => | ||
{ | ||
await GoToAsync(".."); | ||
}), | ||
AutomationId = "GoBack" | ||
} | ||
} | ||
}; | ||
|
||
return page; | ||
} | ||
|
||
#if UITEST && __ANDROID__ | ||
[Test] | ||
public void NavigationWithACustomRendererThatDoesntSetAnAnimationStillWorks() | ||
{ | ||
RunningApp.Tap("PageLoaded"); | ||
RunningApp.Tap("GoBack"); | ||
RunningApp.WaitForElement("PageLoaded"); | ||
} | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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