I am trying to let my users manually select dark m...
# compose
y
I am trying to let my users manually select dark mode independently from the system settings. On non-compose apps I just used
AppCompatDelegate
to change dark mode but on my Compose app it has no effect. It looks like
isSystemInDarkTheme()
just checks the system settings and even when I use my own function to check dark mode, it only effects the Compose MaterialTheme colors which I don't use much. I use resources for dark/light colors and it works fine except this. How can I handle this in Compose? It does not look like
AppCompatDelegate
has any effect on Compose.
c
Have you looked at the Jetsnack sample? That demonstrates how to use a bespoke color system that doesn’t use Material colors
👀 1
Still uses MaterialTheme, but I think it can help with what you are looking for
Also, by default, there is a default set of dark colors available to you in Compose based on the Material dark theme guidelines (
darkColors()
) but it’s entirely in your control to pass them into
MaterialTheme
that is at the root of your Compose app hierarchy.
isSystemInDarkTheme()
is there for convenience, but the conditional can be custom as you mentioned.
And I think using color values from resource files is a different issue, which we have some theme adapter libraries in Accompanist which may help: https://github.com/google/accompanist/tree/main/appcompat-theme
👀 1
K 1
y
Ooo thanks for the resources, ill check them out! 🙏
👍 1