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

alorma

02/18/2021, 6:14 PM
Hi. Weird question Is it possible, from a module (library), having
MaterialTheme
, to obtain the
light
or
dark
version of a MaterialTheme?
For example: A module with a method that shows a given composable (via slot) with light or dark variation?
I have my library
ComposeDebugDrawer
, configured like this:
Copy code
DebugDrawerLayout(
     drawerColors = YourColorScheme, // darkColors() or lightColors()
)
And I would like to always theme my drawer with the dark variation of the app theme
j

jaqxues

02/18/2021, 6:46 PM
What you probably want is just wrapping it around
MaterialTheme
?
Copy code
MaterialTheme(colors = darkColors()) {
    DebugDrawerLayout(...)
}
or similar
a

alorma

02/18/2021, 7:24 PM
Yes, but how to obtain the
darkColors()
without recuesting it as a param ?
j

jaqxues

02/18/2021, 7:25 PM
what is your use case? Since usually you should not pass around these theme colors, but use MaterialTheme {}
a

alorma

02/18/2021, 7:29 PM
I have a library, that builds a debug drawer, and I would theme it as the local theme, but in dark variation
Yes, i thougt so, i just wonderd if there's a way to make it automatically
j

jaqxues

02/18/2021, 7:30 PM
Well in that case you need it as params
I cannot think of any other way with providers etc to receive a theme with darkColors
2 Views