diff --git a/.gitignore b/.gitignore index 3698cd9b4..596f1ee67 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ Resource.Designer.cs # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs +.DS_Store # Build results [Dd]ebug[-\w]*/ diff --git a/UI/SplashScreenSample/SplashScreenSample.Mobile/SplashScreenSample.Mobile.csproj b/UI/SplashScreenSample/SplashScreenSample.Mobile/SplashScreenSample.Mobile.csproj index f82bf9976..04eab427b 100644 --- a/UI/SplashScreenSample/SplashScreenSample.Mobile/SplashScreenSample.Mobile.csproj +++ b/UI/SplashScreenSample/SplashScreenSample.Mobile/SplashScreenSample.Mobile.csproj @@ -14,6 +14,7 @@ osx-x64 + diff --git a/UI/SplashScreenSample/SplashScreenSample.Shared/App.xaml b/UI/SplashScreenSample/SplashScreenSample.Shared/App.xaml index c9c900926..7361f11c2 100644 --- a/UI/SplashScreenSample/SplashScreenSample.Shared/App.xaml +++ b/UI/SplashScreenSample/SplashScreenSample.Shared/App.xaml @@ -8,8 +8,9 @@ - - + + + diff --git a/UI/SplashScreenSample/SplashScreenSample.Shared/App.xaml.cs b/UI/SplashScreenSample/SplashScreenSample.Shared/App.xaml.cs index f65f68694..39708dbb7 100644 --- a/UI/SplashScreenSample/SplashScreenSample.Shared/App.xaml.cs +++ b/UI/SplashScreenSample/SplashScreenSample.Shared/App.xaml.cs @@ -3,6 +3,7 @@ using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Navigation; using System; +using System.Threading.Tasks; using Windows.ApplicationModel; using Windows.ApplicationModel.Activation; @@ -58,7 +59,7 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page - rootFrame = new Frame(); + rootFrame = WaitWithSplashScreen(); rootFrame.NavigationFailed += OnNavigationFailed; @@ -66,9 +67,6 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar { // TODO: Load state from previously suspended application } - - // Place the frame in the current Window - _window.Content = rootFrame; } #if !(NET6_0_OR_GREATER && WINDOWS) @@ -111,6 +109,34 @@ private void OnSuspending(object sender, SuspendingEventArgs e) deferral.Complete(); } + private Frame WaitWithSplashScreen() where T : Page, new() + { + var shell = new Shell(); + if (Shell.IsSplashCapable) + { + _window.Content = shell; + + Frame rootFrame = new Frame(); + async void PageNavigated(object s, NavigationEventArgs e) + { + await Task.Delay(3000); + _window.Content = rootFrame; + rootFrame.Navigated -= PageNavigated; + }; + + rootFrame.Navigated += PageNavigated; + rootFrame.Navigate(typeof(T)); + return rootFrame; + } + else + { + var page = new T(); + Frame rootFrame = new Frame(); + rootFrame.Navigate(typeof(T)); + return rootFrame; + } + } + /// /// Configures global Uno Platform logging /// diff --git a/UI/SplashScreenSample/SplashScreenSample.Shared/Shell.xaml b/UI/SplashScreenSample/SplashScreenSample.Shared/Shell.xaml new file mode 100644 index 000000000..a38bac723 --- /dev/null +++ b/UI/SplashScreenSample/SplashScreenSample.Shared/Shell.xaml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UI/SplashScreenSample/SplashScreenSample.Shared/Shell.xaml.cs b/UI/SplashScreenSample/SplashScreenSample.Shared/Shell.xaml.cs new file mode 100644 index 000000000..6a3b040ff --- /dev/null +++ b/UI/SplashScreenSample/SplashScreenSample.Shared/Shell.xaml.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; + +namespace SplashScreenSample +{ + public sealed partial class Shell : UserControl + { + public static bool IsSplashCapable = false; + + public Shell() + { + this.InitializeComponent(); +#if NET6_0_OR_GREATER && WINDOWS && !HAS_UNO + IsSplashCapable = true; +#endif + } + } +} \ No newline at end of file diff --git a/UI/SplashScreenSample/SplashScreenSample.Shared/SplashScreenSample.Shared.projitems b/UI/SplashScreenSample/SplashScreenSample.Shared/SplashScreenSample.Shared.projitems index 79adaaed7..78b20123e 100644 --- a/UI/SplashScreenSample/SplashScreenSample.Shared/SplashScreenSample.Shared.projitems +++ b/UI/SplashScreenSample/SplashScreenSample.Shared/SplashScreenSample.Shared.projitems @@ -21,12 +21,16 @@ MainPage.xaml + + Shell.xaml + Designer MSBuild:Compile + diff --git a/UI/SplashScreenSample/SplashScreenSample.Skia.Gtk/SplashScreenSample.Skia.Gtk.csproj b/UI/SplashScreenSample/SplashScreenSample.Skia.Gtk/SplashScreenSample.Skia.Gtk.csproj index 330411d48..9f80ac7d0 100644 --- a/UI/SplashScreenSample/SplashScreenSample.Skia.Gtk/SplashScreenSample.Skia.Gtk.csproj +++ b/UI/SplashScreenSample/SplashScreenSample.Skia.Gtk/SplashScreenSample.Skia.Gtk.csproj @@ -16,6 +16,7 @@ + diff --git a/UI/SplashScreenSample/SplashScreenSample.Skia.WPF/SplashScreenSample.Skia.WPF.csproj b/UI/SplashScreenSample/SplashScreenSample.Skia.WPF/SplashScreenSample.Skia.WPF.csproj index d3356143a..19ef31d08 100644 --- a/UI/SplashScreenSample/SplashScreenSample.Skia.WPF/SplashScreenSample.Skia.WPF.csproj +++ b/UI/SplashScreenSample/SplashScreenSample.Skia.WPF/SplashScreenSample.Skia.WPF.csproj @@ -22,6 +22,7 @@ + diff --git a/UI/SplashScreenSample/SplashScreenSample.Wasm/SplashScreenSample.Wasm.csproj b/UI/SplashScreenSample/SplashScreenSample.Wasm/SplashScreenSample.Wasm.csproj index a008a4d41..f38454406 100644 --- a/UI/SplashScreenSample/SplashScreenSample.Wasm/SplashScreenSample.Wasm.csproj +++ b/UI/SplashScreenSample/SplashScreenSample.Wasm/SplashScreenSample.Wasm.csproj @@ -48,6 +48,7 @@ + diff --git a/UI/SplashScreenSample/SplashScreenSample.Windows/SplashScreenSample.Windows.csproj b/UI/SplashScreenSample/SplashScreenSample.Windows/SplashScreenSample.Windows.csproj index 92b13b122..e2d8c9914 100644 --- a/UI/SplashScreenSample/SplashScreenSample.Windows/SplashScreenSample.Windows.csproj +++ b/UI/SplashScreenSample/SplashScreenSample.Windows/SplashScreenSample.Windows.csproj @@ -28,6 +28,7 @@ +