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

feat: Added INavigator to both NavigationResponse as well as IRouteNotifier #1678

Merged
merged 2 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/Uno.Extensions.Navigation.UI/IRouteUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ internal interface IRouteUpdater
{
void StartNavigation(INavigator navigator, IRegion region, NavigationRequest request);

void EndNavigation(INavigator navigator, IRegion region, NavigationRequest request);
void EndNavigation(INavigator navigator, IRegion region, NavigationRequest request, NavigationResponse? response);
}

52 changes: 26 additions & 26 deletions src/Uno.Extensions.Navigation.UI/Navigator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,31 @@ protected Navigator(
public async Task<NavigationResponse?> NavigateAsync(NavigationRequest request)
{
RouteUpdater.StartNavigation(this, Region, request);
try
NavigationResponse? response;

if (request.Source is null)
{
if (request.Source is null)
{
if (Logger.IsEnabled(LogLevel.Information)) Logger.LogInformationMessage($"Starting Navigation - Navigator: {this.GetType().Name} Request: {request.Route}");
request = request with { Source = this };
}
if (Logger.IsEnabled(LogLevel.Information)) Logger.LogInformationMessage($"Starting Navigation - Navigator: {this.GetType().Name} Request: {request.Route}");
request = request with { Source = this };
}

if (Logger.IsEnabled(LogLevel.Debug)) Logger.LogDebugMessage($" Navigator: {this.GetType().Name} Request: {request.Route}");
if (Logger.IsEnabled(LogLevel.Debug)) Logger.LogDebugMessage($" Navigator: {this.GetType().Name} Request: {request.Route}");

// Do any initialisation logic that may be
// defined for the route - allows for
// routes to be redirected
request = InitializeRequest(request);
// Do any initialisation logic that may be
// defined for the route - allows for
// routes to be redirected
request = InitializeRequest(request);

// Redirect navigation if required
// eg route that matches a child, should be routed to that child
// eg route that doesn't match a page for frame nav should be sent to parent
var redirection = await RedirectNavigateAsync(request);
if (redirection is not null)
{
return await redirection;
}
// Redirect navigation if required
// eg route that matches a child, should be routed to that child
// eg route that doesn't match a page for frame nav should be sent to parent
var redirection = await RedirectNavigateAsync(request);
if (redirection is not null)
{
response = await redirection;
}
else
{

// Append Internal qualifier to avoid requests being sent back to parent
request = request.AsInternal();
Expand All @@ -80,18 +82,16 @@ protected Navigator(
{
// Dialogs will load a separate navigation hierarchy
// so there's no need to route the request to child regions
return await DialogNavigateAsync(request);
response = await DialogNavigateAsync(request);
}
else
{
// Invoke the region specific navigation
return await RegionNavigateAsync(request);
response = await RegionNavigateAsync(request);
}
}
finally
{
RouteUpdater.EndNavigation(this, Region, request);
}
RouteUpdater.EndNavigation(this, Region, request, response);
return response;
}

private async Task<Task<NavigationResponse?>?> RedirectNavigateAsync(NavigationRequest request)
Expand Down Expand Up @@ -710,7 +710,7 @@ private NavigationRequest DefaultRouteRequest(NavigationRequest request, (IRegio
{
return (from child in Region.Children
let nav = child.Navigator()
select (Region:child, Navigator: nav)).ToArray();
select (Region: child, Navigator: nav)).ToArray();
});


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public virtual void ControlInitialize()

UpdateRoute(executedRoute);

return new NavigationResponse(executedRoute ?? Route.Empty);
return new NavigationResponse(executedRoute ?? Route.Empty, Navigator: this);
}

protected virtual void UpdateRoute(Route? route)
Expand Down
Loading