Another question: I see there is MaterialTheme.error. Is there such colors for success and warning? If there is no such values, how can I add them and make adoptive (for light, dark or custom theme)?
a
Abdelilah El Aissaoui
10/31/2022, 11:26 AM
You can add them as extension methods/properties. If you plan to support more than light and dark, it may require more effort.
val Colors.warning: Color
get() {
return if(isLight)
colorWarningLight
else
colorWarningDark
}
j
jwill
10/31/2022, 1:56 PM
You can also do a CompositionLocal. I prefer it a touch more than putting extension functions on ColorScheme as it's more clear where the values are coming from. But either works.
Just be aware when using Compose Desktop examples that Colors (M2) and ColorScheme(M3) are different.