Skip to content

Commit

Permalink
fix(StatusBar): OS theme change no longer crashes app (#867)
Browse files Browse the repository at this point in the history
  • Loading branch information
silviuo committed Oct 16, 2023
1 parent 01d3e0a commit 4e2e33c
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/Uno.Toolkit.UI/Behaviors/StatusBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,21 @@ private static void OnUISettingsColorValuesChanged(UISettings sender, object arg
{
if (_lastActivePage is { } page)
{
if (GetSubscription(page) != null &&
GetForeground(page) is StatusBarForegroundTheme.Auto or StatusBarForegroundTheme.AutoInverse &&
GetSystemTheme() is var theme && theme != _lastAppliedTheme)
{
// this will prevent deadlock, as setting the XamlStatusBar.Foreground will trigger ColorValuesChanged
_lastAppliedTheme = theme;

UpdateStatusBar(page);
}
#if !HAS_UNO
page.GetDispatcherCompat().Schedule(() => {
#endif
if (GetSubscription(page) != null &&
GetForeground(page) is StatusBarForegroundTheme.Auto or StatusBarForegroundTheme.AutoInverse &&
GetSystemTheme() is var theme && theme != _lastAppliedTheme)
{
// this will prevent deadlock, as setting the XamlStatusBar.Foreground will trigger ColorValuesChanged
_lastAppliedTheme = theme;
UpdateStatusBar(page);
}
#if !HAS_UNO
});
#endif
}
}

Expand Down

0 comments on commit 4e2e33c

Please sign in to comment.