react-native-screens
react-native-screens copied to clipboard
fix (iOS): Swipe down to dismiss screen with ScrollView on iOS
Description
Following the changes done in PR #1512, we encountered an issue where we couldn't swipe down to dismiss a modal screen on iOS if this screen contained a ScrollView.
To fix this, we made some check in the RNSScreenStack.mm
file, more specifically in the - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
method to check if the gesture is coming from a ScrollView, and if so, check if this scroll view's content offset is less than or equal to 0. If so, we allow the swipe to dismiss gesture and cancel the scroll view's gesture.
Changes
- Added fix in
RNNScreenStack.mm
- Added a reproducible example Test1902 in
TestsExample
Screenshots / GIFs
https://github.com/software-mansion/react-native-screens/assets/11820540/5860adf6-9a57-4b1f-bc90-7c9094ea9d05
Test code and steps to reproduce
See Test1902 in TestsExample
. In order to enable this feature, you need to have these options :
animation: 'slide_from_bottom',
fullScreenGestureEnabled: true,
gestureDirection: 'vertical'
Checklist
- [x] Included code example that can be used to test this change
- [x] Updated TS types
- [x] Updated documentation:
- [ ] https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md
- [ ] https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md
- [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx
- [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx
- [x] Ensured that CI passes