fix: containedTransparentModal swipe back gesture issue#1514
Conversation
…ve-screens into @hurali97/contained-transparent-modal-gesture-fix
|
@kkafar or anyone would want to review 👍 |
kkafar
left a comment
There was a problem hiding this comment.
Thank you for your contribution!
Gesture recogniser logic received overhaul recently:
So this PR needs to be updated & conform to the new business logic.
I will also need your to revert the changes in Podfile.lock, remove commented out code, and possibly add empty lines at file ends (you can see it easliy on github overview).
I'll come back shortly to review the changes from the perspective of business logic
Hey, I incorporated to the required changes. Prevented the sending of events to RNSPanGestureRecognizer if the modal is opened. Tested the updated changes on the Test1072, doesn't break it either. Also, regarding the empty lines, git preview seems to truncates the empty lines at bottom. |
|
Hi @kkafar :) I checked out the commit, but I am getting unexpected outputs. Please see the attached videos for reference: Below is the output when I import { createNativeStackNavigator, NativeStackNavigationOptions } from 'react-native-screens/native-stack'; rns.native-stack.mp4This one is the output when I import { createNativeStackNavigator, NativeStackNavigationOptions } from '@react-navigation/native-stack'; react-nav.native-stack.mp4Also, I tried to see Test1509 it seems to fix the issue for vertical swipe without specifying on the parent screen, but if you try removing the swipeDirection from the second screen too, the default horizontal swipe for back doesn't work, producing the same result as first video. Also, please see second video, it should be noted that the swipe doesn't work on the opened modal (perfect) but it doesn't also work on the standalone screen. |
* fix: don't change screen on which you handleSwipe when we were swiping with the current logic in the next frame properties were taken from previous screen * chore: add example Co-authored-by: Wojciech Lewicki <wojciech.lewicki@swmansion.com> * chore: rename test example Co-authored-by: Wojciech Lewicki <wojciech.lewicki@swmansion.com> * chore: add test for #1476 Submitted in #1514 by @hurali97 Co-authored-by: Muhammad Hur Ali <hurali87@gmail.com> * chore: add dependency on @react-navigation/native-stack Required by Test1509v2 * fix: typo in comment * chore: remove test 1509v2 Co-authored-by: Wojciech Lewicki <wojciech.lewicki@swmansion.com> Co-authored-by: Kacper Kafara <kacperkafara@gmail.com> Co-authored-by: Muhammad Hur Ali <hurali87@gmail.com>
|
@hurali97 Edit:
To have "default horizontal swipe working" you would need to set Also please keep in mind, that screen prop names in |
Description
This PR aims to fix the gesture issue on the modal presentation 'containedTransparentModal'. The issue is raised here: #1476 (comment)
So if we look at the video attached in the above issue, we'd see the swipe back gesture works (which it shouldn't) when the presentations type is 'containedTransparentModal' and it doesn't work(excellent) when the presentation type is 'transparentModal'.
Changes
The method
gestureRecognizerShouldBeginis checking fortopScreenbut not for thetopModal, and ideally it should check for it. So the idea is to compare thetopModalis presented by thetopScreenand if yes, we obscure the gesture and returnNO. And obviously, if the topModal isn't being presented we check forisAttachedflag to let the gestures flow.Relevant changes: 15fb9dd
Before (This Before video is taken from the issue link provided above)
before.mp4
After
after.mp4
Test code and steps to reproduce
The code is taken from here and added in TestExample dir, below is the repro provided by the issue opener.
https://github.com/NguyenHoangMinhkkkk/navigation-reproduce
Comment out the below fixes,
pod installand rebuild the TestExample iOS project and you should be able to repro.15fb9dd
Checklist