Question for AnimatedVisibility. If I have 2 poten...
# compose
a
Question for AnimatedVisibility. If I have 2 potential enter/exit animation combinations for a single view that depend on state, how can I set the exit animation based on the state of the enter animation. Ex:
Copy code
@Composable
fun MusicPopUp(
    modifier: Modifier = Modifier,
    slidePopup: Boolean = false, <-- this is a flow state  (collectAsState)
    fadePopup: Boolean = false <-- this is a flow state (collectAsState)
) {
    val exitAnimation = if (fadePopup) {
        fadeOut(targetAlpha = 0f, animationSpec = tween(500))
    } else {
        slideOutVertically(animationSpec = tween(500)) { -it }
    }
    AnimatedVisibility(
        visible = fadePopup || slidePopup,
        enter =
        if (fadePopup) {
            fadeIn(initialAlpha = 0f, animationSpec = tween(500))
        } else {
            slideInVertically(animationSpec = tween(500)) { it }
        },
        exit = exitAnimation
    ) { ...
It always seems to default to the slide out animation instead of the fade out. How can I get fade out working?