darkmoon_uk
08/09/2021, 4:49 AMLocalContentColor
always default to black, and this default is not overridden by a MaterialTheme
block?
This means that even in Dark themes, the text colour inside a TextField
, for example, is also black, leaving it hard to read.
The API comments talk about this being 'typically' set to MaterialTheme.onSurface
- but don't say whether this is the direct responsibility of the developer, or how to do it.
This feels like something I shouldn't be handling directly - why do other Material elements adjust well to dark/light scheme, but the text inside a TextField
does not? Either I'm missing something or this is inconsistent/broken?
Edit: Straw-man solution 👉 🧵darkmoon_uk
08/09/2021, 5:05 AMMyMaterialTheme
class like so:
@Composable
fun MyApplicationTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable() () -> Unit) {
val colors = if (darkTheme) {
DarkColorPalette
} else {
LightColorPalette
}
MaterialTheme(
colors = colors,
typography = Typography,
shapes = Shapes
) {
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colors.onSurface) {
content()
}
}
}
darkmoon_uk
08/09/2021, 5:05 AMCompositionLocalProvider(LocalContentColor provides MaterialTheme.colors.onSurface) { ...
darkmoon_uk
08/09/2021, 5:06 AMKefas
08/09/2021, 5:21 AMSurface
?Ian Lake
08/09/2021, 5:34 AMSurface
(/or get one for free by using Scaffold
): https://kotlinlang.slack.com/archives/CJLTWPH7S/p1628359360407100