Fix for broken swipe back gesture in RTL mode (#4119)

* 3127: Fixed gestureDirectionInverted variable declaration and condition in onPanResponderMove method in regards to swipe back action in RTL mode.

* - 4118: Put axis check first;
- Fixed default BackButton mask in RTL mode.
This commit is contained in:
spaceye 2018-05-06 22:42:22 +03:00 committed by Eric Vicenti
parent 1bd6593ede
commit 8ec2466fef
2 changed files with 8 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import {
Platform, Platform,
StyleSheet, StyleSheet,
View, View,
I18nManager,
ViewPropTypes, ViewPropTypes,
} from 'react-native'; } from 'react-native';
import { MaskedViewIOS } from '../../PlatformHelpers'; import { MaskedViewIOS } from '../../PlatformHelpers';
@ -565,6 +566,7 @@ const styles = StyleSheet.create({
marginTop: -0.5, // resizes down to 20.5 marginTop: -0.5, // resizes down to 20.5
alignSelf: 'center', alignSelf: 'center',
resizeMode: 'contain', resizeMode: 'contain',
transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
}, },
title: { title: {
bottom: 0, bottom: 0,

View File

@ -227,8 +227,12 @@ class StackViewLayout extends React.Component {
const { index } = navigation.state; const { index } = navigation.state;
const isVertical = mode === 'modal'; const isVertical = mode === 'modal';
const { options } = scene.descriptor; const { options } = scene.descriptor;
const gestureDirection = options.gestureDirection;
const gestureDirectionInverted = options.gestureDirection === 'inverted'; const gestureDirectionInverted =
typeof gestureDirection === 'string'
? gestureDirection === 'inverted'
: I18nManager.isRTL;
const gesturesEnabled = const gesturesEnabled =
typeof options.gesturesEnabled === 'boolean' typeof options.gesturesEnabled === 'boolean'
@ -302,7 +306,7 @@ class StackViewLayout extends React.Component {
? layout.height.__getValue() ? layout.height.__getValue()
: layout.width.__getValue(); : layout.width.__getValue();
const currentValue = const currentValue =
(I18nManager.isRTL && axis === 'dx') !== gestureDirectionInverted axis === 'dx' && gestureDirectionInverted
? startValue + gesture[axis] / axisDistance ? startValue + gesture[axis] / axisDistance
: startValue - gesture[axis] / axisDistance; : startValue - gesture[axis] / axisDistance;
const value = clamp(index - 1, currentValue, index); const value = clamp(index - 1, currentValue, index);