question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[iOS] Add "peek and pop" (3d touch) capabilities to RN

See original GitHub issue

#3055 will transmit 3d touch props during touch events. However the “peek and pop” feature presented by Apple is still very hard to implement just using pressure events. My goal would be to implement in a related PR a wrapper around iOS’s UIViewControllerPreviewingDelegate Protocol that makes it easy to create “peek and pop” previews. This protocol works well on iOS but may not be really friendly with the way React does things. On that, I would like to get your input.

In my opinion, the React way of doing things is still handling an event but use a component or an API that would wrap UIPreviewAction, UIPreviewActionGroup and the UIPreviewActionItem Protocol to display the preview and its action group.

How would you do that ? Once I get the right way of doing things here, I can try to implement it!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:21 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
brentvatnecommented, Oct 5, 2015

I have a working (yet not fully featured) example here: https://github.com/brentvatne/PeekPopAttempt

Feel free to flesh it out and distribute as a package on npm. The main missing features are:

  • need to be able to set the height of the peek preview, which you can do by setting preferredContentSize of the controller being peeked.
  • need to be able to specify what actions can be taken / fire appropriate callbacks in JS when they are.

Usage looks like this:

<Peekable.View renderPreview={this._renderPreviewOne} onPop={this._handlePopOne}>
   <View style={styles.button}>
     <Text>Tap me to peek!</Text>
   </View>
</Peekable.View>

and…

  _renderPreviewOne() {
    return (
      <Image source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}} style={{width: 400, height: 400}} />
    )
  },

and…

  _handlePopOne() {
    alert('pop first one!');
   // You could push some route to navigator or setState or whatever here
  },
1reaction
boournscommented, Sep 29, 2015

@ide can a JS implementation match the experience of the native implementation? I just tried this feature on a 6s; it is extremely polished. Blur increases as I increase finger pressure in a very delightful manner.

I mean, anything’s possible, but by going the javascript route you give up a lot of the functionality you get for “free” on iOS if you were to use a UIViewController.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implementing Peek and Pop | Apple Developer Documentation
This sample project demonstrates previewing content and providing quick shortcuts to functionality using Peek and Pop APIs. The app uses a table view...
Read more >
Supporting 3D Touch “Peek and Pop” | by Stephen Anthony
Supporting specific hardware features that ship with iOS devices is one of the primary benefits of developing completely native applications.
Read more >
Peek and Pop With 3D Touch - RayWenderlich.com
In this tutorial, you'll implement Peek and Pop, which enables you to preview content of the navigating view controller.
Read more >
Here Comes the iPhone 6S What s New Should You Upgrade
3D Touch 3D Touch is another way of saying "push your finger right through ... You can preview new email in Mail with...
Read more >
What s New in iOS 10 Everything Coming to Your iPhone This ...
New Messages Features Probably the biggest list of changes in iOS 10 belongs ... will work on non-3D-Touch devices remains to be seen...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found