Skip to content

Commit

Permalink
Merge pull request #1597 from unoplatform/dev/nr/rootnav
Browse files Browse the repository at this point in the history
  • Loading branch information
agneszitte authored Oct 27, 2023
2 parents a2168a1 + cfd4520 commit ee114c9
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src/Uno.Extensions.Navigation.UI/Navigator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,18 @@ protected virtual async Task<bool> RegionCanNavigate(Route route, RouteInfo? rou
}
}

if (Route?.IsEmpty() == false)
{
var currentRouteMap = Resolver.FindByPath(Route.Base);
if (currentRouteMap != null || routeMap != null)
{
if (currentRouteMap?.Parent != routeMap?.Parent)
{
return false;
}
}
}

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@
<PathIcon Data="{StaticResource Icon_person}" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem AutomationProperties.AutomationId="SettingsNavigationViewItem"
Content="Settings"
uen:Navigation.Request="Settings">
<muxc:NavigationViewItem.Icon>
<PathIcon Data="{StaticResource Icon_person}" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
</muxc:NavigationView.MenuItems>
<Grid>
<Grid.RowDefinitions>
Expand Down Expand Up @@ -135,6 +142,13 @@
<PathIcon Data="{StaticResource Icon_person}" />
</utu:TabBarItem.Icon>
</utu:TabBarItem>
<utu:TabBarItem AutomationProperties.AutomationId="SettingsTabBarItem"
IsSelectable="False"
uen:Navigation.Request="Settings">
<utu:TabBarItem.Icon>
<PathIcon Data="{StaticResource Icon_person}" />
</utu:TabBarItem.Icon>
</utu:TabBarItem>
</utu:TabBar>
</Grid>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ protected override void RegisterRoutes(IViewRegistry views, IRouteRegistry route
new ViewMap<CommerceProductsPage, CommerceProductsViewModel>(),
new DataViewMap<CommerceProductDetailsPage, CommerceProductDetailsViewModel, CommerceProduct>(),
new ViewMap<CommerceDealsPage, CommerceDealsViewModel>(),
new ViewMap<CommerceProfilePage, CommerceProfileViewModel>()
new ViewMap<CommerceProfilePage, CommerceProfileViewModel>(),
new ViewMap<CommerceSettingsPage, CommerceSettingsViewModel>()
);


Expand Down Expand Up @@ -56,7 +57,8 @@ protected override void RegisterRoutes(IViewRegistry views, IRouteRegistry route
DependsOn:"Products"),

new RouteMap("Profile", View: views.FindByViewModel<CommerceProfileViewModel>())
})
}),
new RouteMap("Settings", View: views.FindByViewModel<CommerceSettingsViewModel>())
}));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Page
x:Class="TestHarness.Ext.Navigation.Apps.Commerce.CommerceSettingsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestHarness.Ext.Navigation.Apps.Commerce"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:utu="using:Uno.Toolkit.UI"
xmlns:uen="using:Uno.Extensions.Navigation.UI"
xmlns:um="using:Uno.Material"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<utu:NavigationBar AutomationProperties.AutomationId="SettingsNavigationBar"
Content="Settings" />

</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238

namespace TestHarness.Ext.Navigation.Apps.Commerce
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class CommerceSettingsPage : Page
{
public CommerceSettingsPage()
{
this.InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace TestHarness.Ext.Navigation.Apps.Commerce;

public record CommerceSettingsViewModel(INavigator Navigator)
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ protected override void RegisterRoutes(IViewRegistry views, IRouteRegistry route
new ViewMap<CommerceProductsPage, CommerceProductsViewModel>(),
new DataViewMap<CommerceProductDetailsPage, CommerceProductDetailsViewModel, CommerceProduct>(),
new ViewMap<CommerceDealsPage, CommerceDealsViewModel>(),
new ViewMap<CommerceProfilePage, CommerceProfileViewModel>()
new ViewMap<CommerceProfilePage, CommerceProfileViewModel>(),
new ViewMap<CommerceSettingsPage, CommerceSettingsViewModel>()
);


Expand Down Expand Up @@ -57,7 +58,8 @@ protected override void RegisterRoutes(IViewRegistry views, IRouteRegistry route
DependsOn:"Products"),

new RouteMap("Profile", View: views.FindByViewModel<CommerceProfileViewModel>())
})
}),
new RouteMap("Settings", View: views.FindByViewModel<CommerceSettingsViewModel>())
}));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
<Button AutomationProperties.AutomationId="ProductsProfileButton"
Content="Profile"
uen:Navigation.Request="Profile" />
<Button AutomationProperties.AutomationId="ProductsSettingsButton"
Content="Settings"
uen:Navigation.Request="Settings" />
</StackPanel>
<StackPanel uen:Region.Name="Deals"
AutomationProperties.AutomationId="DealsStackPanel"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
<Compile Include="$(MSBuildThisFileDirectory)Ext\Navigation\Apps\Commerce\CommerceHomePage.xaml.cs">
<DependentUpon>CommerceHomePage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Ext\Navigation\Apps\Commerce\CommerceSettingsPage.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Ext\Navigation\Apps\Commerce\CommerceSettingsViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Ext\Navigation\Apps\Commerce\CommerceShellControlHostInit.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Ext\Navigation\Apps\Commerce\CommerceHostInit.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Ext\Navigation\Apps\Commerce\CommerceLoginPage.xaml.cs">
Expand Down Expand Up @@ -502,6 +504,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Ext\Navigation\Apps\Commerce\CommerceSettingsPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Ext\Navigation\Apps\Commerce\CommerceShellControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<Import Project="TestHarness.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
<ItemGroup>
<_Globbed_Compile Remove="Ext\Navigation\Apps\Commerce\CommerceSettingsPage.xaml.cs" />
<_Globbed_Compile Remove="Ext\Navigation\Apps\Commerce\CommerceSettingsViewModel.cs" />
<_Globbed_Compile Remove="Ext\Navigation\Dialogs\DialogsComplexFlyout.xaml.cs" />
<_Globbed_Compile Remove="Ext\Navigation\Dialogs\DialogsComplexFlyoutOnePage.xaml.cs" />
<_Globbed_Compile Remove="Ext\Navigation\Dialogs\DialogsComplexFlyoutTwoPage.xaml.cs" />
Expand All @@ -22,6 +24,7 @@
<_Globbed_Compile Remove="Ext\Navigation\NavigationView\NavigationViewDataService.cs" />
</ItemGroup>
<ItemGroup>
<_Globbled_Page Remove="Ext\Navigation\Apps\Commerce\CommerceSettingsPage.xaml" />
<_Globbled_Page Remove="Ext\Navigation\Dialogs\DialogsComplexFlyout.xaml" />
<_Globbled_Page Remove="Ext\Navigation\Dialogs\DialogsComplexFlyoutOnePage.xaml" />
<_Globbled_Page Remove="Ext\Navigation\Dialogs\DialogsComplexFlyoutTwoPage.xaml" />
Expand Down

0 comments on commit ee114c9

Please sign in to comment.