Hitanshu Dhawan
11/15/2020, 9:32 PMMaterialTheme.colors.background
inside my transitionDefinition
but I as this function is not marked with @Composable
I am getting this error
@Composable invocations can only happen from the context of a @Composable function
Is the transitionDefinition
function made non-composable on purpose? How can I make access these values inside transitionDefinition
?
My use case is to have different values for light and dark theme.
Something like this…
private val SomeTransitionDefinition = transitionDefinition<SomeState> {
state(SomeState.State1) {
this[backgroundColor] = if (MaterialTheme.colors.isLight) MaterialTheme.colors.primary else MaterialTheme.colors.secondary
}
}
Doris Liu
11/17/2020, 2:44 AMval color = if (MaterialTheme.colors.isLight) MaterialTheme.colors.primary else MaterialTheme.colors.secondary
val SomeTransitionDefinition = remember(color) {
transitionDefinition<SomeState> {
state(SomeState.State1) {
this[backgroundColor] = color
}
}
}
Hitanshu Dhawan
11/17/2020, 7:12 PMDoris Liu
11/17/2020, 7:49 PMTransitionDefinition
when the theme changes.Hitanshu Dhawan
11/18/2020, 5:30 AM