https://kotlinlang.org logo
#compose
Title
# compose
f

Florian

08/28/2021, 7:45 AM
If I want to enable dark theme directly in the app settings (that overrides the system settings), I store a Boolean in DataStore or SharedPreferences and pass that to my Theme composable? Is this the correct approach?
👌 1
a

adjpd

08/28/2021, 10:11 AM
That's what I did. But now I'm thinking I should react to when the app user selects dark mode, not in my app, but on their phone. That is: give the user an option that says "mirror my phone's theme" and then change my theme accordingly.
f

Florian

08/28/2021, 2:52 PM
yes, I have 3 options now
light, dark, system default
that's the most common approach
the downside of this approach is that I have to wait for the value from preferences before we can render the first screen, right?
but there is no way around this
a

adjpd

08/29/2021, 7:30 PM
You could use a default and render the first screen. I'd use the system set light or dark mode, then rerender if the preferences value is different.
f

Florian

08/29/2021, 8:10 PM
yes but this will show a visible color switch when the app starts
I don't know if that's better