Archie

    Archie

    1 year ago
    Hi @Doris Liu, just wondering if there is any guide around animating TextSize change? Would it be enough to simply create a
    State
    holder for the font size? Just would want to be sure that this is the correct way since with Views (Correct me if I’m wrong), animating the font size directly isn’t the suggested (optimize) way of doing it.
    For my specific UseCase, I am trying to create a Collapsing Toolbar where the Title changes size depending on the current “collapse” value. Something similar to this:https://images.app.goo.gl/SVhja8vBi2uTYni6A
    I also looked at
    TextField
    and it ssems that the Label animation works directly with the TextStyle:
    val labelAnimatedStyle = lerp(
        MaterialTheme.typography.subtitle1,
        MaterialTheme.typography.caption,
        labelProgress
    )
    So I guess its fine to do the same thing as well?
    Doris Liu

    Doris Liu

    1 year ago
    Hey Archie, sorry for the delayed response - just came back from vacation. 🙂 TextField is a lot more lightweight than TextView. Hence I'd expect the fontSize change to be more performant. Do you see any performance issue when you animate the fontSize directly in Compose?
    Archie

    Archie

    1 year ago
    Hi @Doris Liu! Thank you for the response 😄 Not really.. performance have been great just wanted to make sure that it was the correct thing to do 🙂
    Sorry @Doris Liu just really would like to take the opportunity. I can’t seem to figure out how to coordinate animation with gesture/swipes. I am trying to replicate this animation attached here. Specifically, the part where the card expands when swiped up. It feels like I should be able to create a
    Transition
    to replicate the animation but I can’t seem to wrap around how to seek the
    Transition
    base on the current Swipe offset. I could easily create the expanding card with swiping, but I can’t figure out how to combine the swiping card animation with all other animation. Right now, I am simply computing the current progress of the swipe by:
    val swipeProgress = swipeableState.offset.value / expandedCardOffset
    And using this
    swipeProgress
    everywhere. like:
    val appbarOffset by animateDpAsState(
        targetValue = lerp(0.dp, 25.dp, swipeProgress.coerceAtLeast(0f)),
    )
    Do you have any advice? Thank in advnace.
    Doris Liu

    Doris Liu

    1 year ago
    Great question! Seeking in Transition is something that we plan on supporting in the future. We haven't got to implementing it yet, due to other higher priorities. Your code snippet above with the lerping seems like a pretty clever workaround. 🙂 I'm curious how it looks
    Archie

    Archie

    1 year ago
    Thats good to hear! Hope it would be available soon. I'll try and push the code once i cleaned it up. I kinda have mixed feelings about all the lerps but it works. Thank you very much always being nice! ❤️