nathantannar4 / Transmission

Bridges UIKit presentation APIs to a SwiftUI API so you can use presentation controllers, interactive transitions and more.
BSD 2-Clause "Simplified" License
378 stars 13 forks source link

HeroMove Transition for larger views #5

Closed Saim-Khan1 closed 1 year ago

Saim-Khan1 commented 1 year ago

Hi @nathantannar4! Hope you're doing well, I just stumbled across this repo and it's exactly what I've needed for a long time, thanks a lot for doing this!

Just one thing I noticed, for the hero move transition, it only really seems to work well if the source view is fairly small (like the blue square example or the pictures in the grid in your example app). I have some cards in my app that I'd like to animate an expanding transition for (a bit like the cards in the App Store), but it doesn't seem to expand as smoothly (e.g. the height doesn't really animate), and sort of fades instead, like this:

HeroMove transition

For reference, https://github.com/sebjvidal/UIViewControllerAnimatedTransitioning-Demo has some cards that are almost full-width that seem to expand quite nicely, or the below example:

App Store card example

If I am doing something wrong, or if there's any way to achieve something like this please let me know! Thanks a lot for your help :)

nathantannar4 commented 1 year ago

The hero move transition is not feature complete. It's just there as a demonstration of what is possible and so one could adapt it to how they would like it to behave. That's why it's not in the library itself, just the example project.

You'll need to change the transition code. Currently when it the interaction ends, it fades between the two views.

Saim-Khan1 commented 1 year ago

Ahh I see, thanks for clarifying. I don't actually use UIKit myself, would you be able to point me to whereabouts it says the views should fade? And I can try and figure something out :)

nathantannar4 commented 1 year ago

You'll need to learn about UIViewControllerInteractiveTransitioning and UIViewControllerAnimatedTransitioning. Look at the source code for the heroMove transition in the example and you'll see it.

Saim-Khan1 commented 1 year ago

Perfect, could you point me to whereabouts in the source code the fade happens? To be honest it's already very close to what I would like to happen anyway, just as I said it needs to expand and shrink properly even with the source view being the size it is (as it does when the source view is smaller, as in the GIF above), as I am not too familiar with UIKit myself would you be able to highlight how I could do this? I was thinking maybe there's some logic in your code that checks for the sizing and behaves accordingly? If not if you could point me in the right direction I would really appreciate it, as long as it doesn't take too much of your time!