Skip to content

Commit

Permalink
chore: keep just for wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
rafael-rosa-knowcode committed Jan 30, 2024
1 parent 296d4f9 commit a2095df
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions Uno.Gallery/Uno.Gallery.Shared/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public partial class App : Application

public Window MainWindow { get; private set; }

private static Sample[] _samples;

private Shell _shell;

/// <summary>
Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand Down Expand Up @@ -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<OverviewPage>(
Expand All @@ -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);
Expand All @@ -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)
{
Expand Down

0 comments on commit a2095df

Please sign in to comment.