Stylianos Gakis
01/13/2022, 3:07 PMsealed interface State { object One : State; object Two : State; object Three : State }
@Composable
fun MyComp(state: State) {
val color by animateColorAsState(when(state)){...})
Box(modifier = Modifier.animateContentSize()) {
when(state) {
is One -> SomeComposable1(Modifier.height(16.dp).smth(color))
is Two -> SomeComposable2(Modifier.height(32.dp).smth(color))
is Three -> SomeComposable3(Modifier.height(48.dp).smth(color))
}
}
}
Then in order to Preview this all I can do is to pass a state object, like:
@Preview
@Composable
fun MyCompPreview() {
val state = State.One // Changing it in an rememberInfiniteTransition doesn't work of course, it's just 3 distinct values
MyComp(state)
}
which doesn’t allow me to use the animation inspector with it.
And I don’t want to test the SomeComposable#
in isolation either, I am interested in the MyComp
itself and its interaction with everything else.Doris Liu
01/13/2022, 7:35 PMtoggleable
modifier on the Surface
that transforms gestures on the preview into state changes, which then triggers animations.Stylianos Gakis
01/13/2022, 7:44 PMDoris Liu
01/13/2022, 7:48 PMAnimatedVisibility
and Transition
APIs are supported by the inspector. The other APIs will be supported in future releases. We should probably make that more clear in the documentation.Stylianos Gakis
01/13/2022, 7:53 PMChris Sinco [G]
01/13/2022, 8:09 PMStylianos Gakis
01/13/2022, 8:16 PMChris Sinco [G]
01/13/2022, 8:16 PM