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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Shell Navigation for Hierarchally registered Global Routes (#13330)
fixes #13328 fixes #11237 * Fix Shell Navigation for Hierarchally registered Global Routes * - fix added paths * - fix relative hierarchical routing * - remove extra comment * - remove comments * - generalize shell setter * - additional test * Update BaseShellItem.cs * - fix routes pushed with longer uris * - improve matching * - clean up comments * - fix multiple back navigation with hierarchies * - fix root routes * - fix absolute routes
- Loading branch information
Showing
8 changed files
with
867 additions
and
289 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Diagnostics; | ||
|
||
namespace Xamarin.Forms | ||
{ | ||
[DebuggerDisplay("RequestDefinition = {Request}, StackRequest = {StackRequest}")] | ||
internal class NavigationRequest | ||
{ | ||
public enum WhatToDoWithTheStack | ||
{ | ||
ReplaceIt, | ||
PushToIt | ||
} | ||
|
||
public NavigationRequest(RequestDefinition definition, WhatToDoWithTheStack stackRequest, string query, string fragment) | ||
{ | ||
StackRequest = stackRequest; | ||
Query = query; | ||
Fragment = fragment; | ||
Request = definition; | ||
} | ||
|
||
public WhatToDoWithTheStack StackRequest { get; } | ||
public string Query { get; } | ||
public string Fragment { get; } | ||
public RequestDefinition Request { get; } | ||
} | ||
} |
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,50 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
|
||
namespace Xamarin.Forms | ||
{ | ||
[DebuggerDisplay("Full = {FullUri}, Short = {ShortUri}")] | ||
internal class RequestDefinition | ||
{ | ||
public RequestDefinition(RouteRequestBuilder theWinningRoute, Shell shell) | ||
{ | ||
Item = theWinningRoute.Item; | ||
Section = theWinningRoute.Section ?? Item?.CurrentItem; | ||
Content = theWinningRoute.Content ?? Section?.CurrentItem; | ||
GlobalRoutes = theWinningRoute.GlobalRouteMatches; | ||
|
||
List<String> builder = new List<string>(); | ||
if (Item?.Route != null) | ||
builder.Add(Item.Route); | ||
|
||
if (Section?.Route != null) | ||
builder.Add(Section?.Route); | ||
|
||
if (Content?.Route != null) | ||
builder.Add(Content?.Route); | ||
|
||
if (GlobalRoutes != null) | ||
builder.AddRange(GlobalRoutes); | ||
|
||
var uriPath = MakeUriString(builder); | ||
var uri = ShellUriHandler.CreateUri(uriPath); | ||
FullUri = ShellUriHandler.ConvertToStandardFormat(shell, uri); | ||
|
||
} | ||
|
||
string MakeUriString(List<string> segments) | ||
{ | ||
if (segments[0].StartsWith("/", StringComparison.Ordinal) || segments[0].StartsWith("\\", StringComparison.Ordinal)) | ||
return String.Join("/", segments); | ||
|
||
return $"//{String.Join("/", segments)}"; | ||
} | ||
|
||
public Uri FullUri { get; } | ||
public ShellItem Item { get; } | ||
public ShellSection Section { get; } | ||
public ShellContent Content { get; } | ||
public List<string> GlobalRoutes { get; } | ||
} | ||
} |
Oops, something went wrong.