maui
maui copied to clipboard
[macOS/iOS] Fix RequestedThemeChanged event
Description of Change
Fix RequestedThemeChanged event using Shell on macOS/iOS.
We use the page controller to detect theme changes thanks to traitCollectionDidChange
. However, with Shell this doesn't work and the default project template uses Shell. This PR applies changes to detect changes in themes also using Shell.
Issues Fixed
Fixes #10055 Fixes #10310 Fixes #11005 Fixes #11119
When will the changes be available in the .net 6 stable version?
When will the changes be available in the .net 6 stable version?
This will probably not land in .NET 6 as it introduces new APIs and thus breaking changes. This will become available in .NET 8 or if we decide this is crucial in .NET 7 maybe.
When will the changes be available in the .net 6 stable version?
This will probably not land in .NET 6 as it introduces new APIs and thus breaking changes. This will become available in .NET 8 or if we decide this is crucial in .NET 7 maybe.
Please at least make this change in .NET 7. This is not a new feature but a crucial fix for developing macOS apps using .NET MAUI.
I am currently developing a MAUI application that I intend to ship to macOS only (cross platform to be flexible) and my current experience is that its Dark Mode capabilities are completely unusable without this fix and I would never ship my app in its current state.
How could it be better to keep it in its current state "to not break things"? Currently this part of the macOS target is completely broken anyways! 😃
This will be superseded by https://github.com/dotnet/maui/pull/13510. However, this PR is more backport friendly and we can get the fix in sooner until @PureWeen runs all the tests.
This PR is very hard to test because our UI tests are not yet ready to run and this is an OS event.
/backport to net7.0
Started backporting to net7.0: https://github.com/dotnet/maui/actions/runs/4469092013
@rmarinho backporting to net7.0 failed, the patch most likely resulted in conflicts:
$ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Fix RequestedThemeChanged event on macOS using Shell
Using index info to reconstruct a base tree...
M src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
M src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
Falling back to patching base and 3-way merge...
Auto-merging src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
CONFLICT (content): Merge conflict in src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
Auto-merging src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
CONFLICT (content): Merge conflict in src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Fix RequestedThemeChanged event on macOS using Shell
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128
Please backport manually!
@rmarinho an error occurred while backporting to net7.0, please check the run log for details!
Error: git am failed, most likely due to a merge conflict.
/backport to main
Started backporting to main: https://github.com/dotnet/maui/actions/runs/4469507099
@mattleibow backporting to main failed, the patch most likely resulted in conflicts:
$ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Fix RequestedThemeChanged event on macOS using Shell
Using index info to reconstruct a base tree...
M src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRootRenderer.cs
M src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
M src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
Falling back to patching base and 3-way merge...
Auto-merging src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
CONFLICT (content): Merge conflict in src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
Auto-merging src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
CONFLICT (content): Merge conflict in src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
Auto-merging src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRootRenderer.cs
CONFLICT (content): Merge conflict in src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRootRenderer.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Fix RequestedThemeChanged event on macOS using Shell
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128
Please backport manually!
@mattleibow an error occurred while backporting to main, please check the run log for details!
Error: git am failed, most likely due to a merge conflict.