Question about Android Studio tooling for compose ...
# compose
s
Question about Android Studio tooling for compose animations. More in thread 🧵
The example in the documentation shows the case where we’re controlling the values ourselves from inside the @Preview function. If I have a function that looks something like this, super simplified:
Copy code
sealed 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:
Copy code
@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.
d
Notice in the example there's a
toggleable
modifier on the
Surface
that transforms gestures on the preview into state changes, which then triggers animations.
s
But this doesn’t let you use the bottom of the preview to play the animation, increase/decrease the speed, make it repeatable etc. This is what I would love to have to fine-tune the animation.
d
Uh I see. Currently only
AnimatedVisibility
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.
s
Ahhh it makes sense. Yeah please any more documentation on this feature would be awesome. Define the current features and the current limitations like this one which I was unfortunately not aware of. Currently only this section exists in the documentation afaik (please do share if anything else exists) which doesn’t do justice to such a great tool. I’m pretty sure most devs don’t even know it exists.
c
Thanks for the feedback! The documentation of the tool is in that state because the Animation Inspector is not yet in our stable releases. It will be though in Chipmunk stable, so we will update the docs accordingly soon.
🎉 1
s
Oops, sorry 😅 I am so used to using the Alpha channel that I often forget what isn’t supported in the Stable/Beta versions 😂
😀 1
c
Well happy that you are using the alpha channel!