I got a composable like this which takes an input ...
# compose
s
I got a composable like this which takes an input and uses it as a target for animateIntAsState
Copy code
@Composable
fun AnimatingFoo(input: Int) {
  val animated by animateIntAsState(input.someCalculation(), label = "recordingAmplitudeIndicator")
  Canvas() {
    drawCircle(radius = animated.toFloat())
  }
}
And I want to use the animation preview to test how the inputs it gets affect the UI it outputs. If I make a preview composable like this which has its own transition (so that it shows up in the animation preview)
Copy code
@Preview
@Composable
private fun PreviewAnimatingFoo() {
  val infiniteTransition = rememberInfiniteTransition()
  val amplitude by infiniteTransition.animateFloat(...)
  RecordingAmplitudeIndicator(amplitude.toInt(), Modifier.fillMaxSize())
}
Then in my IDE I get to edit both values (pic in thread), but I don’t want to be able to edit the “recordingAmplitudeIndicator” really, just wanted to see how it behaves as a result of the input. This makes it so that I can’t really test the animation, without having to remove the animation from inside my non-preview composable, test and then have to add it back. Is this a limitation on the Animation Preview system in the IDE, or is there some config in there I am missing where I can basically tell “Don’t edit this value, let it work as it would in real execution time”
And this is where I can edit both, but I don’t want to basically. Just want the top one to be driven by the bottom animation which is the transition I added in my preview
And yes, I could try and preview using the
recordingAmplitudeIndicator
directly, but the way the calculation is done is not a straightforward thing (some calculations like square root, multiplications etc), what I do want to test is the input, not that value itself. Also this way I can’t add a sane start-end value for my preview to start with, and I need to edit it in the animation preview UI every time I make a change on the code and want to test again.
d
Could you file a feature request for this? Please do include the screenshot and the description of your use case above. 🙂 Thanks.
s
Absolutely! Here’s the reported issue https://issuetracker.google.com/issues/280000350 and I included the exact same text along with the screenshot. Also a link to this discussion through the use of the slack archives of this channel so that everyone can see it even without access to this channel https://slack-chats.kotlinlang.org/t/10978819/i-got-a-composable-like-this-which-takes-an-input-and-uses-i#a7060683-4084-419e-b7d7-0b10ca0655ec
Wow, just realized I sent it against a completely wrong target, I can’t seem to be able to change it, maybe you or someone from inside google has to do that instead, sorry about that, I had another issuetracker tab open and I added my information on the wrong one 🫣