From 6eecda4e98d3b761998be871698bdde40190ea81 Mon Sep 17 00:00:00 2001 From: Rafael Rosa Date: Wed, 3 Jan 2024 11:08:46 -0300 Subject: [PATCH] chore: keep just for wasm --- Uno.Gallery/Uno.Gallery.Shared/App.xaml.cs | 30 ++++++++-------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/Uno.Gallery/Uno.Gallery.Shared/App.xaml.cs b/Uno.Gallery/Uno.Gallery.Shared/App.xaml.cs index ad4d7d966..6a4ddbbc0 100644 --- a/Uno.Gallery/Uno.Gallery.Shared/App.xaml.cs +++ b/Uno.Gallery/Uno.Gallery.Shared/App.xaml.cs @@ -29,8 +29,6 @@ public partial class App : Application public Window MainWindow { get; private set; } - private static Sample[] _samples; - private Shell _shell; /// @@ -67,11 +65,10 @@ protected override void OnLaunched(LaunchActivatedEventArgs e) base.OnLaunched(e); this.Log().Debug("Launched app."); - this.Log().Debug(e.Arguments.ToString()); - OnLaunchedOrActivated(e); + OnLaunchedOrActivated(); } - private void OnLaunchedOrActivated(LaunchActivatedEventArgs e) + private void OnLaunchedOrActivated() { #if WINDOWS && !HAS_UNO MainWindow = new Window(); @@ -87,7 +84,7 @@ private void OnLaunchedOrActivated(LaunchActivatedEventArgs e) Xamarin.Calabash.Start(); #endif - MainWindow.Content = _shell = BuildShell(e); + MainWindow.Content = _shell = BuildShell(); } // Ensure the current window is active @@ -223,15 +220,16 @@ public void SearchShellNavigateTo(Sample sample) _shell.NavigationView.Content = page; } - private Shell BuildShell(LaunchActivatedEventArgs e) + private Shell BuildShell() { _shell = new Shell(); AutomationProperties.SetAutomationId(_shell, "AppShell"); _shell.RegisterPropertyChangedCallback(Shell.CurrentSampleBackdoorProperty, OnCurrentSampleBackdoorChanged); var nv = _shell.NavigationView; AddNavigationItems(nv); - - if (!IsThereSampleFilteredByArgs(nv, e)) +#if __WASM__ + if (!IsThereSampleFilteredByArgs(nv)) +#endif { // landing navigation ShellNavigateTo( @@ -247,14 +245,10 @@ private Shell BuildShell(LaunchActivatedEventArgs e) return _shell; } - - private bool IsThereSampleFilteredByArgs(MUXC.NavigationView nv, LaunchActivatedEventArgs e) - { #if __WASM__ + private bool IsThereSampleFilteredByArgs(MUXC.NavigationView nv) + { var argumentsHash = Wasm.FragmentNavigationHandler.CurrentFragment; -#else - var argumentsHash = e.Arguments; -#endif if (argumentsHash.Contains("#")) { string searchTerm = (argumentsHash + string.Empty).Replace("#", string.Empty); @@ -269,21 +263,17 @@ private bool IsThereSampleFilteredByArgs(MUXC.NavigationView nv, LaunchActivated { ShellNavigateTo( (Uno.Gallery.Sample)sampleItem.DataContext -#if !WINDOWS - // workaround for uno#5069: setting NavView.SelectedItem at launch bricks it , trySynchronizeCurrentItem: false -#endif ); return true; } } -#if __WASM__ //If there is a Hash that is not valid, redirect it to the root of the site. Wasm.LocationHrefNavigationHandler.CurrentLocationHref = "/"; -#endif } return false; } +#endif private void OnCurrentSampleBackdoorChanged(DependencyObject sender, DependencyProperty dp) {