-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Mac Catalyst] TitleBar not reacting on UserAppTheme changes #30525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Hey there @@kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures the custom TitleBar updates its background color when the user switches app themes by reacting to trait collection changes.
- Added an override of
TraitCollectionDidChange
to reset the TitleBar’s background on theme change. - Used
UIColor.SecondarySystemBackground
for adaptive coloring. - Suppressed CA1422 warnings around the base call for backward‐compatibility checks.
Comments suppressed due to low confidence (1)
src/Core/src/Platform/iOS/WindowViewController.cs:74
- This override handles theme changes at runtime; please add a corresponding UI test in
TestCases.HostApp
and an automated test inTestCases.Shared.Tests
to verify that the TitleBar background updates correctly when the app theme changes.
public override void TraitCollectionDidChange(UITraitCollection? previousTraitCollection)
#pragma warning disable CA1422 // Validate platform compatibility | ||
base.TraitCollectionDidChange(previousTraitCollection); | ||
#pragma warning restore CA1422 // Validate platform compatibility | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than disabling the platform compatibility analyzer via pragmas, consider using platform compatibility guards such as if (OperatingSystem.IsIOSVersionAtLeast(13))
or marking the override with [SupportedOSPlatform("ios13.0")]
to clearly express the iOS 13+ dependency and maintain analyzer support.
#pragma warning disable CA1422 // Validate platform compatibility | |
base.TraitCollectionDidChange(previousTraitCollection); | |
#pragma warning restore CA1422 // Validate platform compatibility | |
[SupportedOSPlatform("ios13.0")] | |
public override void TraitCollectionDidChange(UITraitCollection? previousTraitCollection) | |
{ | |
base.TraitCollectionDidChange(previousTraitCollection); | |
if (_titleBar is not null && _iTitleBarRef.TryGetTarget(out IView? iTitleBar) && iTitleBar?.Background is null) | |
{ | |
_titleBar.BackgroundColor = UIColor.SecondarySystemBackground; | |
} | |
} |
Copilot uses AI. Check for mistakes.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
This needs to be fixed on Windows, likewise
Issues Fixed
Fixes #30518
Screen.Recording.2025-07-10.at.02.20.20.mov
Screen.Recording.2025-07-10.at.02.21.04.mov