react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

[ENHANCEMENT] Add support for gestureResponseDistance for iOS pop gestures

Open mrousavy opened this issue 3 years ago • 9 comments

Problem

Currently you can only enable or disable the swipe from left edge to right edge gesture to pop screens on iOS. Some apps have this gesture, but instead of only being able to only swipe from the left most edge of the screen, you can swipe from anywhere, such as the middle of the screen (e.g.: Instagram Chats, Telegram)

The react-navigation library has the property gestureResponseDistance, which is exactly that. It would be awesome to have that supported in the react-native-navigation library as-well

Solution

Unfortunately, as solution to this isn't as simple as in the react-navigation library, since we can't simply use some react-native-gesture-handler tricks. Instead, we have to create a custom UIGestureRecognizer and bind it to the interactivePopGestureRecognizer. I found this answer on stackoverflow which also provides a code solution.

I'm creating this issue as a discussion point, rather than an actual issue. @wix: feel free to close if this isn't going anywhere.

  • In case the original iOS interactivePopGestureRecognizer changes at some point in the future, we have to mimic that new behavior and adjust it in our copy
  • This is a lot of code just for a simple property
    • More to maintain
    • More error prone
    • Behavior isn't really requested by many people

Let me know if you still want me to open a PR with the proposed changes!

mrousavy avatar Sep 08 '20 14:09 mrousavy

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest version and report back. Thank you for your contributions.

stale[bot] avatar Oct 12 '20 00:10 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Dec 02 '20 14:12 stale[bot]

@mrousavy We can easily implement this solution and add popGestureMode?: 'bezel' | 'entireScreen' to control it. wdyt?

yogevbd avatar Dec 17 '20 11:12 yogevbd

@yogevbd That's a good idea, what do you think about just giving the user full control via an x coordinate value?

So:

popGestureX: Dimensions.get('window').width * 0.1
popGestureX: Dimensions.get('window').width * 0.5
popGestureX: Dimensions.get('window').width

mrousavy avatar Dec 17 '20 11:12 mrousavy

@mrousavy it does add flexibility but I'm not sure it's needed here.. I think that keeping it simple better serves our users

yogevbd avatar Dec 17 '20 11:12 yogevbd

Makes sense to me. I think I have some time tomorrow/saturday if you're too busy to look into this yourself! @yogevbd

mrousavy avatar Dec 17 '20 15:12 mrousavy

@mrousavy @yogevbd Hi, is there an update here? Would be cool to have this feature.

hukpo avatar Jan 08 '21 21:01 hukpo

I managed to implement the full-screen pop gesture:

https://user-images.githubusercontent.com/15199031/122741658-73c97d00-d285-11eb-9bb7-fdedf6488ea9.MP4

but it takes over all other gestures - i.e. I can't even scroll on the chat page anymore. I tried to override the delegate stubs:

- (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
  NSLog(@"shouldRecognizeSimultaneouslyWithGestureRecognizer?");
  return NO;
}

- (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
  NSLog(@"shouldRequireFailureOfGestureRecognizer?");
  return YES;
}

- (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
  NSLog(@"shouldBeRequiredToFailByGestureRecognizer?");
  return YES;
}

but the bottom ones are not called at all, only shouldRecognizeSimultaneouslyWithGestureRecognizer is called. Also it makes no difference if I return YES or NO in that stub.. 🤨

mrousavy avatar Jun 21 '21 09:06 mrousavy

Any updates on this?

ghiculescualexandru avatar Apr 04 '22 14:04 ghiculescualexandru

@mrousavy any chance of revisiting this? This would be such a "breakthrough" feature, as seemingly every well produced mainstream app allows swiping back from anywhere on the screen. It's to the point where, if an app doesn't allow it - you kind of almost feels like some sort of inferior UX.

techno-mad avatar Dec 26 '22 16:12 techno-mad