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: remove unique routes #2677

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions src/Uno.Extensions.Navigation.UI/Navigator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,21 @@ await RedirectForDependsOn(request, rm) is { } dependsNavResponse)
// where request needs to be sent to parent so that all child
// regions receive the request)
// Required for Test: Given_NavigationView.When_NavigationView
if (await CanNavigate(request.Route) &&
!await ParentCanNavigate(request.Route))
var canNavigate = await CanNavigate(request.Route);
//var parentCanNavigate = request.Route.Base == "ChefsRecipeDetails" ? false : await ParentCanNavigate(request.Route);
var parentCanNavigate = await ParentCanNavigate(request.Route);
if (canNavigate &&
!parentCanNavigate)
{
if (Logger.IsEnabled(LogLevel.Trace)) Logger.LogTraceMessage($"No redirection - Navigator can handle request (and parent cannot)");
return default;
}

//if (canNavigate)
//{
// if (Logger.IsEnabled(LogLevel.Trace)) Logger.LogTraceMessage($"Navigator can handle request - navigating");
// return default;
//}

// If this is a back/close with no other path, then return
// as if this navigator can handl it - it can't, so the request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public partial class ChefsFavoriteRecipesModel(INavigator navigator)
{
public async ValueTask NavigateToRecipeDetail()
{
await navigator.NavigateRouteAsync(this, "ChefsFavoriteRecipeDetails", data: new ChefsRecipe { Name = "Favorite Page" });
await navigator.NavigateRouteAsync(this, "/ChefsRoot/ChefsFavoriteRecipes/ChefsRecipeDetails", data: new ChefsRecipe { Name = "Favorite Page" });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
VerticalAlignment="Center"
Text="All my recipes" />
<Button AutomationProperties.AutomationId="RecipeDetailsButton"
uen:Navigation.Request="ChefsFavoriteRecipeDetails"
uen:Navigation.Request="ChefsRecipeDetails"
Content="Recipe Details" />
</Grid>
<Grid uen:Region.Name="MyCookbooks"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<Button Command="{Binding NavigateToRecipeDetail}" Content="Recipe Details" />
<Button AutomationProperties.AutomationId="FavoriteRecipesButton" Command="{Binding NavigateToFavoriteRecipes}" Content="Favorite Recipes" />
<Button uen:Navigation.Request="ChefsSearch" Content="Search" />
<Button uen:Navigation.Request="ChefsProfile" Content="Profile :D" />
<Button uen:Navigation.Request="ChefsNotifications" Content="Notifications" />
</StackPanel>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,55 +42,40 @@ protected override void RegisterRoutes(IViewRegistry views, IRouteRegistry route
new RouteMap("ChefsRoot", View: views.FindByViewModel<ChefsRootModel>(), Nested: new RouteMap[]
{
#region Main Tabs
new RouteMap("ChefsHome", View: views.FindByViewModel<ChefsHomeModel>(), IsDefault: true),
new RouteMap("ChefsSearch", View: views.FindByViewModel<ChefsSearchModel>()),
new RouteMap("ChefsFavoriteRecipes", View: views.FindByViewModel<ChefsFavoriteRecipesModel>()),
//new RouteMap("ChefsHome", View: views.FindByViewModel<ChefsHomeModel>(), IsDefault: true),
//new RouteMap("ChefsSearch", View: views.FindByViewModel<ChefsSearchModel>()),
//new RouteMap("ChefsFavoriteRecipes", View: views.FindByViewModel<ChefsFavoriteRecipesModel>()),
#endregion

#region Cookbooks
new RouteMap("ChefsCookbookDetails", View: views.FindByViewModel<ChefsCookbookDetailModel>(), DependsOn: "FavoriteRecipes"),
new RouteMap("ChefsUpdateCookbook", View: views.FindByViewModel<ChefsCreateUpdateCookbookModel>(), DependsOn: "FavoriteRecipes"),
new RouteMap("ChefsCreateCookbook", View: views.FindByViewModel<ChefsCreateUpdateCookbookModel>(), DependsOn: "FavoriteRecipes"),
//new RouteMap("ChefsCookbookDetails", View: views.FindByViewModel<ChefsCookbookDetailModel>(), DependsOn: "FavoriteRecipes"),
//new RouteMap("ChefsUpdateCookbook", View: views.FindByViewModel<ChefsCreateUpdateCookbookModel>(), DependsOn: "FavoriteRecipes"),
//new RouteMap("ChefsCreateCookbook", View: views.FindByViewModel<ChefsCreateUpdateCookbookModel>(), DependsOn: "FavoriteRecipes"),
#endregion

#region Recipe Details
new RouteMap("ChefsRecipeDetails", View: views.FindByViewModel<ChefsRecipeDetailsModel>(), DependsOn: "ChefsHome", Nested: new[] {
new RouteMap("ChefsIngredientsTabWide"),
new RouteMap("ChefsStepsTabWide"),
new RouteMap("ChefsReviewsTabWide"),
new RouteMap("ChefsNutritionTabWide"),
new RouteMap("ChefsIngredientsTab"),
new RouteMap("ChefsStepsTab"),
new RouteMap("ChefsReviewsTab"),
new RouteMap("ChefsNutritionTab"),
}),
new RouteMap("ChefsSearchRecipeDetails", View: views.FindByViewModel<ChefsRecipeDetailsModel>(), DependsOn: "ChefsSearch"),
new RouteMap("ChefsFavoriteRecipeDetails", View: views.FindByViewModel<ChefsRecipeDetailsModel>(), DependsOn: "ChefsFavoriteRecipes"),
new RouteMap("ChefsCookbookRecipeDetails", View: views.FindByViewModel<ChefsRecipeDetailsModel>(), DependsOn: "ChefsFavoriteRecipes"),
//new RouteMap("ChefsRecipeDetails", View: views.FindByViewModel<ChefsRecipeDetailsModel>(), DependsOn: "ChefsHome"),
#endregion

#region Live Cooking
new RouteMap("ChefsLiveCooking", View: views.FindByViewModel<ChefsLiveCookingModel>(), DependsOn: "ChefsRecipeDetails"),
new RouteMap("ChefsSearchLiveCooking", View: views.FindByViewModel<ChefsLiveCookingModel>(), DependsOn: "ChefsSearchRecipeDetails"),
new RouteMap("ChefsFavoriteLiveCooking", View: views.FindByViewModel<ChefsLiveCookingModel>(), DependsOn: "ChefsFavoriteRecipeDetails"),
new RouteMap("ChefsCookbookLiveCooking", View: views.FindByViewModel<ChefsLiveCookingModel>(), DependsOn: "ChefsCookbookRecipeDetails"),
//new RouteMap("ChefsLiveCooking", View: views.FindByViewModel<ChefsLiveCookingModel>()),
#endregion

new RouteMap("ChefsMap", View: views.FindByViewModel<ChefsMapModel>(), DependsOn: "ChefsHome"),
//new RouteMap("ChefsMap", View: views.FindByViewModel<ChefsMapModel>(), DependsOn: "ChefsHome"),
}),
new RouteMap("ChefsNotifications", View: views.FindByViewModel<ChefsNotificationsModel>(), Nested: new RouteMap[]
{
new RouteMap("ChefsAllTab"),
new RouteMap("ChefsUnreadTab"),
new RouteMap("ChefsReadTab"),
}),
new RouteMap("ChefsFilter", View: views.FindByViewModel<ChefsFilterModel>()),
new RouteMap("ChefsReviews", View: views.FindByViewModel<ChefsReviewsModel>()),
new RouteMap("ChefsProfile", View: views.FindByViewModel<ChefsProfileModel>()),
new RouteMap("ChefsSettings", View: views.FindByViewModel<ChefsSettingsModel>(), DependsOn: "ChefsProfile"),
new RouteMap("ChefsCompleted", View: views.FindByView<ChefsCompletedDialog>()),
new RouteMap("ChefsMap", View: views.FindByViewModel<ChefsMapModel>(), DependsOn: "ChefsMain"),
new RouteMap("ChefsDialog", View: views.FindByView<ChefsGenericDialog>())
//new RouteMap("ChefsNotifications", View: views.FindByViewModel<ChefsNotificationsModel>(), Nested: new RouteMap[]
//{
// new RouteMap("ChefsAllTab"),
// new RouteMap("ChefsUnreadTab"),
// new RouteMap("ChefsReadTab"),
//}),
//new RouteMap("ChefsFilter", View: views.FindByViewModel<ChefsFilterModel>()),
//new RouteMap("ChefsReviews", View: views.FindByViewModel<ChefsReviewsModel>()),
//new RouteMap("ChefsProfile", View: views.FindByViewModel<ChefsProfileModel>()),
//new RouteMap("ChefsSettings", View: views.FindByViewModel<ChefsSettingsModel>(), DependsOn: "ChefsProfile"),
//new RouteMap("ChefsCompleted", View: views.FindByView<ChefsCompletedDialog>()),
//new RouteMap("ChefsMap", View: views.FindByViewModel<ChefsMapModel>(), DependsOn: "ChefsMain"),
//new RouteMap("ChefsDialog", View: views.FindByView<ChefsGenericDialog>())
}
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ public partial class ChefsRecipeDetailsModel(ChefsRecipe recipe, INavigator navi

public async ValueTask LiveCooking()
{
var route = _navigator?.Route?.Base switch
{
"ChefsRecipeDetails" => "ChefsLiveCooking",
"ChefsSearchRecipeDetails" => "ChefsSearchLiveCooking",
"ChefsFavoriteRecipeDetails" => "ChefsFavoriteLiveCooking",
"ChefsCookbookRecipeDetails" => "ChefsCookbookLiveCooking",
_ => throw new InvalidOperationException("Navigating from unknown route")
};

await _navigator.NavigateRouteAsync(this, route, data: new ChefsLiveCookingParameter(Recipe, ImmutableList<ChefsStep>.Empty));
await _navigator.NavigateRouteAsync(this, "ChefsLiveCooking", data: new ChefsLiveCookingParameter(Recipe, ImmutableList<ChefsStep>.Empty));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public partial class ChefsSearchModel(INavigator navigator)
{
public async ValueTask NavigateToRecipeDetail()
{
await navigator.NavigateRouteAsync(this, "ChefsSearchRecipeDetails", data: new ChefsRecipe { Name = "Search Page" });
await navigator.NavigateRouteAsync(this, "ChefsRecipeDetails", data: new ChefsRecipe { Name = "Search Page" });
}
}
Loading