Kolos65 / InstagramTransition

Replicating Instagram's gesture-driven shared-element transition using UIKit.
19 stars 0 forks source link

The possibility of interaction during InstagramTransition transition. #6

Open Juhnkerg opened 3 months ago

Juhnkerg commented 3 months ago

Hi @Kolos65 ,

I hope this message finds you well.I think the transition of InstagramTransition is very good, so recently I tried to apply the transition of InstagramTransition to a custom ContextMenu. However, I want to make sure that during the transition process (which is not over yet), ContextMenu elements such as buttons can be tapped.

But I tried a lot of things without success. I know you have a lot of experience, so I would like to ask you about how to implement the transition and be able to interact before it is over.

I know that a UIView can be tapped during animation, but I haven't tried the button in a UIView.

I've been trying to transition ViewControllers. For example, in the transition from fromViewController to toViewController, I wanted to be able to tap on atableView in toViewController during the transition, but I was frustrated and found it very difficult to implement. I would like to ask you about the possibilities of interaction during the Viewcontrollers transition.

(PS: I uploaded a GIF example of the plus button on the left of the input box in iMessage. After tapping the plus button, you can tap the "Apple Cash" button before the transition is finished.)

Your advice would be incredibly valuable to me. Thank you in advance for your time and assistance.

Best regards, Juhnkerg

Simulator Screen Recording

Kolos65 commented 3 months ago

Hey @Juhnkerg!

Have you tried setting options: [.allowUserInteraction] parameter on the UIView.animate() call?

I'm afraid achieving this is more complex, will let you know if I have any ideas.

Juhnkerg commented 3 months ago

Hi @Kolos65,

I had tried setting options: [.allowUserInteraction] parameter on the UIView.animate() call.

Indeed, I have tried many ways, and it's very difficult to achieve that.

Juhnkerg commented 3 months ago

@Kolos65 Thank you very much for your reply. I submitted this question on apple's Developer Forums not long ago under the suggestion of the engineer of wwdc24 UIKit consultation, but I have not received any reply so far. https://developer.apple.com/forums/thread/757029

However, I have recently found some information on how this might be done. I hope it inspires some thinking.

WWDC 2016 video 216 Advances in UIKit Animations and Transitions

https://devstreaming-cdn.apple.com/videos/wwdc/2016/216v55u6zpxizxkml6k/216/216_hd_advances_in_uikit_animations_and_transitions.mp4

And the demo inside

PhotoTransitioning: Using UIViewPropertyAnimator to create a fully interative and interruptible custom view controller transition

https://developer.apple.com/library/archive/samplecode/PhotoTransitioning/Introduction/Intro.html#//apple_ref/doc/uid/TP40017554

Kolos65 commented 3 months ago

@Juhnkerg what I have found is that user interaction works during the pop animation, but not during push which is weird...

What I would try is to implement the non-interactive push and pop animation with an interaction controller and check it that way. Maybe UIKit will only enable user interactions during transition if it's an interactive transition.

Juhnkerg commented 3 months ago

It's really weird and complicated. I am reading PhotoTransitioning this Apple demo.

I see the inside of the class AssetTransitionDriver - init - fromAssetTransitioning.itemsForTransition(context: context).filter - imageView, a UILongPressGestureRecognizer. It makes it possible to reverse the transition by clicking on an imageView during transition, but switching to another UIGestureRecognizer does not work.

I have an idea. Could this be possible? When using UIViewControllerInteractiveTransitioning, and then tap suspend transition, then after interaction, to continue or reverse the transition?