dominicstop / react-native-ios-context-menu

A react-native component to use context menu's (UIMenu) on iOS 13/14+
MIT License
566 stars 28 forks source link

Add ability to show a new view when Preview.ContextMenuInteractionCommitStyle is "pop" #39

Open j-braun0384 opened 2 years ago

j-braun0384 commented 2 years ago

It would be so cool if we can nicely transition to a new view/screen when we pop the preview after pressing it - a very commonly used tactic in many mainstream apps (twitter, instagram etc.).

Looking at this article: https://kylebashour.com/posts/context-menu-guide - seems the way to go is to tap into the animator.addCompletion instance method from the contextMenuInteraction func like so:

func contextMenuInteraction(_ interaction: UIContextMenuInteraction, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) {
    animator.addCompletion {
       // HERE WE DEFINE THE LOGIC TO SHOW A PASSED IN VIEW?
        if let viewController = animator.previewViewController {
            self.show(viewController, sender: self)
        }
    }
}

We should be able to house this logic within RNIContextMenuView.swift

...thoughts?

nandorojo commented 1 year ago

To clarify: one example of this is Twitter. If you long press a tweet, and then click into it, it'll nicely transition into the next tweet screen. This would be a cool feature.

klosmo commented 10 months ago

@nandorojo this feature would be one of those "bridge closing" efforts towards fully native feeling apps in RN. Any idea if this is in the works or being considered?

nandorojo commented 10 months ago

It would be cool, might need to be on the RN screens side though. Honestly don't know what it would take.

klosmo commented 4 months ago

@nandorojo want to revisit this enhancement now that the new architecture is stable and implementing something like this should be easier. Here is another great article on this feature for reference: https://nsscreencast.com/episodes/485-context-menus-previews

if this requires some cooperation from react-native-screens, i think it'll really be worth the time to poke them for involvement. Can't understate how big of a feature this would be.