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

chore: Adjust nav sample to properly navigate with to from query #860

Merged
merged 2 commits into from
Jan 28, 2025
Merged
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
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