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

Commit

Permalink
- rebase fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWeen committed Feb 24, 2020
1 parent efe5404 commit d82df3a
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 21 deletions.
1 change: 0 additions & 1 deletion Xamarin.Forms.Core.UnitTests/ShellUriHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public async Task LocationRemovesImplicit()
[Test]
public async Task GlobalNavigateTwice()
{

var shell = new Shell();
var item1 = CreateShellItem(asImplicit: true, shellContentRoute: "rootlevelcontent1");

Expand Down
24 changes: 18 additions & 6 deletions Xamarin.Forms.Core/Shell/Shell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ internal async Task GoToAsync(ShellNavigationState state, bool animate, bool ena

ShellRouteState navigationRequest = await ShellUriParser.ParseAsync(new ShellUriParserArgs(this, state.FullLocation));
navigationRequest = await ShellNavigationRequest.NavigatingToAsync(new ShellNavigationArgs(this, navigationRequest));

if (navigationRequest == null || navigationRequest == this.RouteState)
if (navigationRequest == null || navigationRequest == RouteState)
{
return;
}
Expand All @@ -469,7 +469,19 @@ internal async Task GoToAsync(ShellNavigationState state, bool animate, bool ena

var currentRoute = navigationRequest.CurrentRoute;
var pathParts = currentRoute.PathParts;
IReadOnlyList<PathPart> globalRoutes = pathParts.Skip(3).ToList();

IReadOnlyList<PathPart> globalRoutes = null;
if (replaceEntireStack)
{
globalRoutes = pathParts.Skip(3).ToList();
}
else
{
// skip all global routes already pushed
globalRoutes = pathParts.Skip(RouteState.CurrentRoute.PathParts.Count).ToList();
}

globalRoutes = globalRoutes ?? new List<PathPart>();

ApplyQueryAttributes(this, currentRoute.NavigationParameters, false);

Expand All @@ -484,7 +496,7 @@ internal async Task GoToAsync(ShellNavigationState state, bool animate, bool ena
if (globalRoutes.Count > 0 && nextActiveSection != null && replaceEntireStack)
{
modalStackPreBuilt = true;
await nextActiveSection.GoToAsync(navigationRequest, false, state.FullLocation);
await nextActiveSection.GoToAsync(navigationRequest, false, state.FullLocation, RouteState);
}

if (shellItem != null)
Expand Down Expand Up @@ -533,13 +545,13 @@ internal async Task GoToAsync(ShellNavigationState state, bool animate, bool ena
// TODO get rid of this hack and fix so if there's a stack the current page doesn't display
Device.BeginInvokeOnMainThread(async () =>
{
await CurrentItem.CurrentItem.GoToAsync(navigationRequest, animate, state.FullLocation);
await CurrentItem.CurrentItem.GoToAsync(navigationRequest, animate, state.FullLocation, RouteState);
});
}
}
else
{
await CurrentItem.CurrentItem.GoToAsync(navigationRequest, animate, state.FullLocation);
await CurrentItem.CurrentItem.GoToAsync(navigationRequest, animate, state.FullLocation, RouteState);
}

_accumulateNavigatedEvents = false;
Expand Down
35 changes: 25 additions & 10 deletions Xamarin.Forms.Core/Shell/ShellSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,27 +284,38 @@ public static implicit operator ShellSection(TemplatedPage page)
return (ShellSection)(ShellContent)page;
}

internal async Task GoToAsync(ShellRouteState navigationRequest, bool animate, Uri uri)
internal async Task GoToAsync(ShellRouteState navigationRequest, bool animate, Uri uri, ShellRouteState shellRouteState)
{
List<Page> navStack = null;
string route = String.Empty;
var currentRoute = navigationRequest.CurrentRoute;
var pathParts = currentRoute.PathParts;
IReadOnlyList<PathPart> globalRoutes = pathParts.Skip(3).ToList();

if (pathParts == null || pathParts.Count <= 3)
{
await Navigation.PopToRootAsync(animate);
return;
}


uri = ShellUriHandler.FormatUri(uri);
bool replaceEntireStack = false;
if (uri.IsAbsoluteUri)
replaceEntireStack = true;
else if (uri.OriginalString.StartsWith("//", StringComparison.Ordinal) || uri.OriginalString.StartsWith("\\\\", StringComparison.Ordinal))
replaceEntireStack = true;

IReadOnlyList<PathPart> globalRoutes = null;
if (replaceEntireStack)
{
globalRoutes = pathParts.Skip(3).ToList();
}
else
{
// skip all global routes already pushed
globalRoutes = pathParts.Skip(shellRouteState.CurrentRoute.PathParts.Count).ToList();
}

if (globalRoutes == null || globalRoutes.Count == 0)
{
await Navigation.PopToRootAsync(animate);
return;
}


int whereToStartNavigation = 0;

// Pop the stack down to where it no longer matches
Expand Down Expand Up @@ -335,7 +346,11 @@ internal async Task GoToAsync(ShellRouteState navigationRequest, bool animate, U
// pop everything after this route
popCount = i + 2;
whereToStartNavigation++;
ShellApplyParameters.ApplyParameters(new ShellLifecycleArgs((BaseShellItem)LogicalChildren[i], globalRoutes[i], currentRoute));

if (i < LogicalChildren.Count)
ShellApplyParameters.ApplyParameters(new ShellLifecycleArgs((BaseShellItem)LogicalChildren[i], globalRoutes[i], currentRoute));
else
Shell.ApplyQueryAttributes(navPage, currentRoute.NavigationParameters, isLast);

// If we're not on the last loop of the stack then continue
// otherwise pop the rest of the stack
Expand Down
2 changes: 1 addition & 1 deletion Xamarin.Forms.Material.Android/MaterialFrameRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void UpdateBackgroundColor()
if (_defaultBackgroundColor == null)
_defaultBackgroundColor = CardBackgroundColor.DefaultColor;

SetCardBackgroundColor(bgColor.IsDefault ? _defaultBackgroundColor.Value : bgColor.ToAndroid());
SetCardBackgroundColor(bgColor.IsDefault ? _defaultBackgroundColor.Value : (int)bgColor.ToAndroid());
}

// IVisualElementRenderer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ void UpdateSplitViewLayout()
SetLockMode(isShowingSplit ? LockModeLockedOpen : LockModeUnlocked);
unchecked
{
SetScrimColor(isShowingSplit ? Color.Transparent.ToAndroid() : (int)DefaultScrimColor);
SetScrimColor(isShowingSplit ? (int)Color.Transparent.ToAndroid() : (int)DefaultScrimColor);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void UpdateSplitViewLayout()
SetLockMode(isShowingSplit ? LockModeLockedOpen : LockModeUnlocked);
unchecked
{
SetScrimColor(isShowingSplit ? Color.Transparent.ToAndroid() : (int)DefaultScrimColor);
SetScrimColor(isShowingSplit ? (int)Color.Transparent.ToAndroid() : (int)DefaultScrimColor);
}
Platform?.UpdateMasterDetailToggle();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ protected virtual void UpdateDrawerLockMode(FlyoutBehavior behavior)

unchecked
{
SetScrimColor(behavior == FlyoutBehavior.Locked ? Color.Transparent.ToAndroid() : (int)DefaultScrimColor);
SetScrimColor(behavior == FlyoutBehavior.Locked ? (int)Color.Transparent.ToAndroid() : (int)DefaultScrimColor);
}
}

Expand Down

0 comments on commit d82df3a

Please sign in to comment.