From e78b7cbdeb6a9b64d8a9785dd01b81d9d853ca0a Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Tue, 11 Feb 2025 14:58:52 +0100 Subject: [PATCH] chore: Adjust check (cherry picked from commit 1cf85d7e9b56f267254b442bafe66b320f84c0f8) --- src/Uno.UI/UI/Xaml/Application.Android.cs | 10 +++++++++- src/Uno.UI/UI/Xaml/Application.cs | 5 +---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Uno.UI/UI/Xaml/Application.Android.cs b/src/Uno.UI/UI/Xaml/Application.Android.cs index bca6f2c491a1..3c1991f18086 100644 --- a/src/Uno.UI/UI/Xaml/Application.Android.cs +++ b/src/Uno.UI/UI/Xaml/Application.Android.cs @@ -32,5 +32,13 @@ static partial void StartPartial(ApplicationInitializationCallback callback) /// private DateTimeOffset GetSuspendingOffset() => DateTimeOffset.Now.AddSeconds(5); - partial void ApplySystemOverlaysTheming() => NativeWindowWrapper.Instance?.ApplySystemOverlaysTheming(); + partial void ApplySystemOverlaysTheming() + { + // This is needed only due to the fact that currently Instance accessor creates the wrapper + // eagerly - which could then happen too early. Will no longer be needed when un-singletoned. + if (InitializationComplete) + { + NativeWindowWrapper.Instance.ApplySystemOverlaysTheming(); + } + } } diff --git a/src/Uno.UI/UI/Xaml/Application.cs b/src/Uno.UI/UI/Xaml/Application.cs index d8d940f7e448..82c5e18e6897 100644 --- a/src/Uno.UI/UI/Xaml/Application.cs +++ b/src/Uno.UI/UI/Xaml/Application.cs @@ -444,10 +444,7 @@ private void SetRequestedTheme(ApplicationTheme requestedTheme) internal void OnRequestedThemeChanged() { - if (InitializationComplete) - { - ApplySystemOverlaysTheming(); - } + ApplySystemOverlaysTheming(); OnResourcesChanged(ResourceUpdateReason.ThemeResource); }