Skip to content

Commit

Permalink
Merge pull request #860 from unoplatform/dev/erli/update-nav-sample-t…
Browse files Browse the repository at this point in the history
…ofromquery

chore: Adjust nav sample to properly navigate with to from query
  • Loading branch information
agneszitte authored Jan 28, 2025
2 parents e9ccf60 + 5bf0ff9 commit 1e39f85
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 13 deletions.
5 changes: 3 additions & 2 deletions UI/Navigation/src/Navigation/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes)
new ViewMap<SecondPage>(),
new ViewMap<ThirdPage>(),
messageDialog,

new ViewMap<ToFromQueryMainPage, ToFromQueryMainViewModel>(),
// FIXME: Using the URL address bar to navigate doesn't work
// eg: http://localhost:5000/Main/ToFromQuery?QueryUser.Id=2b64071a-2c8a-45e4-9f48-3eb7d7aace41
// https://github.com/unoplatform/uno.extensions/issues/2488
Expand Down Expand Up @@ -163,7 +163,8 @@ private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes)
#endregion

#region ToFromQuery
new ("ToFromQuery", View: views.FindByViewModel<ToFromQueryViewModel>()),
new ("ToFromQueryMain", View: views.FindByViewModel<ToFromQueryMainViewModel>()),
new ("ToFromQuery", View: views.FindByViewModel<ToFromQueryViewModel>(), DependsOn: "ToFromQueryMain"),
#endregion

#region Flyout Drawer
Expand Down
11 changes: 2 additions & 9 deletions UI/Navigation/src/Navigation/Presentation/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,8 @@
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>

<muxc:NavigationViewItem uen:Region.Name="./ToFromQuery?QueryUser.Id=8a5c5b2e-ff96-474b-9e4d-65bde598f6bc"
Content="FromQuery User 1">
<muxc:NavigationViewItem.Icon>
<SymbolIcon Symbol="Link" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>

<muxc:NavigationViewItem uen:Region.Name="./ToFromQuery?QueryUser.Id=2b64071a-2c8a-45e4-9f48-3eb7d7aace41"
Content="FromQuery User 2">
<muxc:NavigationViewItem uen:Region.Name="ToFromQueryMain"
Content="FromQuery/ToQuery">
<muxc:NavigationViewItem.Icon>
<SymbolIcon Symbol="Link" />
</muxc:NavigationViewItem.Icon>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<Page x:Class="Navigation.Presentation.ToFromQueryMainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Navigation.Presentation"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:utu="using:Uno.Toolkit.UI"
xmlns:uen="using:Uno.Extensions.Navigation.UI"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>

<utu:NavigationBar Content="FromQuery/ToQuery Page">
<utu:NavigationBar.MainCommand>
<AppBarButton>
<AppBarButton.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/Images/back.png" />
</AppBarButton.Icon>
</AppBarButton>
</utu:NavigationBar.MainCommand>
</utu:NavigationBar>

<StackPanel Grid.Row="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Spacing="16">
<Image Width="150"
Height="150"
Margin="12"
HorizontalAlignment="Center"
Source="ms-appx:///Assets/logo.png" />

<Button Content="See User 1"
HorizontalAlignment="Center"
uen:Navigation.Data="{Binding User1}"
uen:Navigation.Request="ToFromQuery" />

<Button Content="See User 2"
HorizontalAlignment="Center"
uen:Navigation.Data="{Binding User2}"
uen:Navigation.Request="ToFromQuery" />

</StackPanel>
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Navigation.Presentation;

public sealed partial class ToFromQueryMainPage : Page
{
public ToFromQueryMainPage()
{
this.InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Navigation.Presentation;

public partial class ToFromQueryMainViewModel : ObservableObject
{
[ObservableProperty]
private IDictionary<string, object> user1;

[ObservableProperty]
private IDictionary<string, object> user2;

public ToFromQueryMainViewModel()
{
User1 = new Dictionary<string, object>
{
{ "QueryUser.Id", Guid.Parse("8a5c5b2e-ff96-474b-9e4d-65bde598f6bc") }
};

User2 = new Dictionary<string, object>
{
{ "QueryUser.Id", Guid.Parse("2b64071a-2c8a-45e4-9f48-3eb7d7aace41") }
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<RowDefinition />
</Grid.RowDefinitions>

<utu:NavigationBar Content="ToFromQuery Page">
<utu:NavigationBar Content="FromQuery/ToQuery User Page">
<utu:NavigationBar.MainCommand>
<AppBarButton>
<AppBarButton.Icon>
Expand Down
2 changes: 1 addition & 1 deletion UI/Navigation/src/global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
// 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.
"msbuild-sdks": {
"Uno.Sdk": "5.4.5"
"Uno.Sdk": "5.5.56"
},
"sdk": {
"allowPrerelease": false
Expand Down

0 comments on commit 1e39f85

Please sign in to comment.