Skip to content

Commit

Permalink
Toplevel - Fix system theme not being applied at launch on some platf…
Browse files Browse the repository at this point in the history
…orms (#16159)

* move platformbinding for theme variant from WindowBase up to TopLevel.

* remvoe visibility check in android insets manager for system theme
  • Loading branch information
emmauss authored Jun 28, 2024
1 parent 6b0f09a commit 3b235f9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
10 changes: 0 additions & 10 deletions src/Android/Avalonia.Android/Platform/AndroidInsetsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,6 @@ public SystemBarTheme? SystemBarTheme
{
_statusBarTheme = value;

if (!_topLevel.View.IsShown)
{
return;
}

var compat = new WindowInsetsControllerCompat(Window, _topLevel.View);

if (_isDefaultSystemBarLightTheme == null)
Expand Down Expand Up @@ -229,11 +224,6 @@ public bool? IsSystemBarVisible
{
_systemUiVisibility = value;

if (!_topLevel.View.IsShown)
{
return;
}

var compat = WindowCompat.GetInsetsController(Window, _topLevel.View);

if (value == null || value.Value)
Expand Down
5 changes: 5 additions & 0 deletions src/Avalonia.Controls/TopLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ public TopLevel(ITopLevelImpl impl, IAvaloniaDependencyResolver? dependencyResol
impl.TransparencyLevelChanged = HandleTransparencyLevelChanged;

CreatePlatformImplBinding(TransparencyLevelHintProperty, hint => PlatformImpl.SetTransparencyLevelHint(hint ?? Array.Empty<WindowTransparencyLevel>()));
CreatePlatformImplBinding(ActualThemeVariantProperty, variant =>
{
variant ??= ThemeVariant.Default;
PlatformImpl?.SetFrameThemeVariant((PlatformThemeVariant?)variant ?? PlatformThemeVariant.Light);
});

_keyboardNavigationHandler?.SetOwner(this);
_accessKeyHandler?.SetOwner(this);
Expand Down
5 changes: 0 additions & 5 deletions src/Avalonia.Controls/WindowBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ static WindowBase()
public WindowBase(IWindowBaseImpl impl) : this(impl, AvaloniaLocator.Current)
{
CreatePlatformImplBinding(TopmostProperty, topmost => PlatformImpl!.SetTopmost(topmost));
CreatePlatformImplBinding(ActualThemeVariantProperty, variant =>
{
variant ??= ThemeVariant.Default;
PlatformImpl?.SetFrameThemeVariant((PlatformThemeVariant?)variant ?? PlatformThemeVariant.Light);
});

FrameSize = impl.FrameSize;
}
Expand Down

0 comments on commit 3b235f9

Please sign in to comment.