Tash
07/16/2021, 2:53 AMAnimatedVisibility
& trying to dynamically update the transition values by calculating them based on mutable states; so, when a component enters/exits the enter/exit animation can be different every time. Just wanted to get some feedback on the approach 🧵Tash
07/16/2021, 2:57 AMFloat
that is also being transitioned)
AnimatedVisibility(
modifier = modifier,
visibleState = state.visibility,
enter = state.inDirection.value.enterTransition(),
exit = state.outDirection.value.exitTransition()
)
val animatedRotZ by transition.animateFloat { enterExitState ->
when (enterExitState) {
EnterExitState.PreEnter -> {
when (state.inDirection.value) {
Direction.In.Left -> -90f
Direction.In.Right -> 90f
Direction.In.Up -> 0f
Direction.In.Down -> 0f
}
}
EnterExitState.Visible -> 0f
EnterExitState.PostExit -> {
when (state.outDirection.value) {
Direction.Out.Left -> -90f
Direction.Out.Right -> 90f
Direction.Out.Up -> 0f
Direction.Out.Down -> 0f
}
}
}
}
Tash
07/16/2021, 2:58 AMDoris Liu
07/21/2021, 9:12 PMTash
07/22/2021, 2:17 AMDoris Liu
07/22/2021, 2:45 AMfun Direction.In.enterTransition()
and the exit equivalent fun. That would allow the function call to be skipped by the compiler plugin when the input is the same. 🙂 See: https://github.com/androidx/androidx/blob/androidx-main/compose/docs/compose-api-guidelines.md#stable-typesTash
07/23/2021, 6:32 AM@Stable
works great 🙏🏼