Open rylexr opened 1 year ago
I have the same problem. @Alex009
I use the dark and light colors for darkColors() and lightColors() functions, so I can use them in MaterialTheme.
private val DarkColorPalette = darkColors(
primary = Color(MR.colors.primary.dark.colorInt()),
primaryVariant = Color(MR.colors.primaryVariant.dark.colorInt()),
onPrimary = Color(MR.colors.onPrimary.dark.colorInt()),
secondary = Color(MR.colors.primary.dark.colorInt()),
onSecondary = Color(MR.colors.onPrimary.dark.colorInt()),
error = Color(MR.colors.error.dark.colorInt()),
onError = Color(MR.colors.onError.dark.colorInt()),
)
private val LightColorPalette = lightColors(
primary = Color(MR.colors.primary.light.colorInt()),
primaryVariant = Color(MR.colors.primaryVariant.light.colorInt()),
onPrimary = Color(MR.colors.onPrimary.light.colorInt()),
secondary = Color(MR.colors.primary.light.colorInt()),
onSecondary = Color(MR.colors.onPrimary.light.colorInt()),
error = Color(MR.colors.error.light.colorInt()),
onError = Color(MR.colors.onError.light.colorInt()),
)
val colors = remember {
mutableStateOf(
if (darkTheme.value) {
DarkColorPalette
} else {
LightColorPalette
}
)
}
...
MaterialTheme(
colors = colors.value,
content = content,
)
Could it be that my approach to using the dark/light colors is completely wrong?
Any news on this one @Alex009 ?
When using light/dark attributes pointing to another themed color, moko resources is unable to generate the platform files properly. Take this example:
I'd expect referencing
@color/themeColor1
fromthemeColor2
to resolve to light and dark values accordingly and to usethemeColor2.light
value in Androidvalues/colors.xml
andthemeColor2.dark
value invalues-night/colors.xml
. Could we please add support for this?Also, is there a workaround?