Chris Johnson
03/21/2022, 8:30 PManimateContentSize with say an alpha animation? If not, what's the way we should go about this? Say I want to update the alpha alongside the size change for a Text. Currently it animates the size first and doesn't appear to get any alpha updates. Code in 🧵Chris Johnson
03/21/2022, 8:31 PMval alpha by animateFloatAsState(animationSpec = spring(stiffness = Spring.StiffnessMediumLow), targetValue = if (uiState.someState) 1f else .5f)
Text(text = if (uiState.someState) "Send Message" else "", modifier = Modifier.animateContentSize(animationSpec = spring(stiffness = Spring.StiffnessMediumLow))
.alpha(alpha))Chris Sinco [G]
03/21/2022, 9:10 PMAnimatedContent would be useful for combining fade + size transform, but @Doris Liu might have other suggestionsDoris Liu
03/21/2022, 10:00 PMAnimatedContent would be the API to use for this.
animateContentSize reactively animates the size change after the text has already changed, say from "Send Message" to "". At that point, the animated alpha is applied on an empty text.
AnimatedContent can help you swap between the old and new text while applying fade and size transform.Chris Johnson
03/21/2022, 10:01 PMAnimatedContent is powerful.
I was trying to do simultaneous animations via coroutines from this link.
but this is much simpler.
Ah, Thanks for the reply guys! And for making such a delightful and fun to use api = )