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

K Merle

07/21/2022, 8:26 AM
How to check if current theme is dark, without checking for
system
theme?
z

Zun

07/21/2022, 1:55 PM
Using the same way you're setting the theme to dark. Usually this is a Boolean value or whatever
k

K Merle

07/21/2022, 3:39 PM
Not sure if I understand. Considering the dark theme is being set on very top, how can my nested components know about this variable? Previously I do remember we had some LocalComposition, but I am unable to find it now, all I see is
isSystemDarkTheme()
o

Oleksandr Balan

07/21/2022, 4:14 PM
What is wrong then with
isSystemDarkTheme
? It should be observable, thus your component will recompose on change
k

K Merle

07/22/2022, 7:22 AM
App will be able to change theme at runtime. That being said, I'll just grab the variable from implementation.
z

Zun

07/22/2022, 8:33 AM
If you are persisting the newly selected theme to a database such as DataStore then you can simply observe that key from your database At the very top of your application you observe, down the road you write to it
3 Views