Skip to content

Commit 654eb62

Browse files
author
eriklimakc
committed
chore: Adjust nav sample to properly navigate with to from query
1 parent e9ccf60 commit 654eb62

File tree

8 files changed

+91
-26
lines changed

8 files changed

+91
-26
lines changed

UI/Navigation/src/Navigation/App.xaml.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes)
7979
new ViewMap<SecondPage>(),
8080
new ViewMap<ThirdPage>(),
8181
messageDialog,
82-
82+
new ViewMap<ToFromQueryMainPage, ToFromQueryMainViewModel>(),
8383
// FIXME: Using the URL address bar to navigate doesn't work
8484
// eg: http://localhost:5000/Main/ToFromQuery?QueryUser.Id=2b64071a-2c8a-45e4-9f48-3eb7d7aace41
8585
// https://github.com/unoplatform/uno.extensions/issues/2488
@@ -163,7 +163,8 @@ private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes)
163163
#endregion
164164

165165
#region ToFromQuery
166-
new ("ToFromQuery", View: views.FindByViewModel<ToFromQueryViewModel>()),
166+
new ("ToFromQueryMain", View: views.FindByViewModel<ToFromQueryMainViewModel>()),
167+
new ("ToFromQuery", View: views.FindByViewModel<ToFromQueryViewModel>(), DependsOn: "ToFromQueryMain"),
167168
#endregion
168169

169170
#region Flyout Drawer

UI/Navigation/src/Navigation/Navigation.csproj

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
<Project Sdk="Uno.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>
4-
net8.0-android;
5-
net8.0-ios;
6-
net8.0-maccatalyst;
7-
net8.0-windows10.0.19041;
8-
net8.0-desktop;
9-
net8.0-browserwasm;
10-
</TargetFrameworks>
3+
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst;net8.0-windows10.0.26100;net8.0-browserwasm;net8.0-desktop</TargetFrameworks>
114

125
<OutputType>Exe</OutputType>
136
<UnoSingleProject>true</UnoSingleProject>
@@ -29,11 +22,7 @@
2922
the "Microsoft.Windows.SDK.BuildTools" package above, and the "revision" version number
3023
must be the highest found in https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref.
3124
-->
32-
33-
<!-- Uno Platform 5.4 has been updated to use WinAppSDK 1.6, which necessitates a temporary version adjustment until newer versions of .NET 8 SDKs are released. -->
34-
<!-- Comment this WindowsSdkPackageVersion line again once .NET SDK version 8.0.403 or later is available. -->
35-
<!-- For more details, refer to: https://aka.platform.uno/migrate-from-previous#uno-platform-54 -->
36-
<WindowsSdkPackageVersion>10.0.19041.38</WindowsSdkPackageVersion>
25+
<!-- <WindowsSdkPackageVersion>10.0.22621.28</WindowsSdkPackageVersion> -->
3726

3827
<!--
3928
UnoFeatures let's you quickly add and manage implicit package references based on the features you want to use.

UI/Navigation/src/Navigation/Presentation/MainPage.xaml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,8 @@
107107
</muxc:NavigationViewItem.Icon>
108108
</muxc:NavigationViewItem>
109109

