Stylianos Gakis
04/28/2023, 9:42 AM@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)
@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”Stylianos Gakis
04/28/2023, 9:42 AMStylianos Gakis
04/28/2023, 9:44 AMrecordingAmplitudeIndicator
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.Doris Liu
04/28/2023, 5:21 PMStylianos Gakis
04/28/2023, 10:03 PMStylianos Gakis
04/28/2023, 11:04 PM