bamlab / react-tv-space-navigation

A React Native module to handle spatial navigation for a TV application in a 100% cross-platform way
https://bamlab.github.io/react-tv-space-navigation/
MIT License
201 stars 17 forks source link

Handling long press events #36

Open pierpo opened 9 months ago

pierpo commented 9 months ago

Is your feature request related to a problem? Please describe. We can't detect a long press right now.

Describe the solution you'd like

<SpatialNavigationNode isFocusable onLongSelect={() => {}} />

Describe alternatives you've considered N/A

Additional context N/A

fulminant commented 5 months ago

+1. It would be a great feature.

fulminant commented 4 months ago

Investigated this issue a little bit, and I can say that it is not an easy task. LRUD library doesn't handle long press events in any variant. That means that to implement this feature we need to modify LRUD library and add longPress handle there and only after that implement it in SpatialNode.

We can use react-native Pressable component for example and see how it is accomplished there. https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Pressability/Pressability.js There are a lot of tricky moments in this code.