I develop library with composables. Composables have different foregone colors set for light and dark theme. For example backgroundColor
, buttonColor
, progressLineColor
. I don't want library users to pass any information about theme or colors to composables of library.
What I want is
@Composable
fun SomeLibraryComposable(someText: String) {
// This color should be different for light/dark modes of consumer app
val backgroundColor = getThemedBackroundColor()
....
}
I see that it is possible to add custom themed palette, using staticCompositionLocalOf
, like here. But:
- I can't wrap composables in my theme inside library, because I don't know if it's dark or light mode in app.
isSystemInDarkMode
is appliable only if app uses system dark mode - I should not make library users add
staticCompositionLocalOf
with my palette to their theme - I should not make library users pass
darkMode: Boolean
to composables of library to create corresponding theme