Skip to content
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

App.Current.RequestedThemeChanged doesn't fire #10310

Closed
davidortinau opened this issue Sep 26, 2022 · 4 comments · Fixed by #11199
Closed

App.Current.RequestedThemeChanged doesn't fire #10310

davidortinau opened this issue Sep 26, 2022 · 4 comments · Fixed by #11199
Assignees
Labels
area-core-lifecycle XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events fixed-in-7.0.81 Look for this fix in 7.0.81! fixed-in-7.0.92 Look for this fix in 7.0.92! fixed-in-7.0.100 fixed-in-7.0.101 fixed-in-8.0.0-preview.3.8149 Look for this fix in 8.0.0-preview.3.8149! p/1 Work that is critical for the release, but we could probably ship without partner/cat 😻 Client CAT Team platform/macOS 🍏 macOS / Mac Catalyst t/bug Something isn't working

Comments

@davidortinau
Copy link
Contributor

Description

App.Current.RequestedThemeChanged doesn't fire IF the new UserAppTheme resolves to the current theme.

Example:

When the current theme is "Unspecified" and "Light", the event will ONLY fire when the user changes to "Dark".
When the current theme is "Light, the event will ONLY fire when the user changes to "Dark". Changing to "Unspecified" is equivalent to "Light" and thus won't fire the event.

I believe it should fire. I have 2 different UI controls that listen for theme change events and when it doesn't fire one may say "Light" while the other says "Unspecified" on the same screen.

image

Steps to Reproduce

do the things described

Link to public reproduction project repository

https://github.com/davidortinau/ControlGallery

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, macOS, I was not able test on other platforms

Affected platform versions

latest

Did you find any workaround?

haven't tried

Relevant log output

No response

@davidortinau davidortinau added the t/bug Something isn't working label Sep 26, 2022
@jsuarezruiz jsuarezruiz added the platform/macOS 🍏 macOS / Mac Catalyst label Sep 26, 2022
@mattleibow
Copy link
Member

I believe this is "correct" behavior because when transitioning form Light to Unspecified (as Light), there is no actual theme change. I also do not believe that event fires for anything "Unspecified" and will always be a Light or Dark.

If this is unexpected, then we need to determine if the behaviour is wrong for everyone and we should change it, or if we need some new event that first when the property changes.

@davidortinau
Copy link
Contributor Author

There are 3 theme options in AppTheme. When a request to change between those 3 options is made, I need an event to tell me so I can decide what to do about it. I'm not asking if the actual theme changed, I'm asking if the request was made to change it. And Unspecified IS different than Light in terms of the request. I do need my UI to update as you can see in the video.

How can I achieve my goal with the API? There is only 1 theme-related event presently, and it doesn't seem to meet my need since it doesn't fire in this situation.

App.Current.UserAppTheme
Microsoft.Maui.ApplicationModel.AppTheme.Unspecified
	base: {int}
	value__: 0
	Static members: 
App.Current.PlatformAppTheme
Microsoft.Maui.ApplicationModel.AppTheme.Light
	base: {int}
	value__: 1
	Static members: 
App.Current.RequestedTheme
Microsoft.Maui.ApplicationModel.AppTheme.Light
	base: {int}
	value__: 1
	Static members: 
2022-09-26_09-41-32.mp4

@PureWeen PureWeen added this to the Backlog milestone Sep 28, 2022
@ghost
Copy link

ghost commented Sep 28, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@PureWeen PureWeen added the area-core-lifecycle XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events label Sep 28, 2022
@ewerspej
Copy link

ewerspej commented Oct 30, 2022

@davidortinau @mattleibow Shouldn't the RequestedThemeChanged event only fire when the System Theme changes? That's what the official documentation says and that's also how the documentation of XF says it, too. That's also how I would interpret this feature.

However, there is something else unclear about this for me (or there is another issue): The UserAppTheme is what I set as a developer when the user wants to change between Dark or Light mode or follow the System Theme (== AppTheme.Unspecified). At the moment, when the UserAppTheme is set to Unspecified and I change the System Theme on Android, the AppThemeBinding doesn't get updated and the RequestedThemeChanged event doesn't fire, either. I would need the latter to update the status bar color.

@jsuarezruiz jsuarezruiz self-assigned this Nov 8, 2022
@samhouts samhouts added partner/cat 😻 Client CAT Team p/1 Work that is critical for the release, but we could probably ship without labels Feb 13, 2023
@samhouts samhouts modified the milestones: Backlog, .NET 8 Planning Mar 17, 2023
@samhouts samhouts added fixed-in-7.0.81 Look for this fix in 7.0.81! fixed-in-8.0.0-preview.3.8149 Look for this fix in 8.0.0-preview.3.8149! labels Apr 12, 2023
@ghost ghost locked as resolved and limited conversation to collaborators May 12, 2023
@samhouts samhouts added the fixed-in-7.0.92 Look for this fix in 7.0.92! label Jul 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-core-lifecycle XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events fixed-in-7.0.81 Look for this fix in 7.0.81! fixed-in-7.0.92 Look for this fix in 7.0.92! fixed-in-7.0.100 fixed-in-7.0.101 fixed-in-8.0.0-preview.3.8149 Look for this fix in 8.0.0-preview.3.8149! p/1 Work that is critical for the release, but we could probably ship without partner/cat 😻 Client CAT Team platform/macOS 🍏 macOS / Mac Catalyst t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants