galex
09/02/2021, 7:05 AMenum class Hierarchy(
backgroundColor: Color,
contentColor: Color,
pressedBackgroundColor: Color,
pressedContentColor: Color,
disabledBackgroundColor: Color,
disabledContentColor: Color,
border: BorderStroke? = null,
) {
Primary(
backgroundColor = MyTheme.colors.accentDefault,
contentColor = MyTheme.colors.contentInverse,
disabledBackgroundColor = MyTheme.colors.accentDisabled,
disabledContentColor = MyTheme.colors.contentInverse)
}
But as the enum is not a Composable I am hit with an error @Composable invocations can only happen from the context of a @Composable function
. Is there a workaround this error?Luis
09/02/2021, 7:07 AMcolors
?Luis
09/02/2021, 7:09 AMColor
class is implemented, I think you might be better served with a class and some global variablesgalex
09/02/2021, 7:13 AMChris Johnson
09/02/2021, 7:14 AMval primary = @Composable { MaterialTheme.colors.primary }
And then you can use it like color = primary()
galex
09/02/2021, 7:14 AMAntimonit
09/05/2021, 6:49 PM@Composable
annotated getters like
val primary
@Composable
get() = MaterialTheme.colors.primary
Don't have an access to ide right now, didn't test.