Thread
#compose
    s

    Steve C

    1 year ago
    Hello everyone. Pretty new to working with compose, and I'm a bit stuck on animations. I've done quite a bit of searching, but I'm still stuck. I know I just don't know the proper syntax, but can't find a relevant example so I am reaching out for help here. Can anyone enlighten me on the correct way to use a different tween for different states? Here's what I have, but I get a compile error of "Not enough information to infer type variable T" if I put the tween call in a conditional:
    val transition = updateTransition(starState, label = "twinkle transition")
    
    val alpha: State<Float> = transition.animateFloat(transitionSpec = {
        if (StarState.IDLE isTransitioningTo StarState.TWINKLE) {
            tween(durationMillis = 3000, easing = LinearOutSlowInEasing)
        } else {
            tween(durationMillis = 1500, easing = LinearOutSlowInEasing)
        }
    
        tween(durationMillis = 3000, easing = LinearOutSlowInEasing)
    }, label = "alpha transition") { state ->
        if (state == StarState.TWINKLE) 1F else 0F
    }
    Albert Chang

    Albert Chang

    1 year ago
    You need to specify
    tween<Float>()
    .