diff --git a/.gitignore b/.gitignore index 487c1c28dc..0fdf90e9eb 100644 --- a/.gitignore +++ b/.gitignore @@ -204,4 +204,7 @@ FakesAssemblies/ .mfractor/ # Jetbrains files -.idea* \ No newline at end of file +.idea* + +# Binlog +*.binlog diff --git a/e2e/Uno/HelloWorld/Views/Shell.xaml b/e2e/Uno/HelloWorld/Views/Shell.xaml index 604bd8565b..6875627f88 100644 --- a/e2e/Uno/HelloWorld/Views/Shell.xaml +++ b/e2e/Uno/HelloWorld/Views/Shell.xaml @@ -4,27 +4,52 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:pr="using:Prism.Navigation.Regions" xmlns:pvm="using:Prism.Mvvm" + xmlns:toolkit="using:Uno.Toolkit.UI" pvm:ViewModelLocator.AutowireViewModel="true" xmlns:local="using:HelloWorld.Views" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" > - - - - - - + + + + + + + + + + + + + + + + + + - - - + - - + + + - - - + + + + diff --git a/e2e/Uno/HelloWorld/Views/Shell.xaml.cs b/e2e/Uno/HelloWorld/Views/Shell.xaml.cs index fe63257b92..5f2acc762c 100644 --- a/e2e/Uno/HelloWorld/Views/Shell.xaml.cs +++ b/e2e/Uno/HelloWorld/Views/Shell.xaml.cs @@ -1,12 +1,20 @@ +using Uno.Toolkit; + namespace HelloWorld.Views; /// /// An empty page that can be used on its own or navigated to within a Frame. /// -public sealed partial class Shell : Page +public sealed partial class Shell : Page, ILoadableShell { public Shell() { this.InitializeComponent(); } + + public ILoadable Source + { + get => Splash.Source; + set => Splash.Source = value; + } } diff --git a/e2e/Uno/HelloWorld/msbuild.binlog b/e2e/Uno/HelloWorld/msbuild.binlog deleted file mode 100644 index 3d43f4891c..0000000000 Binary files a/e2e/Uno/HelloWorld/msbuild.binlog and /dev/null differ diff --git a/src/Uno/Prism.Uno/ILoadableShell.cs b/src/Uno/Prism.Uno/ILoadableShell.cs new file mode 100644 index 0000000000..dff93e2a7e --- /dev/null +++ b/src/Uno/Prism.Uno/ILoadableShell.cs @@ -0,0 +1,9 @@ +using Uno.Toolkit; + +namespace Prism; + +#nullable enable +public interface ILoadableShell +{ + ILoadable Source { get; set; } +} diff --git a/src/Uno/Prism.Uno/Prism.Uno.WinUI.csproj b/src/Uno/Prism.Uno/Prism.Uno.WinUI.csproj index dbff630c03..c1b612c130 100644 --- a/src/Uno/Prism.Uno/Prism.Uno.WinUI.csproj +++ b/src/Uno/Prism.Uno/Prism.Uno.WinUI.csproj @@ -20,6 +20,7 @@ + diff --git a/src/Uno/Prism.Uno/PrismApplicationBase.cs b/src/Uno/Prism.Uno/PrismApplicationBase.cs index a9880815a9..95a1a9af4b 100644 --- a/src/Uno/Prism.Uno/PrismApplicationBase.cs +++ b/src/Uno/Prism.Uno/PrismApplicationBase.cs @@ -5,6 +5,7 @@ using Prism.Modularity; using Prism.Mvvm; using Prism.Navigation.Regions; +using Uno.Toolkit; using Application = Microsoft.UI.Xaml.Application; #nullable enable @@ -122,9 +123,16 @@ protected virtual void Initialize(IApplicationBuilder builder) RegisterFrameworkExceptionTypes(); + var loadable = new PrismShellLoadable(); var shell = CreateShell(); + if (shell != null) { + if (shell is ILoadableShell loadableShell) + { + loadableShell.Source = loadable; + } + MvvmHelpers.AutowireViewModel(shell); builder.Window.Content = shell; builder.Window.Activate(); @@ -136,6 +144,8 @@ void FinalizeInitialization() _host = builder.Build(); InitializeModules(); OnInitialized(); + loadable.FinishLoading(); + MvvmHelpers.ViewAndViewModelAction(shell, x => x.IsActive = true); } if (shell is FrameworkElement fe) diff --git a/src/Uno/Prism.Uno/PrismShellLoadable.cs b/src/Uno/Prism.Uno/PrismShellLoadable.cs new file mode 100644 index 0000000000..6c15fc239a --- /dev/null +++ b/src/Uno/Prism.Uno/PrismShellLoadable.cs @@ -0,0 +1,20 @@ +namespace Prism; + +#nullable enable +internal sealed class PrismShellLoadable : Uno.ILoadable, Uno.Toolkit.ILoadable +{ + public bool IsExecuting { get; private set; } = true; + + public bool IsLoaded { get; private set; } + + public event EventHandler? IsExecutingChanged; + public event EventHandler? Loaded; + + public void FinishLoading() + { + IsExecuting = false; + IsLoaded = true; + IsExecutingChanged?.Invoke(this, EventArgs.Empty); + Loaded?.Invoke(this, EventArgs.Empty); + } +}