Hi everyone, we've recently redesigned `Transition...
# compose
d
Hi everyone, we've recently redesigned
Transition
animation to make it easier to use and more extensible. tl;dr No more `PropKey`s and `transitionDefinition`s, and instead animations can be declared dynamically. πŸŽ‰ Please give the new Transition (available since alpha 09) a try. I would love to hear what you think! πŸ™ (P.S. Seeking isn't supported yet, but dynamic target values (e.g. theme-specific values) are now supported.)
😍 23
mind blown 10
πŸŽ‰ 10
πŸ‘ 22
r
throws error on build when used alpha 09
d
Can you share the code that caused this error? Or is it just a plain migration to alpha09?
r
@Doris Liu Sorry. I’ve forgot to update composeOptions.kotlinCompilerExtensionVersion
@Doris Liu Is there a sample of transition between buildin vector icons?
d
Great question. Transitioning between vector icons would require the same amount of path nodes for the purpose of path morphing. Not all built-in vector icons have the same number of path nodes AFAIK. So the solution can't be easily generalized. Maybe @Alexjlockwood could have a
Transition<S>.animateVectorIcons(...)
extension with ShapeShifter? πŸ˜›
r
There is no standard path morphing solution for all vector drawables. So It would be nice to have build-in animations for ArrowBack and Search, Edit and Done, etc
d
Agreed. For some of the built in vectors, we'll probably offer built-in animations like we do with
AnimatedVectorDrawable
. Meanwhile, we have some ongoing work that is a more general solution for creating custom animated vectors using
Transition
. Stay tuned! πŸ™‚ @Nader Jawad may be able to share more.
K 1
a
haha adding compose support to shapeshifter is something that crossed my mind and i would definitely want to do it eventually (probably wouldn’t be hard either lol). been holding off though since the APIs are constantly changing.
πŸ™Œ 1
also because converting
AnimatedVectorDrawable
resources to a compose format sounds like not that much fun πŸ˜„
d
We might be able to solve the AVD resources conversion headache for you. πŸ˜‰
r
@Alexjlockwood What a wonderful idea πŸ€ͺ
n
Like @Doris Liu mentioned, stay tuned ;-)
r
@Doris Liu Is There a sample for top appbar menu to searchview transition?

https://i.stack.imgur.com/oLG2Y.gifβ–Ύ

d
I don't think there's an existing sample for this. The white ripple/reveal seamlessly transitioning into the background is not super straight forward to implement. I played around a bit, and came up with this. Not pixel perfect, more of a quick proof of concept. I haven't seen this sort of reveal transition in the latest material design. Is this on the material design site?
r
Thank you @Doris Liu. No it is not. I found it googling. What about the suggestion list? Do we have to render it in separate place in order to overlay the content of screen?
I tried it with Scaffold but when suggestion appears content is being pushed down
d
a
Converted an Exploding Fab that used v1 transitions to v2: https://gist.github.com/AfzalivE/46e0460aacbd3c04268d4446b3a7f2b1 Some thoughts: β€’ v2 seems less boilerplate to define all states (even though the number of lines ended up being about the same for the whole code) β€’ v2 feels more deliberate about all transition states, in my v1, the Initial to Normal transition was automatic and I didn't expect that in the beginning. Although, it would be great to know what the recommended way is to have a transition that runs immediately after the view has been rendered the first time. β€’ I can see easily see how one can convert a set of "animate()" calls to transitions, which is great! β€’ Personal preference but this function for defining the transition spec between the initial -> target state was more readable
transition(FabState.Normal to FabState.Exploded)
as compared to
if (it.initialState == FabState.Initial && it.targetState == FabState.Normal)
Btw, is it intentional that if I write this:
Copy code
val fabSize by transition.animateDp(
        transitionSpec = {
            keyframes {
                durationMillis = 500
                58.dp at 0
                48.dp at 200
                1500.dp at 500
            }
        }
    ) {
        when (it) {
            initialState -> 20.dp
            normalState -> 56.dp
            explodedState -> 1500.dp
            else -> 56.dp
        }
    }
The animation always goes to
1500.dp
even if the state is
normalState
?
d
@Afzal Najam Thanks for the feedback and for sharing the code! I really appreciate that! β€’ We are evaluating a few different ways to support a different initial state than the first state being passed in. Having
initialState
be a parameter to
transition
like in v1 has led to some confusion around what should happen when
initialState
changes during a transition animation (i.e. restart everything or ignore it, both of which make sense). For v2 we are trying to avoid such confusion, yet provide the support through other solutions. Stay tuned on that. πŸ™‚ β€’ I'm glad you see it as a straightforward conversion from
animate
. We aim to make it minimum effort to animate things.😁 So we expect folks to start with
animate
and progress to
Transition
as needed. β€’ Very insightful feedback on the ergonomics of
transitionSpec
! πŸ™ I'm also considering a transition spec builder that supports selective overwrites of the default animations. This feedback is very helpful.πŸ‘
πŸ‘ 1
The expected behavior for the code snippet above is to animate to
1500.dp
(as defined by
keyframes
) then snap to whatever value defined for the state. It shouldn't "rest" at
1500.dp
for any state other than
explodedState
. I'll file a bug to fix this. Thanks for reporting it. πŸ™‚
πŸ‘ 1
a
Looking forward to seeing future updates to this! And yes, that's what was happening. It went all the way to 1500.dp then reset the value to the size defined for normalState so I guess that was working as intended.
πŸ™‚ 1
r
@Doris Liu via dropdown inputfield loosing focus when suggestions shown