but I can't find a way to change the text color based on the previous value. Am I missing something obvious here? 🤔
r
Rebecca Franks
10/21/2022, 11:20 AM
Have you tried just changing your underlying state depending on the previous value?
Rebecca Franks
10/21/2022, 11:20 AM
Ie - not relying on the Animation APIs here to help
Rebecca Franks
10/21/2022, 11:23 AM
In your ViewModel or wherever you are doing business logic - looking at the old state to determine what the new state should be.
s
smithc42
10/21/2022, 11:41 AM
Thanks for the reply. Yep, that will definitely work! But I was trying to figure out if it could be done entirely though Compose with
AnimatedContent
+ something similar for color transition. The ViewModel approach is the fallback though 🙂
r
Rebecca Franks
10/21/2022, 3:07 PM
Not to my knowledge, but maybe @Doris Liu knows some way 🙂 The transitionSpec is for determining how it'll get to the targetState - there is a transitionSpec on animateColor if you want to change the how, but changing the what should probably be calculated in a different way.
d
Doris Liu
10/21/2022, 6:10 PM
It'd be useful if the
AnimatedContent
provided the initial/target state in the scope for its content lambda. Please feel free to file a feature request for this. 🙂