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 May 27, 2020
1 parent 27e8e02 commit 8d1c61b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
1 change: 1 addition & 0 deletions Xamarin.Forms.Core/Shell/Shell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@ internal async void ProcessNavigated(ShellNavigatedEventArgs args)
{
content.OnAppearing(async () =>
{
OnNavigated(args);
Navigated?.Invoke(this, args);
await ShellNavigationRequest.NavigatedToAsync(new ShellNavigationArgs(this, null));
});
Expand Down
15 changes: 12 additions & 3 deletions Xamarin.Forms.Core/Shell/ShellNavigationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,18 @@ void UpdateUris()

builder.Append(queryString);

FullUriWithImplicit = ShellUriHandler.ConvertToStandardFormat(null, new Uri(builder.ToString(), UriKind.Relative));
FullUri = ShellUriHandler.ConvertToStandardFormat(null, new Uri(builderWithoutImplicit.ToString(), UriKind.Relative));
if (builder.Length > 0)
FullUriWithImplicit = new Uri(builder.Insert(0, @"//").ToString(), UriKind.Relative);

if (builderWithoutImplicit.Length > 0)
FullUri = new Uri(builderWithoutImplicit.Insert(0, @"//").ToString(), UriKind.Relative);


//if(builder.Length > 0)
// FullUriWithImplicit = ShellUriHandler.ConvertToStandardFormat(null, new Uri(builder.Insert(0, @"//").ToString(), UriKind.Relative));

//if(builderWithoutImplicit.Length > 0)
// FullUri = ShellUriHandler.ConvertToStandardFormat(null, new Uri(builderWithoutImplicit.Insert(0, @"//").ToString(), UriKind.Relative));
}

public Uri FullUri { get; private set; }
Expand Down Expand Up @@ -214,7 +224,6 @@ internal ShellRouteState(Shell shell)
Routes = new[] { CurrentRoute };
}


public ShellRouteState(RoutePath routePath)
{
CurrentRoute = routePath;
Expand Down
27 changes: 19 additions & 8 deletions Xamarin.Forms.Core/Shell/ShellUriHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal static Uri FormatUri(Uri path, Shell shell)
if (path.OriginalString.StartsWith("..") && shell?.CurrentState != null)
{
var result = Path.Combine(shell.CurrentState.FullLocation.OriginalString, path.OriginalString);
var returnValue = ConvertToStandardFormat(shell, new Uri(result, UriKind.Relative));
var returnValue = ConvertToStandardFormat("scheme", "host", null, new Uri(result, UriKind.Relative));
return new Uri(FormatUri(returnValue.PathAndQuery), UriKind.Relative);
}

Expand Down Expand Up @@ -54,8 +54,17 @@ internal static Uri CreateUri(string path)

return new Uri(path, UriKind.Relative);
}

public static Uri ConvertToStandardFormat(Shell shell, Uri request)
{
request = FormatUri(request, shell);
return ConvertToStandardFormat(
shell?.RouteScheme,
shell?.RouteHost,
shell?.Route, request);
}

public static Uri ConvertToStandardFormat(string routeScheme, string routeHost, string route, Uri request)
{
string pathAndQuery = null;
if (request.IsAbsoluteUri)
Expand All @@ -65,20 +74,22 @@ public static Uri ConvertToStandardFormat(Shell shell, Uri request)

var segments = new List<string>(pathAndQuery.Split(_pathSeparators, StringSplitOptions.RemoveEmptyEntries));

if (segments.Count > 0 && segments[0] != (shell?.RouteHost ?? RouteHost))
segments.Insert(0, (shell?.RouteHost ?? RouteHost));
if (segments.Count > 0 && segments[0] != (routeHost))
segments.Insert(0, (routeHost));

if (segments.Count > 1 && segments[1] != (shell?.Route ?? Route))
segments.Insert(1, (shell?.Route ?? Route));
if (segments.Count > 1 && segments[1] != (route))
segments.Insert(1, (route));

var path = String.Join(_pathSeparator, segments.ToArray());
string uri = $"{(shell?.RouteScheme ?? RouteScheme)}://{path}";

string uri = $"{(routeScheme)}://{path}";

return new Uri(uri);
}

internal static ShellRouteState GetNavigationRequest(Shell shell, Uri uri, bool enableRelativeShellRoutes = false)
internal static ShellRouteState GetNavigationRequest(Shell shell, Uri navigationUri, bool enableRelativeShellRoutes = false)
{
var uri = navigationUri;
uri = FormatUri(uri, shell);
Uri request = ConvertToStandardFormat(shell, uri);
var possibleRouteMatches = GenerateRoutePaths(shell, request, uri, enableRelativeShellRoutes);
Expand Down

0 comments on commit 8d1c61b

Please sign in to comment.