Let's consider the following @Composable
functions:
@Composable
fun WelcomeScreen() {
...
ButtonTheme {
Button(...) {...}
}
}
@Composable
@Preview
fun MockWelcome() {
AppTheme {
WelcomeScreen { }
}
}
@Composable
@Preview
fun MockDarkWelcome() {
AppTheme(darkTheme = true) {
WelcomeScreen { }
}
}
And theme (note: AppTheme
follows the same logic):
@Composable
fun ButtonTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
MaterialTheme(
...
colors = if (darkTheme) darkButtonColorPalette else lightButtonColorPalette,
)
}
The preview window will show both WelcomeScreen versions correctly but the dark version will not show the button in the dark theme.
Running the app everything is OK, this it's only a preview "problem".
So, my question is: is this intended behaviour, a bug, or a misconfiguration?
Full code here: https://github.com/GuilhE/JetpackChallenge