From b4ea2f6d69188875d91064d4a7d7007511195ba8 Mon Sep 17 00:00:00 2001 From: Nick Randolph Date: Tue, 5 Jul 2022 13:12:38 +1000 Subject: [PATCH 1/2] chore(deps): Update to WinAppSdk 1.1.2 (cherry picked from commit 9f9d340df05019a864cb18b32cc0277dea29145b) --- .../Playground.Package/Playground.Windows.Package.wapproj | 2 +- samples/Playground/Playground.Windows/Playground.Windows.csproj | 2 +- .../MyExtensionsApp.Windows/MyExtensionsApp.Windows.csproj | 2 +- .../TestHarness/TestHarness.Windows/TestHarness.Windows.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/Playground/Playground.Package/Playground.Windows.Package.wapproj b/samples/Playground/Playground.Package/Playground.Windows.Package.wapproj index 001ab40920..06b3411abf 100644 --- a/samples/Playground/Playground.Package/Playground.Windows.Package.wapproj +++ b/samples/Playground/Playground.Package/Playground.Windows.Package.wapproj @@ -70,7 +70,7 @@ - + build diff --git a/samples/Playground/Playground.Windows/Playground.Windows.csproj b/samples/Playground/Playground.Windows/Playground.Windows.csproj index 13adf1b34e..43d22f9db5 100644 --- a/samples/Playground/Playground.Windows/Playground.Windows.csproj +++ b/samples/Playground/Playground.Windows/Playground.Windows.csproj @@ -49,7 +49,7 @@ - + diff --git a/src/Uno.Extensions.Templates/content/unoapp-extensions/MyExtensionsApp.Windows/MyExtensionsApp.Windows.csproj b/src/Uno.Extensions.Templates/content/unoapp-extensions/MyExtensionsApp.Windows/MyExtensionsApp.Windows.csproj index d89754ef7f..9171afd3f2 100644 --- a/src/Uno.Extensions.Templates/content/unoapp-extensions/MyExtensionsApp.Windows/MyExtensionsApp.Windows.csproj +++ b/src/Uno.Extensions.Templates/content/unoapp-extensions/MyExtensionsApp.Windows/MyExtensionsApp.Windows.csproj @@ -37,7 +37,7 @@ - + diff --git a/testing/TestHarness/TestHarness.Windows/TestHarness.Windows.csproj b/testing/TestHarness/TestHarness.Windows/TestHarness.Windows.csproj index cfa9ecfd9d..e88dfc5821 100644 --- a/testing/TestHarness/TestHarness.Windows/TestHarness.Windows.csproj +++ b/testing/TestHarness/TestHarness.Windows/TestHarness.Windows.csproj @@ -32,7 +32,7 @@ - + From 906eca35e31f1322b30e2c4113e85eefae64c109 Mon Sep 17 00:00:00 2001 From: Nick Randolph Date: Tue, 5 Jul 2022 15:44:34 +1000 Subject: [PATCH 2/2] fix: Navigation fixes for responsive nav (cherry picked from commit c97f362ea5b5cf9eb718197b53f7da879bf83895) --- .../Navigators/FrameNavigator.cs | 4 +- src/Uno.Extensions.Navigation.UI/Region.cs | 4 +- .../Regions/NavigationRegion.cs | 13 +++++-- .../RouteExtensions.cs | 23 ++++++------ .../TestHarness.Mobile.csproj | 15 ++++---- .../Apps/Commerce/CommerceDealsPage.xaml | 12 +++++- .../Apps/Commerce/CommerceDealsPage.xaml.cs | 8 +++- .../Apps/Commerce/CommerceHomePage.xaml | 36 +++++++++++------- .../Apps/Commerce/CommerceHomePage.xaml.cs | 2 +- .../Apps/Commerce/CommerceProductsPage.xaml | 11 +++++- .../Commerce/CommerceProductsPage.xaml.cs | 2 +- .../Navigation/Apps/ToDo/ToDoHomePage.xaml | 9 +++-- .../Navigation/Apps/ToDo/ToDoHomePage.xaml.cs | 2 +- .../Apps/ToDo/ToDoTaskListPage.xaml | 11 +++++- .../Apps/ToDo/ToDoTaskListPage.xaml.cs | 2 +- .../Responsive/ResponsiveListPage.xaml | 14 ++++++- .../Responsive/ResponsiveListPage.xaml.cs | 2 +- .../TestHarness.Shared/PageExtensions.cs | 37 ------------------- .../TestHarness.Skia.Gtk.csproj | 15 ++++---- .../TestHarness.Skia.Linux.FrameBuffer.csproj | 6 +-- .../TestHarness.Skia.Wpf.Host.csproj | 6 +-- .../TestHarness.Skia.WPF.csproj | 15 ++++---- .../Ext/Authentication/Custom/Given_Custom.cs | 3 +- .../Ext/Authentication/Msal/Given_Msal.cs | 3 +- .../Apps/Commerce/Given_Apps_Commerce.cs | 13 +++---- .../Navigation/Apps/ToDo/Given_Apps_ToDo.cs | 5 +-- .../Navigation/Responsive/Given_Responsive.cs | 5 +-- .../TestHarness.Wasm/TestHarness.Wasm.csproj | 15 ++++---- .../TestHarness.Windows.csproj | 9 +++-- 29 files changed, 162 insertions(+), 140 deletions(-) diff --git a/src/Uno.Extensions.Navigation.UI/Navigators/FrameNavigator.cs b/src/Uno.Extensions.Navigation.UI/Navigators/FrameNavigator.cs index 0c0c376712..309f465357 100644 --- a/src/Uno.Extensions.Navigation.UI/Navigators/FrameNavigator.cs +++ b/src/Uno.Extensions.Navigation.UI/Navigators/FrameNavigator.cs @@ -96,7 +96,7 @@ viewType is null || } var route = request.Route; - var segments = route.ForwardNavigationSegments(Resolver, Region, includeDependsOnRoutes: true); + var segments = route.ForwardNavigationSegments(Resolver, Region); // As this is a forward navigation if (segments.Length == 0) @@ -128,7 +128,7 @@ viewType is null || // Rebuild the nested region hierarchy Control.ReassignRegionParent(); if (segments.Length > 1 || - string.IsNullOrWhiteSpace(request.Route.Path)) + !string.IsNullOrWhiteSpace(request.Route.Path)) { refreshViewModel = true; } diff --git a/src/Uno.Extensions.Navigation.UI/Region.cs b/src/Uno.Extensions.Navigation.UI/Region.cs index 0e8696b68f..94edb71cd8 100644 --- a/src/Uno.Extensions.Navigation.UI/Region.cs +++ b/src/Uno.Extensions.Navigation.UI/Region.cs @@ -87,12 +87,12 @@ public static IRegion GetInstance(this DependencyObject element) return (IRegion)element.GetValue(InstanceProperty); } - public static void SetAttached(DependencyObject element, bool value) + public static void SetAttached(this DependencyObject element, bool value) { element.SetValue(AttachedProperty, value); } - public static bool GetAttached(DependencyObject element) + public static bool GetAttached(this DependencyObject element) { return (bool)element.GetValue(AttachedProperty); } diff --git a/src/Uno.Extensions.Navigation.UI/Regions/NavigationRegion.cs b/src/Uno.Extensions.Navigation.UI/Regions/NavigationRegion.cs index 5a89bf196b..b9ed703a9a 100644 --- a/src/Uno.Extensions.Navigation.UI/Regions/NavigationRegion.cs +++ b/src/Uno.Extensions.Navigation.UI/Regions/NavigationRegion.cs @@ -58,9 +58,16 @@ public NavigationRegion(FrameworkElement? view = null, IServiceProvider? service View = view; if (View is not null) { - View.Loading += ViewLoading; - View.Loaded += ViewLoaded; View.SetInstance(this); + if (!View.IsLoaded) + { + View.Loading += ViewLoading; + View.Loaded += ViewLoaded; + } + else + { + View.Unloaded += ViewUnloaded; + } } if (services is not null) @@ -137,7 +144,7 @@ private Task HandleLoading() private void AssignParent() { - if (View is null || _isRoot) + if (View is null || _isRoot || !View.GetAttached()) { return; } diff --git a/src/Uno.Extensions.Navigation.UI/RouteExtensions.cs b/src/Uno.Extensions.Navigation.UI/RouteExtensions.cs index aecb770233..b8978ab72a 100644 --- a/src/Uno.Extensions.Navigation.UI/RouteExtensions.cs +++ b/src/Uno.Extensions.Navigation.UI/RouteExtensions.cs @@ -65,8 +65,7 @@ public static bool FrameIsBackNavigation(this Route route) => public static (Route, RouteInfo?, bool)[] ForwardNavigationSegments( this Route route, IRouteResolver mappings, - IRegion region, - bool includeDependsOnRoutes) + IRegion region) { // Here we're interested in the actual page navigation segments. // Start with an empty list, and progressively add routes that @@ -80,7 +79,7 @@ public static (Route, RouteInfo?, bool)[] ForwardNavigationSegments( // For routes that have a depends on, we need to ensure that // the dependson segments are added to the segments list - var r = includeDependsOnRoutes ? route.RootDependsOn(mappings, region, false) : route; + var r = route.RootDependsOn(mappings, region, false); var map = mappings.Find(r); var originalRoute = false; while ( @@ -375,7 +374,7 @@ public static IDictionary AsParameters(this IDictionary AsParameters(this IDictionary AsParameters(this IDictionary + - - - + + + - - - + + + + diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Commerce/CommerceDealsPage.xaml b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Commerce/CommerceDealsPage.xaml index 83a99654df..ad54cbfbd4 100644 --- a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Commerce/CommerceDealsPage.xaml +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Commerce/CommerceDealsPage.xaml @@ -8,14 +8,19 @@ xmlns:utu="using:Uno.Toolkit.UI" xmlns:uen="using:Uno.Extensions.Navigation.UI" xmlns:um="using:Uno.Material" + xmlns:triggers="using:CommunityToolkit.WinUI.UI.Triggers" mc:Ignorable="d" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" NavigationCacheMode="Required"> - + - + + + + @@ -34,6 +39,9 @@ + + + @@ -75,6 +83,7 @@ - + - + - + @@ -18,11 +19,15 @@ FontSize="32" /> - + + + + @@ -37,6 +42,10 @@ + + + diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/ToDo/ToDoTaskListPage.xaml.cs b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/ToDo/ToDoTaskListPage.xaml.cs index 77a0d5a3f7..8d26b0b21a 100644 --- a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/ToDo/ToDoTaskListPage.xaml.cs +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/ToDo/ToDoTaskListPage.xaml.cs @@ -7,7 +7,7 @@ public ToDoTaskListPage() { this.InitializeComponent(); - this.ApplyAdaptiveTrigger(App.Current.Resources["WideMinWindowWidth"] is double width ? width : 0.0, nameof(Narrow), nameof(Wide)); + } diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Responsive/ResponsiveListPage.xaml b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Responsive/ResponsiveListPage.xaml index 3a1c43b0a6..7d6d3f29fc 100644 --- a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Responsive/ResponsiveListPage.xaml +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Responsive/ResponsiveListPage.xaml @@ -8,13 +8,17 @@ xmlns:models="using:TestHarness.Models" xmlns:uen="using:Uno.Extensions.Navigation.UI" xmlns:utu="using:Uno.Toolkit.UI" + xmlns:triggers="using:CommunityToolkit.WinUI.UI.Triggers" NavigationCacheMode="Required"> - + - + + + @@ -28,6 +32,12 @@ Value="true" /> + + + + + diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Responsive/ResponsiveListPage.xaml.cs b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Responsive/ResponsiveListPage.xaml.cs index ad86f1014c..4e57959239 100644 --- a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Responsive/ResponsiveListPage.xaml.cs +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Responsive/ResponsiveListPage.xaml.cs @@ -7,6 +7,6 @@ public ResponsiveListPage() { this.InitializeComponent(); - this.ApplyAdaptiveTrigger(App.Current.Resources["WideMinWindowWidth"] is double width ? width : 0.0, nameof(Narrow), nameof(Wide)); + } } diff --git a/testing/TestHarness/TestHarness.Shared/PageExtensions.cs b/testing/TestHarness/TestHarness.Shared/PageExtensions.cs index 705bce0c8b..5f2e2e7bcd 100644 --- a/testing/TestHarness/TestHarness.Shared/PageExtensions.cs +++ b/testing/TestHarness/TestHarness.Shared/PageExtensions.cs @@ -2,43 +2,6 @@ public static class PageExtensions { - public static void ApplyAdaptiveTrigger(this Page page, double threshold, string narrowState, string wideState) - { - new ResponsiveState(page, threshold, narrowState, wideState).Connect(); - } - private record ResponsiveState(Page Page, double Threshold, string NarrowState, string WideState) - { - private string? _currentState; - - public void Connect() - { - Page.Loaded += async (s, e) => await Resize(true); - Page.SizeChanged += async (s, e) => await Resize(false); - } - - private async Task Resize(bool refresh) - { - double newWidth = Page.ActualWidth; - - if (newWidth <= 0) - { - return; - } - - - var newState = newWidth > Threshold ? WideState : NarrowState; - if (_currentState != newState || refresh) - { - _currentState = newState; - // Task.Yield is required as we're setting visual states in code. If the - // Region.Attached property is set to fast, it doesn't connect up the region - // correctly. This isn't an issue when the visual states are driven using - // adaptive triggers - await Task.Yield(); - VisualStateManager.GoToState(Page, newState, false); - } - } - } } diff --git a/testing/TestHarness/TestHarness.Skia.Gtk/TestHarness.Skia.Gtk.csproj b/testing/TestHarness/TestHarness.Skia.Gtk/TestHarness.Skia.Gtk.csproj index 20b28735d4..4ab520cca0 100644 --- a/testing/TestHarness/TestHarness.Skia.Gtk/TestHarness.Skia.Gtk.csproj +++ b/testing/TestHarness/TestHarness.Skia.Gtk/TestHarness.Skia.Gtk.csproj @@ -15,19 +15,20 @@ + - - - - - - + + + + + + + diff --git a/testing/TestHarness/TestHarness.Skia.Linux.FrameBuffer/TestHarness.Skia.Linux.FrameBuffer.csproj b/testing/TestHarness/TestHarness.Skia.Linux.FrameBuffer/TestHarness.Skia.Linux.FrameBuffer.csproj index 47242c92a4..a48bb8f7d4 100644 --- a/testing/TestHarness/TestHarness.Skia.Linux.FrameBuffer/TestHarness.Skia.Linux.FrameBuffer.csproj +++ b/testing/TestHarness/TestHarness.Skia.Linux.FrameBuffer/TestHarness.Skia.Linux.FrameBuffer.csproj @@ -15,9 +15,9 @@ - - - + + + \ No newline at end of file diff --git a/testing/TestHarness/TestHarness.Skia.WPF.Host/TestHarness.Skia.Wpf.Host.csproj b/testing/TestHarness/TestHarness.Skia.WPF.Host/TestHarness.Skia.Wpf.Host.csproj index 12e8a077f7..8ffe721263 100644 --- a/testing/TestHarness/TestHarness.Skia.WPF.Host/TestHarness.Skia.Wpf.Host.csproj +++ b/testing/TestHarness/TestHarness.Skia.WPF.Host/TestHarness.Skia.Wpf.Host.csproj @@ -7,9 +7,9 @@ app.manifest - - - + + + diff --git a/testing/TestHarness/TestHarness.Skia.WPF/TestHarness.Skia.WPF.csproj b/testing/TestHarness/TestHarness.Skia.WPF/TestHarness.Skia.WPF.csproj index dd50589b3b..60dd9accfa 100644 --- a/testing/TestHarness/TestHarness.Skia.WPF/TestHarness.Skia.WPF.csproj +++ b/testing/TestHarness/TestHarness.Skia.WPF/TestHarness.Skia.WPF.csproj @@ -4,19 +4,20 @@ + - - - - - - + + + + + + + diff --git a/testing/TestHarness/TestHarness.UITest/Ext/Authentication/Custom/Given_Custom.cs b/testing/TestHarness/TestHarness.UITest/Ext/Authentication/Custom/Given_Custom.cs index 8a9570db18..a903eb50f5 100644 --- a/testing/TestHarness/TestHarness.UITest/Ext/Authentication/Custom/Given_Custom.cs +++ b/testing/TestHarness/TestHarness.UITest/Ext/Authentication/Custom/Given_Custom.cs @@ -2,9 +2,8 @@ public class Given_Custom : NavigationTestBase { - // TODO: Fix UI Test fail // [Test] - public async Task When_Custom() + public async Task When_Custom_Auth() { InitTestSection(TestSections.Authentication_Custom); diff --git a/testing/TestHarness/TestHarness.UITest/Ext/Authentication/Msal/Given_Msal.cs b/testing/TestHarness/TestHarness.UITest/Ext/Authentication/Msal/Given_Msal.cs index 3526dd2f79..805bac1582 100644 --- a/testing/TestHarness/TestHarness.UITest/Ext/Authentication/Msal/Given_Msal.cs +++ b/testing/TestHarness/TestHarness.UITest/Ext/Authentication/Msal/Given_Msal.cs @@ -2,9 +2,8 @@ public class Given_Msal : NavigationTestBase { - // TODO: Fix UI Test fail // [Test] - public async Task When_Multi() + public async Task When_Multi_Auth() { InitTestSection(TestSections.Authentication_Multi); diff --git a/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Apps/Commerce/Given_Apps_Commerce.cs b/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Apps/Commerce/Given_Apps_Commerce.cs index e6c913cc85..4a03a9b1a9 100644 --- a/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Apps/Commerce/Given_Apps_Commerce.cs +++ b/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Apps/Commerce/Given_Apps_Commerce.cs @@ -2,9 +2,8 @@ public class Given_Apps_Commerce : NavigationTestBase { - // TODO: Work out why this is failing - //[Test] - public async Task When_Responsive() + [Test] + public async Task When_Commerce_Responsive() { InitTestSection(TestSections.Apps_Commerce); @@ -28,14 +27,14 @@ public async Task When_Responsive() await App.TapAndWait("ProfileTabBarItem", "ProfileNavigationBar"); // Select a deal - await App.TapAndWait("DealsTabBarItem", "DealsNavigationBar"); + await App.TapAndWait("DealsTabBarItem", "DealsListView"); await App.SelectListViewIndexAndWait("DealsListView", "1", "ProductDetailsNavigationBar"); await App.TapAndWait("DetailsBackButton", "DealsNavigationBar"); // Select a product - await App.TapAndWait("ProductsTabBarItem", "ProductsNavigationBar"); + await App.TapAndWait("ProductsTabBarItem", "ProductsListView"); await App.SelectListViewIndexAndWait("ProductsListView", "2", "ProductDetailsNavigationBar"); @@ -68,14 +67,14 @@ public async Task When_Responsive() // Select a deal - await App.TapAndWait("DealsNavigationViewItem","DealsNavigationBar"); + await App.TapAndWait("DealsNavigationViewItem", "DealsListView"); await App.SelectListViewIndexAndWait("DealsListView", "2", "ProductDetailsNavigationBar"); App.WaitForElement("DealsNavigationBar"); // Select a product - await App.TapAndWait("ProductsNavigationViewItem","ProductsNavigationBar"); + await App.TapAndWait("ProductsNavigationViewItem", "ProductsListView"); await App.SelectListViewIndexAndWait("ProductsListView", "1", "ProductDetailsNavigationBar"); App.WaitForElement("ProductsNavigationBar"); diff --git a/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Apps/ToDo/Given_Apps_ToDo.cs b/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Apps/ToDo/Given_Apps_ToDo.cs index bdb730401a..133e88519d 100644 --- a/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Apps/ToDo/Given_Apps_ToDo.cs +++ b/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Apps/ToDo/Given_Apps_ToDo.cs @@ -2,9 +2,8 @@ public class Given_Apps_ToDo : NavigationTestBase { - // TODO: Work out why this is failing - //[Test] - public async Task When_Responsive() + [Test] + public async Task When_ToDo_Responsive() { InitTestSection(TestSections.Apps_ToDo); diff --git a/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Responsive/Given_Responsive.cs b/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Responsive/Given_Responsive.cs index 779b101e2a..9806f9fe0d 100644 --- a/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Responsive/Given_Responsive.cs +++ b/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Responsive/Given_Responsive.cs @@ -2,9 +2,8 @@ public class Given_Responsive : NavigationTestBase { - // TODO: Work out why this is failing - //[Test] - public async Task When_Responsive() + [Test] + public async Task When_Navigation_Responsive() { InitTestSection(TestSections.Responsive); diff --git a/testing/TestHarness/TestHarness.Wasm/TestHarness.Wasm.csproj b/testing/TestHarness/TestHarness.Wasm/TestHarness.Wasm.csproj index ef7d0d71cf..3f28fe87bd 100644 --- a/testing/TestHarness/TestHarness.Wasm/TestHarness.Wasm.csproj +++ b/testing/TestHarness/TestHarness.Wasm/TestHarness.Wasm.csproj @@ -45,6 +45,7 @@ + @@ -52,15 +53,15 @@ - - - + + + - - - + + + + diff --git a/testing/TestHarness/TestHarness.Windows/TestHarness.Windows.csproj b/testing/TestHarness/TestHarness.Windows/TestHarness.Windows.csproj index e88dfc5821..0fe814fd43 100644 --- a/testing/TestHarness/TestHarness.Windows/TestHarness.Windows.csproj +++ b/testing/TestHarness/TestHarness.Windows/TestHarness.Windows.csproj @@ -30,6 +30,7 @@ + @@ -38,10 +39,10 @@ - - - + + + +