diff --git a/src/Uno.Extensions.Navigation.UI/Navigator.cs b/src/Uno.Extensions.Navigation.UI/Navigator.cs index 7d66e2d938..00e6af4387 100644 --- a/src/Uno.Extensions.Navigation.UI/Navigator.cs +++ b/src/Uno.Extensions.Navigation.UI/Navigator.cs @@ -1,6 +1,4 @@ -using System.Diagnostics; -using Uno.Extensions.Diagnostics; -using Uno.Extensions.Navigation.UI; +using Uno.Extensions.Diagnostics; namespace Uno.Extensions.Navigation; @@ -202,7 +200,7 @@ await RedirectForDependsOn(request, rm) is { } dependsNavResponse) if (Logger.IsEnabled(LogLevel.Trace)) Logger.LogTraceMessage($"Building fully qualified route for unhandled request. New request: {request.Route}"); - if(Region.Navigator() is ClosableNavigator closable) + if (Region.Navigator() is ClosableNavigator closable) { if (Logger.IsEnabled(LogLevel.Trace)) Logger.LogTraceMessage($"Closing navigator and redirecting request"); return closable.CloseAndNavigateAsync(request); @@ -557,6 +555,27 @@ protected virtual async Task RegionCanNavigate(Route route, RouteInfo? rou } } + // If a flyout is hosting a page it will inject frameview + // resulting in an empty route for the flyout navigator. + // In this case we need to check the child regions for a route + // and use that to determine if the current navigator should be + // closed (ie we can navigate to the current route inside the flyout) + if (this is ClosableNavigator closable && + Route?.IsEmpty() == true && + Region.Children.FirstOrDefault(x => x.Navigator()?.Route?.IsEmpty() == false) is { } childRegion) + { + var currentRouteMap = Resolver.FindByPath(childRegion.Navigator()?.Route?.Base); + if (currentRouteMap != null || routeMap != null) + { + if (routeMap?.Parent is not null && + currentRouteMap?.Parent is not null && + currentRouteMap?.Parent != routeMap.Parent) + { + return false; + } + } + } + return true; } diff --git a/testing/TestHarness/TestHarness.Core/TestSections.cs b/testing/TestHarness/TestHarness.Core/TestSections.cs index 1896894535..68f0790a8b 100644 --- a/testing/TestHarness/TestHarness.Core/TestSections.cs +++ b/testing/TestHarness/TestHarness.Core/TestSections.cs @@ -12,6 +12,7 @@ public enum TestSections Navigation_NavigationView, Navigation_TabBar, Navigation_Reactive, + Apps_Chefs, Apps_Commerce, Apps_Commerce_ShellControl, Apps_ToDo, diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCompletedDialog.xaml b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCompletedDialog.xaml new file mode 100644 index 0000000000..7006f0b738 --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCompletedDialog.xaml @@ -0,0 +1,13 @@ + + + + + + diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCompletedDialog.xaml.cs b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCompletedDialog.xaml.cs new file mode 100644 index 0000000000..c32515872e --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCompletedDialog.xaml.cs @@ -0,0 +1,10 @@ + +namespace TestHarness.Ext.Navigation.Apps.Chefs; + +public sealed partial class ChefsCompletedDialog : ContentDialog +{ + public ChefsCompletedDialog() + { + this.InitializeComponent(); + } +} diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCookbookDetailModel.cs b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCookbookDetailModel.cs new file mode 100644 index 0000000000..8e9ccec15e --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCookbookDetailModel.cs @@ -0,0 +1,5 @@ +namespace TestHarness.Ext.Navigation.Apps.Chefs; + +public partial class ChefsCookbookDetailModel +{ +} diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCookbookDetailPage.xaml b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCookbookDetailPage.xaml new file mode 100644 index 0000000000..13d9574c26 --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCookbookDetailPage.xaml @@ -0,0 +1,13 @@ + + + + + + diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCookbookDetailPage.xaml.cs b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCookbookDetailPage.xaml.cs new file mode 100644 index 0000000000..fa28b2038d --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCookbookDetailPage.xaml.cs @@ -0,0 +1,10 @@ + +namespace TestHarness.Ext.Navigation.Apps.Chefs; + +public sealed partial class ChefsCookbookDetailPage : Page +{ + public ChefsCookbookDetailPage() + { + this.InitializeComponent(); + } +} diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCreateUpdateCookbookModel.cs b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCreateUpdateCookbookModel.cs new file mode 100644 index 0000000000..cb22eeb5a1 --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCreateUpdateCookbookModel.cs @@ -0,0 +1,5 @@ +namespace TestHarness.Ext.Navigation.Apps.Chefs; + +public partial class ChefsCreateUpdateCookbookModel +{ +} diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCreateUpdateCookbookPage.xaml b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCreateUpdateCookbookPage.xaml new file mode 100644 index 0000000000..9d290abcd7 --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCreateUpdateCookbookPage.xaml @@ -0,0 +1,13 @@ + + + + + + diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCreateUpdateCookbookPage.xaml.cs b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCreateUpdateCookbookPage.xaml.cs new file mode 100644 index 0000000000..98ae93a40a --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsCreateUpdateCookbookPage.xaml.cs @@ -0,0 +1,10 @@ + +namespace TestHarness.Ext.Navigation.Apps.Chefs; + +public sealed partial class ChefsCreateUpdateCookbookPage : Page +{ + public ChefsCreateUpdateCookbookPage() + { + this.InitializeComponent(); + } +} diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFavoriteRecipesModel.cs b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFavoriteRecipesModel.cs new file mode 100644 index 0000000000..89a81311cc --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFavoriteRecipesModel.cs @@ -0,0 +1,5 @@ +namespace TestHarness.Ext.Navigation.Apps.Chefs; + +public partial class ChefsFavoriteRecipesModel +{ +} diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFavoriteRecipesPage.xaml b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFavoriteRecipesPage.xaml new file mode 100644 index 0000000000..a544e9e107 --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFavoriteRecipesPage.xaml @@ -0,0 +1,13 @@ + + + + + + diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFavoriteRecipesPage.xaml.cs b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFavoriteRecipesPage.xaml.cs new file mode 100644 index 0000000000..d51a25a10f --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFavoriteRecipesPage.xaml.cs @@ -0,0 +1,10 @@ + +namespace TestHarness.Ext.Navigation.Apps.Chefs; + +public sealed partial class ChefsFavoriteRecipesPage : Page +{ + public ChefsFavoriteRecipesPage() + { + this.InitializeComponent(); + } +} diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFilterModel.cs b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFilterModel.cs new file mode 100644 index 0000000000..abe0d00d05 --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFilterModel.cs @@ -0,0 +1,5 @@ +namespace TestHarness.Ext.Navigation.Apps.Chefs; + +public partial class ChefsFilterModel +{ +} diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFilterPage.xaml b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFilterPage.xaml new file mode 100644 index 0000000000..1dff741bec --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFilterPage.xaml @@ -0,0 +1,13 @@ + + + + + + diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFilterPage.xaml.cs b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFilterPage.xaml.cs new file mode 100644 index 0000000000..1a69f91dd8 --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsFilterPage.xaml.cs @@ -0,0 +1,10 @@ + +namespace TestHarness.Ext.Navigation.Apps.Chefs; + +public sealed partial class ChefsFilterPage : Page +{ + public ChefsFilterPage() + { + this.InitializeComponent(); + } +} diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsGenericDialog.xaml b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsGenericDialog.xaml new file mode 100644 index 0000000000..0a62b97f52 --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsGenericDialog.xaml @@ -0,0 +1,13 @@ + + + + + + diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsGenericDialog.xaml.cs b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsGenericDialog.xaml.cs new file mode 100644 index 0000000000..ea17e8fcbf --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsGenericDialog.xaml.cs @@ -0,0 +1,10 @@ + +namespace TestHarness.Ext.Navigation.Apps.Chefs; + +public sealed partial class ChefsGenericDialog : ContentDialog +{ + public ChefsGenericDialog() + { + this.InitializeComponent(); + } +} diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsGenericDialogModel.cs b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsGenericDialogModel.cs new file mode 100644 index 0000000000..2e7638b7a7 --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsGenericDialogModel.cs @@ -0,0 +1,5 @@ +namespace TestHarness.Ext.Navigation.Apps.Chefs; + +public partial class ChefsGenericDialogModel +{ +} diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsHomeModel.cs b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsHomeModel.cs new file mode 100644 index 0000000000..fe1c8912d9 --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsHomeModel.cs @@ -0,0 +1,35 @@ +using TestHarness.Ext.Navigation.Apps.Chefs.Models; + +namespace TestHarness.Ext.Navigation.Apps.Chefs; + +public partial class ChefsHomeModel(INavigator navigator) +{ + + public async ValueTask ShowCurrentProfile() + { + await navigator.NavigateToProfile(this, new ChefsUser { FullName = "Tester User" }); + } + + public async ValueTask ShowCurrentProfileNew() + { + await navigator.NavigateRouteAsync(this, "ChefsProfile", qualifier: Qualifiers.Dialog, data: new ChefsUser { FullName = "Tester User (new)" }); + } + + +} + +public static class ChefsNavigationExtensions +{ + public static async ValueTask NavigateToProfile(this INavigator navigator, object sender, ChefsUser? profile = null) + { + var response = await navigator.NavigateRouteForResultAsync(sender, "ChefsProfile", qualifier: Qualifiers.Dialog, data: profile); + var result = await response!.Result; + + //If a Recipe was selected, navigate to the RecipeDetails. Otherwise, do nothing + await (result.SomeOrDefault() switch + { + ChefsRecipe recipe => navigator.NavigateDataAsync(sender, recipe), + _ => Task.CompletedTask, + }); + } +} diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsHomePage.xaml b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsHomePage.xaml new file mode 100644 index 0000000000..89814f11e3 --- /dev/null +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Chefs/ChefsHomePage.xaml @@ -0,0 +1,17 @@ + + + + +