110-
<muxc:NavigationViewItem uen:Region.Name="./ToFromQuery?QueryUser.Id=8a5c5b2e-ff96-474b-9e4d-65bde598f6bc"
111-
Content="FromQuery User 1">
112-
<muxc:NavigationViewItem.Icon>
113-
<SymbolIcon Symbol="Link" />
114-
</muxc:NavigationViewItem.Icon>
115-
</muxc:NavigationViewItem>
116-
117-
<muxc:NavigationViewItem uen:Region.Name="./ToFromQuery?QueryUser.Id=2b64071a-2c8a-45e4-9f48-3eb7d7aace41"
118-
Content="FromQuery User 2">
110+
<muxc:NavigationViewItem uen:Region.Name="ToFromQueryMain"
111+
Content="FromQuery/ToQuery">
119112
<muxc:NavigationViewItem.Icon>
120113
<SymbolIcon Symbol="Link" />
121114
</muxc:NavigationViewItem.Icon>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<Page x:Class="Navigation.Presentation.ToFromQueryMainPage"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:local="using:Navigation.Presentation"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:utu="using:Uno.Toolkit.UI"
8+
xmlns:uen="using:Uno.Extensions.Navigation.UI"
9+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
10+
mc:Ignorable="d">
11+
12+
<Grid>
13+
<Grid.RowDefinitions>
14+
<RowDefinition Height="Auto" />
15+
<RowDefinition />
16+
</Grid.RowDefinitions>
17+
18+
<utu:NavigationBar Content="FromQuery/ToQuery Page">
19+
<utu:NavigationBar.MainCommand>
20+
<AppBarButton>
21+
<AppBarButton.Icon>
22+
<BitmapIcon UriSource="ms-appx:///Assets/Images/back.png" />
23+
</AppBarButton.Icon>
24+
</AppBarButton>
25+
</utu:NavigationBar.MainCommand>
26+
</utu:NavigationBar>
27+
28+
<StackPanel Grid.Row="1"
29+
HorizontalAlignment="Center"
30+
VerticalAlignment="Center"
31+
Spacing="16">
32+
<Image Width="150"
33+
Height="150"
34+
Margin="12"
35+
HorizontalAlignment="Center"
36+
Source="ms-appx:///Assets/logo.png" />
37+
38+
<Button Content="See User 1"
39+
HorizontalAlignment="Center"
40+
uen:Navigation.Data="{Binding User1}"
41+
uen:Navigation.Request="ToFromQuery" />
42+
43+
<Button Content="See User 2"
44+
HorizontalAlignment="Center"
45+
uen:Navigation.Data="{Binding User2}"
46+
uen:Navigation.Request="ToFromQuery" />
47+
48+
</StackPanel>
49+
</Grid>
50+
</Page>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Navigation.Presentation;
2+
3+
public sealed partial class ToFromQueryMainPage : Page
4+
{
5+
public ToFromQueryMainPage()
6+
{
7+
this.InitializeComponent();
8+
}
9+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace Navigation.Presentation;
2+
3+
public partial class ToFromQueryMainViewModel : ObservableObject
4+
{
5+
[ObservableProperty]
6+
private IDictionary<string, object> user1;
7+
8+
[ObservableProperty]
9+
private IDictionary<string, object> user2;
10+
11+
public ToFromQueryMainViewModel()
12+
{
13+
User1 = new Dictionary<string, object>
14+
{
15+
{ "QueryUser.Id", Guid.Parse("8a5c5b2e-ff96-474b-9e4d-65bde598f6bc") }
16+
};
17+
18+
User2 = new Dictionary<string, object>
19+
{
20+
{ "QueryUser.Id", Guid.Parse("2b64071a-2c8a-45e4-9f48-3eb7d7aace41") }
21+
};
22+
}
23+
}

UI/Navigation/src/Navigation/Presentation/ToFromQuery/ToFromQueryPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<RowDefinition />
1515
</Grid.RowDefinitions>
1616

17-
<utu:NavigationBar Content="ToFromQuery Page">
17+
<utu:NavigationBar Content="FromQuery/ToQuery User Page">
1818
<utu:NavigationBar.MainCommand>
1919
<AppBarButton>
2020
<AppBarButton.Icon>

UI/Navigation/src/global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
// To update the version of Uno please update the version of the Uno.Sdk here. See https://aka.platform.uno/upgrade-uno-packages for more information.
33
"msbuild-sdks": {
4-
"Uno.Sdk": "5.4.5"
4+
"Uno.Sdk": "5.5.56"
55
},
66
"sdk": {
77
"allowPrerelease": false

0 commit comments

Comments
 (0)