Arpit Shukla
10/25/2021, 10:46 AManimateFloatAsState
, I see that it accepts a finishedListener
but how to provide something like an updateListener
?maciejciemiega
10/25/2021, 11:12 AMState<Float>
(returned by animateFloatAsState
) changes and react on that change.Arpit Shukla
10/25/2021, 11:15 AMmaciejciemiega
10/25/2021, 11:30 AMArpit Shukla
10/25/2021, 11:30 AMArpit Shukla
10/25/2021, 11:31 AMmaciejciemiega
10/25/2021, 11:31 AMangle
) and do something like:
image = if (angle >= 180f) imageA else imageB
Arpit Shukla
10/25/2021, 12:23 PMImage(painter = rememberedImage)
But how will I know when does angle reaches 180f ? Or am I doing it the wrong way and there exists a simpler solution?maciejciemiega
10/25/2021, 12:31 PMval isFlipped by derivedStateOf { angle >= 180f }
.
Then you can add isFlipped
as a key to the remember
that you use to cache the image. When isFlipped
changes the image would be recalculated.
It's hard to propose anything specific without seeing the actual code, but I hope you got the idea 🙂Arpit Shukla
10/25/2021, 3:14 PMArpit Shukla
10/25/2021, 3:25 PMtween(durationMillis = if (startRotation) 400 else 0)
But I am not sure whether the overall implementation is correct or not (though it seems to work on my device). Like, should the if condition be put in some effect handler or is it fine this way?maciejciemiega
10/25/2021, 3:56 PMArpit Shukla
10/25/2021, 4:14 PM