maui icon indicating copy to clipboard operation
maui copied to clipboard

[macOS/iOS] Fix RequestedThemeChanged event

Open jsuarezruiz opened this issue 2 years ago • 3 comments

Description of Change

Fix RequestedThemeChanged event using Shell on macOS/iOS.

fix-macos-themes

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

jsuarezruiz avatar Nov 08 '22 13:11 jsuarezruiz

When will the changes be available in the .net 6 stable version?

piotreksda avatar Jan 15 '23 15:01 piotreksda

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.

jfversluis avatar Jan 20 '23 09:01 jfversluis

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! 😃

Hurricane31337 avatar Feb 08 '23 13:02 Hurricane31337

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.

mattleibow avatar Mar 16 '23 20:03 mattleibow

/backport to net7.0

rmarinho avatar Mar 20 '23 14:03 rmarinho

Started backporting to net7.0: https://github.com/dotnet/maui/actions/runs/4469092013

github-actions[bot] avatar Mar 20 '23 14:03 github-actions[bot]

@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!

github-actions[bot] avatar Mar 20 '23 14:03 github-actions[bot]

@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.

github-actions[bot] avatar Mar 20 '23 14:03 github-actions[bot]

/backport to main

mattleibow avatar Mar 20 '23 14:03 mattleibow

Started backporting to main: https://github.com/dotnet/maui/actions/runs/4469507099

github-actions[bot] avatar Mar 20 '23 14:03 github-actions[bot]

@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!

github-actions[bot] avatar Mar 20 '23 14:03 github-actions[bot]

@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.

github-actions[bot] avatar Mar 20 '23 14:03 github-actions[bot]