Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nativeframepresenter): animate pages depending on NavigationMode #19587

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 30 additions & 19 deletions src/Uno.UI/Controls/NativeFramePresenter.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ private async Task InvalidateStack()
while (_stackUpdates.Any())
{
var navigation = _stackUpdates.Dequeue();
await UpdateStack(navigation.page, navigation.args.NavigationTransitionInfo);
await UpdateStack(navigation.page, navigation.args);
}

_isUpdatingStack = false;
}

private async Task UpdateStack(Page newPage, NavigationTransitionInfo transitionInfo)
private async Task UpdateStack(Page newPage, NavigationEventArgs args)
{
// When AndroidUnloadInactivePages is false, we keep the pages that are still a part of the navigation history
// (i.e. in BackStack or ForwardStack) as children and make then invisible instead of removing them. The order
Expand All @@ -133,39 +133,50 @@ private async Task UpdateStack(Page newPage, NavigationTransitionInfo transition

var oldPage = _currentPage.page;
var oldTransitionInfo = _currentPage.transitionInfo;
_currentPage = (newPage, transitionInfo);
_currentPage = (newPage, args.NavigationTransitionInfo);

if (oldPage is not null)
if (newPage is not null)
{
if (GetIsAnimated(oldTransitionInfo))
if (Children.Contains(newPage))
{
await oldPage.AnimateAsync(GetExitAnimation());
oldPage.ClearAnimation();
newPage.Visibility = Visibility.Visible;
}
if (FeatureConfiguration.NativeFramePresenter.AndroidUnloadInactivePages)
else
{
Children.Remove(oldPage);
if (args.NavigationMode is NavigationMode.Back)
{
// insert the new page underneath the old one so that
// when the old one animates out you see the new page
// without a time slice in between where neither
// the old nor the new page is visible.
Children.Insert(0, newPage);
}
else
{
Children.Add(newPage);
}
}
else
if (args.NavigationMode is not NavigationMode.Back && GetIsAnimated(args.NavigationTransitionInfo))
{
oldPage.Visibility = Visibility.Collapsed;
await newPage.AnimateAsync(GetEnterAnimation());
newPage.ClearAnimation();
}
}

if (newPage is not null)
if (oldPage is not null)
{
if (Children.Contains(newPage))
if (args.NavigationMode is NavigationMode.Back && GetIsAnimated(oldTransitionInfo))
{
newPage.Visibility = Visibility.Visible;
await oldPage.AnimateAsync(GetExitAnimation());
oldPage.ClearAnimation();
}
else
if (FeatureConfiguration.NativeFramePresenter.AndroidUnloadInactivePages)
{
Children.Add(newPage);
Children.Remove(oldPage);
}
if (GetIsAnimated(transitionInfo))
else
{
await newPage.AnimateAsync(GetEnterAnimation());
newPage.ClearAnimation();
oldPage.Visibility = Visibility.Collapsed;
}
}

Expand Down
Loading