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

In AdwaitaTheme(), dark mode is only when the system setting is dark #86

Open
naiming-zededa opened this issue Mar 18, 2024 · 12 comments
Open

Comments

@naiming-zededa
Copy link

fyneApp.Settings().SetTheme(theme.DarkTheme())
myApp.App = fyneApp
myApp.CurrentShemeDark = true

This code seems to work only if the system setting is in 'dark' mode.

@andydotxyz
Copy link
Member

How does the code myApp.CurrentShemeDark fit in? This is not part of the exported APIs...

@naiming-zededa
Copy link
Author

Ok, sure. But I see this in the code:

darkScheme := map[string]colorInfo{}
lightScheme := map[string]colorInfo{}

I'm just not sure how to invoke 'dark' or 'light' in this scheme with APIs.

@andydotxyz
Copy link
Member

Most themes don't offer any variant setting, and the adwaita is the same.

But you can create a new theme that wraps this one and specify the variant instead to override the system settings...

@andydotxyz
Copy link
Member

fyneApp.Settings().SetTheme(theme.DarkTheme())
myApp.App = fyneApp
myApp.CurrentShemeDark = true

This code seems to work only if the system setting is in 'dark' mode.

I have just realised this code doesn't mention Adwaita at all - maybe it was a bad paste?

@naiming-zededa
Copy link
Author

I have just realised this code doesn't mention Adwaita at all - maybe it was a bad paste?

Sorry, you are right. I used to do this:

fyneApp.Settings().SetTheme(theme.AdwaitaTheme())
myApp.App = fyneApp
myApp.CurrentShemeDark = true

this works fine. until I changed system mode to 'light'

@andydotxyz
Copy link
Member

You are pasting custom code but not explaining how it works.
The theme you are using adapts to the OS setting - why do you expect that those lines of code will change that?

@naiming-zededa
Copy link
Author

maybe i misunderstood the AdwaitaTheme, i thought it could be integrated into the fyne theme.
but how does it suppose to change between 'darkScheme' and 'lightScheme'?

@andydotxyz
Copy link
Member

All fyne themes reflect the OS user preference for light/dark, is this not what you are seeing?

To force one variant you could wrap the theme and force your variant choice into the Color function call.

@naiming-zededa
Copy link
Author

what i'm seeing is this, it i do:
fyneApp.Settings().SetTheme(theme.DarkTheme())
or
fyneApp.Settings().SetTheme(theme.LightTheme())

it works, regardless of the host system mode setting

but if i'm changing to:
fyneApp.Settings().SetTheme(theme.AdwaitaTheme())
or
fyneApp.Settings().SetTheme(theme.LightTheme())

what i'm seeing is that, if the host system is in dark mode, it works fine.
I can change to the 1st one, get the dark mode, and to the 2nd, get the light mode.
but if the host system is in light mode, even i set to the 1st one, it's still in light mode.

@andydotxyz
Copy link
Member

what i'm seeing is this, it i do:
fyneApp.Settings().SetTheme(theme.DarkTheme())
or
fyneApp.Settings().SetTheme(theme.LightTheme())

it works, regardless of the host system mode setting

These are deprecated because it ignores the user preference which is not what we want to see happen.

but if the host system is in light mode, even i set to the 1st one, it's still in light mode.

Isn't that correct? the theme is matching the user setting. When you call SetTheme a second time it will completely replace the theme, so what you set before has no impact on the theme you load second.

@naiming-zededa
Copy link
Author

but I would think more specific should always overwrite the less specific. If my app has a button to turn it to 'dark' mode, then regardless of the global setting, it should be dark. This is more specific user preference.

@andydotxyz
Copy link
Member

Ok, and how have you coded it so that preference overrides the system default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants