Skip to content

Commit

Permalink
fix: keep RTL in consideration for gestures and slide_from_left trans…
Browse files Browse the repository at this point in the history
…ition
  • Loading branch information
kirillzyusko committed Mar 6, 2024
1 parent f918632 commit 1deddf8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ios/RNSScreenStack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -749,14 +749,14 @@ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
// Now we're dealing with RNSScreenEdgeGestureRecognizer (or _UIParallaxTransitionPanGestureRecognizer)
if (topScreen.customAnimationOnSwipe && [RNSScreenStackAnimator isCustomAnimation:topScreen.stackAnimation]) {
if ([gestureRecognizer isKindOfClass:[RNSScreenEdgeGestureRecognizer class]]) {
UIRectEdge edges = ((RNSScreenEdgeGestureRecognizer *)gestureRecognizer).edges;
BOOL isRTL = _controller.view.semanticContentAttribute == UISemanticContentAttributeForceRightToLeft;
BOOL isSlideFromLeft = topScreen.stackAnimation == RNSScreenStackAnimationSlideFromLeft;
// if we do not set any explicit `semanticContentAttribute`, it is `UISemanticContentAttributeUnspecified` instead
// of `UISemanticContentAttributeForceLeftToRight`, so we just check if it is RTL or not
BOOL isCorrectEdge = (_controller.view.semanticContentAttribute == UISemanticContentAttributeForceRightToLeft &&
((RNSScreenEdgeGestureRecognizer *)gestureRecognizer).edges == UIRectEdgeRight) ||
(topScreen.stackAnimation == RNSScreenStackAnimationSlideFromLeft &&
((RNSScreenEdgeGestureRecognizer *)gestureRecognizer).edges == UIRectEdgeRight) ||
(_controller.view.semanticContentAttribute != UISemanticContentAttributeForceRightToLeft &&
((RNSScreenEdgeGestureRecognizer *)gestureRecognizer).edges == UIRectEdgeLeft);
BOOL isCorrectEdge = (isRTL && edges == UIRectEdgeRight) ||
(!isRTL && isSlideFromLeft && edges == UIRectEdgeRight) ||
(isRTL && isSlideFromLeft && edges == UIRectEdgeLeft) || (!isRTL && edges == UIRectEdgeLeft);
if (isCorrectEdge) {
[self cancelTouchesInParent];
return YES;
Expand Down

0 comments on commit 1deddf8

Please sign in to comment.