@react-navigation/stack 7.0.0-alpha.2 → 7.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/TransitionConfigs/HeaderStyleInterpolators.js +19 -12
- package/lib/commonjs/TransitionConfigs/HeaderStyleInterpolators.js.map +1 -1
- package/lib/commonjs/navigators/createStackNavigator.js +4 -0
- package/lib/commonjs/navigators/createStackNavigator.js.map +1 -1
- package/lib/commonjs/utils/getDistanceForDirection.js +2 -2
- package/lib/commonjs/utils/getDistanceForDirection.js.map +1 -1
- package/lib/commonjs/utils/getInvertedMultiplier.js +3 -4
- package/lib/commonjs/utils/getInvertedMultiplier.js.map +1 -1
- package/lib/commonjs/views/Header/HeaderSegment.js +5 -0
- package/lib/commonjs/views/Header/HeaderSegment.js.map +1 -1
- package/lib/commonjs/views/Stack/Card.js +23 -6
- package/lib/commonjs/views/Stack/Card.js.map +1 -1
- package/lib/commonjs/views/Stack/CardContainer.js +4 -0
- package/lib/commonjs/views/Stack/CardContainer.js.map +1 -1
- package/lib/commonjs/views/Stack/CardStack.js +9 -8
- package/lib/commonjs/views/Stack/CardStack.js.map +1 -1
- package/lib/commonjs/views/Stack/StackView.js.map +1 -1
- package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js +20 -13
- package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js.map +1 -1
- package/lib/module/navigators/createStackNavigator.js +5 -1
- package/lib/module/navigators/createStackNavigator.js.map +1 -1
- package/lib/module/utils/getDistanceForDirection.js +2 -2
- package/lib/module/utils/getDistanceForDirection.js.map +1 -1
- package/lib/module/utils/getInvertedMultiplier.js +3 -4
- package/lib/module/utils/getInvertedMultiplier.js.map +1 -1
- package/lib/module/views/Header/HeaderSegment.js +5 -0
- package/lib/module/views/Header/HeaderSegment.js.map +1 -1
- package/lib/module/views/Stack/Card.js +23 -6
- package/lib/module/views/Stack/Card.js.map +1 -1
- package/lib/module/views/Stack/CardContainer.js +5 -1
- package/lib/module/views/Stack/CardContainer.js.map +1 -1
- package/lib/module/views/Stack/CardStack.js +9 -8
- package/lib/module/views/Stack/CardStack.js.map +1 -1
- package/lib/module/views/Stack/StackView.js.map +1 -1
- package/lib/typescript/src/TransitionConfigs/HeaderStyleInterpolators.d.ts +3 -3
- package/lib/typescript/src/TransitionConfigs/HeaderStyleInterpolators.d.ts.map +1 -1
- package/lib/typescript/src/navigators/createStackNavigator.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +9 -5
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/getDistanceForDirection.d.ts +1 -1
- package/lib/typescript/src/utils/getDistanceForDirection.d.ts.map +1 -1
- package/lib/typescript/src/utils/getInvertedMultiplier.d.ts +1 -1
- package/lib/typescript/src/utils/getInvertedMultiplier.d.ts.map +1 -1
- package/lib/typescript/src/views/Header/HeaderSegment.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/Card.d.ts +2 -0
- package/lib/typescript/src/views/Stack/Card.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/CardContainer.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/CardStack.d.ts +2 -1
- package/lib/typescript/src/views/Stack/CardStack.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/StackView.d.ts +2 -1
- package/lib/typescript/src/views/Stack/StackView.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/TransitionConfigs/HeaderStyleInterpolators.tsx +32 -22
- package/src/navigators/createStackNavigator.tsx +3 -0
- package/src/types.tsx +9 -4
- package/src/utils/getDistanceForDirection.tsx +3 -2
- package/src/utils/getInvertedMultiplier.tsx +4 -5
- package/src/views/Header/HeaderSegment.tsx +4 -0
- package/src/views/Stack/Card.tsx +38 -7
- package/src/views/Stack/CardContainer.tsx +4 -1
- package/src/views/Stack/CardStack.tsx +23 -8
- package/src/views/Stack/StackView.tsx +4 -5
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Animated
|
|
1
|
+
import { Animated } from 'react-native';
|
|
2
2
|
|
|
3
3
|
import type {
|
|
4
4
|
StackHeaderInterpolatedStyle,
|
|
5
5
|
StackHeaderInterpolationProps,
|
|
6
6
|
} from '../types';
|
|
7
7
|
|
|
8
|
-
const { add } = Animated;
|
|
8
|
+
const { add, multiply } = Animated;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Standard UIKit style animation for the header where the title fades into the back button label.
|
|
@@ -13,6 +13,7 @@ const { add } = Animated;
|
|
|
13
13
|
export function forUIKit({
|
|
14
14
|
current,
|
|
15
15
|
next,
|
|
16
|
+
direction,
|
|
16
17
|
layouts,
|
|
17
18
|
}: StackHeaderInterpolationProps): StackHeaderInterpolatedStyle {
|
|
18
19
|
const defaultOffset = 100;
|
|
@@ -34,6 +35,8 @@ export function forUIKit({
|
|
|
34
35
|
// The back title also animates in from this position
|
|
35
36
|
const rightOffset = layouts.screen.width / 4;
|
|
36
37
|
|
|
38
|
+
const multiplier = direction === 'rtl' ? -1 : 1;
|
|
39
|
+
|
|
37
40
|
const progress = add(
|
|
38
41
|
current.progress.interpolate({
|
|
39
42
|
inputRange: [0, 1],
|
|
@@ -59,12 +62,13 @@ export function forUIKit({
|
|
|
59
62
|
leftLabelStyle: {
|
|
60
63
|
transform: [
|
|
61
64
|
{
|
|
62
|
-
translateX:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
: [leftLabelOffset, 0, -rightOffset],
|
|
67
|
-
|
|
65
|
+
translateX: multiply(
|
|
66
|
+
multiplier,
|
|
67
|
+
progress.interpolate({
|
|
68
|
+
inputRange: [0, 1, 2],
|
|
69
|
+
outputRange: [leftLabelOffset, 0, -rightOffset],
|
|
70
|
+
})
|
|
71
|
+
),
|
|
68
72
|
},
|
|
69
73
|
],
|
|
70
74
|
},
|
|
@@ -81,24 +85,26 @@ export function forUIKit({
|
|
|
81
85
|
}),
|
|
82
86
|
transform: [
|
|
83
87
|
{
|
|
84
|
-
translateX:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
: [rightOffset, 0, -titleLeftOffset],
|
|
89
|
-
|
|
88
|
+
translateX: multiply(
|
|
89
|
+
multiplier,
|
|
90
|
+
progress.interpolate({
|
|
91
|
+
inputRange: [0.5, 1, 2],
|
|
92
|
+
outputRange: [rightOffset, 0, -titleLeftOffset],
|
|
93
|
+
})
|
|
94
|
+
),
|
|
90
95
|
},
|
|
91
96
|
],
|
|
92
97
|
},
|
|
93
98
|
backgroundStyle: {
|
|
94
99
|
transform: [
|
|
95
100
|
{
|
|
96
|
-
translateX:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
: [layouts.screen.width, 0, -layouts.screen.width],
|
|
101
|
-
|
|
101
|
+
translateX: multiply(
|
|
102
|
+
multiplier,
|
|
103
|
+
progress.interpolate({
|
|
104
|
+
inputRange: [0, 1, 2],
|
|
105
|
+
outputRange: [layouts.screen.width, 0, -layouts.screen.width],
|
|
106
|
+
})
|
|
107
|
+
),
|
|
102
108
|
},
|
|
103
109
|
],
|
|
104
110
|
},
|
|
@@ -151,8 +157,10 @@ export function forFade({
|
|
|
151
157
|
export function forSlideLeft({
|
|
152
158
|
current,
|
|
153
159
|
next,
|
|
160
|
+
direction,
|
|
154
161
|
layouts: { screen },
|
|
155
162
|
}: StackHeaderInterpolationProps): StackHeaderInterpolatedStyle {
|
|
163
|
+
const isRTL = direction === 'rtl';
|
|
156
164
|
const progress = add(
|
|
157
165
|
current.progress.interpolate({
|
|
158
166
|
inputRange: [0, 1],
|
|
@@ -170,7 +178,7 @@ export function forSlideLeft({
|
|
|
170
178
|
|
|
171
179
|
const translateX = progress.interpolate({
|
|
172
180
|
inputRange: [0, 1, 2],
|
|
173
|
-
outputRange:
|
|
181
|
+
outputRange: isRTL
|
|
174
182
|
? [-screen.width, 0, screen.width]
|
|
175
183
|
: [screen.width, 0, -screen.width],
|
|
176
184
|
});
|
|
@@ -191,8 +199,10 @@ export function forSlideLeft({
|
|
|
191
199
|
export function forSlideRight({
|
|
192
200
|
current,
|
|
193
201
|
next,
|
|
202
|
+
direction,
|
|
194
203
|
layouts: { screen },
|
|
195
204
|
}: StackHeaderInterpolationProps): StackHeaderInterpolatedStyle {
|
|
205
|
+
const isRTL = direction === 'rtl';
|
|
196
206
|
const progress = add(
|
|
197
207
|
current.progress.interpolate({
|
|
198
208
|
inputRange: [0, 1],
|
|
@@ -210,7 +220,7 @@ export function forSlideRight({
|
|
|
210
220
|
|
|
211
221
|
const translateX = progress.interpolate({
|
|
212
222
|
inputRange: [0, 1, 2],
|
|
213
|
-
outputRange:
|
|
223
|
+
outputRange: isRTL
|
|
214
224
|
? [screen.width, 0, -screen.width]
|
|
215
225
|
: [-screen.width, 0, screen.width],
|
|
216
226
|
});
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
StackNavigationState,
|
|
9
9
|
StackRouter,
|
|
10
10
|
StackRouterOptions,
|
|
11
|
+
useLocale,
|
|
11
12
|
useNavigationBuilder,
|
|
12
13
|
} from '@react-navigation/native';
|
|
13
14
|
import * as React from 'react';
|
|
@@ -36,6 +37,7 @@ function StackNavigator({
|
|
|
36
37
|
screenOptions,
|
|
37
38
|
...rest
|
|
38
39
|
}: Props) {
|
|
40
|
+
const { direction } = useLocale();
|
|
39
41
|
const { state, descriptors, navigation, NavigationContent } =
|
|
40
42
|
useNavigationBuilder<
|
|
41
43
|
StackNavigationState<ParamListBase>,
|
|
@@ -81,6 +83,7 @@ function StackNavigator({
|
|
|
81
83
|
<NavigationContent>
|
|
82
84
|
<StackView
|
|
83
85
|
{...rest}
|
|
86
|
+
direction={direction}
|
|
84
87
|
state={state}
|
|
85
88
|
descriptors={descriptors}
|
|
86
89
|
navigation={navigation}
|
package/src/types.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
} from '@react-navigation/elements';
|
|
8
8
|
import type {
|
|
9
9
|
Descriptor,
|
|
10
|
+
LocaleDirection,
|
|
10
11
|
NavigationHelpers,
|
|
11
12
|
NavigationProp,
|
|
12
13
|
ParamListBase,
|
|
@@ -429,19 +430,19 @@ export type StackCardInterpolatedStyle = {
|
|
|
429
430
|
/**
|
|
430
431
|
* Interpolated style for the container view wrapping the card.
|
|
431
432
|
*/
|
|
432
|
-
containerStyle?:
|
|
433
|
+
containerStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
433
434
|
/**
|
|
434
435
|
* Interpolated style for the view representing the card.
|
|
435
436
|
*/
|
|
436
|
-
cardStyle?:
|
|
437
|
+
cardStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
437
438
|
/**
|
|
438
439
|
* Interpolated style for the view representing the semi-transparent overlay below the card.
|
|
439
440
|
*/
|
|
440
|
-
overlayStyle?:
|
|
441
|
+
overlayStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
441
442
|
/**
|
|
442
443
|
* Interpolated style representing the card shadow.
|
|
443
444
|
*/
|
|
444
|
-
shadowStyle?:
|
|
445
|
+
shadowStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
445
446
|
};
|
|
446
447
|
|
|
447
448
|
export type StackCardStyleInterpolator = (
|
|
@@ -468,6 +469,10 @@ export type StackHeaderInterpolationProps = {
|
|
|
468
469
|
*/
|
|
469
470
|
progress: Animated.AnimatedInterpolation<number>;
|
|
470
471
|
};
|
|
472
|
+
/**
|
|
473
|
+
* Writing direction of the layout.
|
|
474
|
+
*/
|
|
475
|
+
direction: LocaleDirection;
|
|
471
476
|
/**
|
|
472
477
|
* Layout measurements for various items we use for animation.
|
|
473
478
|
*/
|
|
@@ -3,9 +3,10 @@ import { getInvertedMultiplier } from './getInvertedMultiplier';
|
|
|
3
3
|
|
|
4
4
|
export function getDistanceForDirection(
|
|
5
5
|
layout: Layout,
|
|
6
|
-
gestureDirection: GestureDirection
|
|
6
|
+
gestureDirection: GestureDirection,
|
|
7
|
+
isRTL: boolean
|
|
7
8
|
): number {
|
|
8
|
-
const multiplier = getInvertedMultiplier(gestureDirection);
|
|
9
|
+
const multiplier = getInvertedMultiplier(gestureDirection, isRTL);
|
|
9
10
|
|
|
10
11
|
switch (gestureDirection) {
|
|
11
12
|
case 'vertical':
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { I18nManager } from 'react-native';
|
|
2
|
-
|
|
3
1
|
import type { GestureDirection } from '../types';
|
|
4
2
|
|
|
5
3
|
export function getInvertedMultiplier(
|
|
6
|
-
gestureDirection: GestureDirection
|
|
4
|
+
gestureDirection: GestureDirection,
|
|
5
|
+
isRTL: boolean
|
|
7
6
|
): 1 | -1 {
|
|
8
7
|
switch (gestureDirection) {
|
|
9
8
|
case 'vertical':
|
|
@@ -11,8 +10,8 @@ export function getInvertedMultiplier(
|
|
|
11
10
|
case 'vertical-inverted':
|
|
12
11
|
return -1;
|
|
13
12
|
case 'horizontal':
|
|
14
|
-
return
|
|
13
|
+
return isRTL ? -1 : 1;
|
|
15
14
|
case 'horizontal-inverted':
|
|
16
|
-
return
|
|
15
|
+
return isRTL ? 1 : -1;
|
|
17
16
|
}
|
|
18
17
|
}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
HeaderBackButtonProps,
|
|
6
6
|
HeaderTitle,
|
|
7
7
|
} from '@react-navigation/elements';
|
|
8
|
+
import { useLocale } from '@react-navigation/native';
|
|
8
9
|
import * as React from 'react';
|
|
9
10
|
import {
|
|
10
11
|
Animated,
|
|
@@ -33,6 +34,8 @@ type Props = Omit<StackHeaderOptions, 'headerStatusBarHeight'> & {
|
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
export function HeaderSegment(props: Props) {
|
|
37
|
+
const { direction } = useLocale();
|
|
38
|
+
|
|
36
39
|
const [leftLabelLayout, setLeftLabelLayout] = React.useState<
|
|
37
40
|
Layout | undefined
|
|
38
41
|
>(undefined);
|
|
@@ -84,6 +87,7 @@ export function HeaderSegment(props: Props) {
|
|
|
84
87
|
styleInterpolator({
|
|
85
88
|
current: { progress: current },
|
|
86
89
|
next: next && { progress: next },
|
|
90
|
+
direction,
|
|
87
91
|
layouts: {
|
|
88
92
|
header: {
|
|
89
93
|
height: headerHeight,
|
package/src/views/Stack/Card.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LocaleDirection } from '@react-navigation/native';
|
|
1
2
|
import Color from 'color';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import {
|
|
@@ -40,6 +41,7 @@ type Props = ViewProps & {
|
|
|
40
41
|
gesture: Animated.Value;
|
|
41
42
|
layout: Layout;
|
|
42
43
|
insets: EdgeInsets;
|
|
44
|
+
direction: LocaleDirection;
|
|
43
45
|
headerDarkContent: boolean | undefined;
|
|
44
46
|
pageOverflowEnabled: boolean;
|
|
45
47
|
gestureDirection: GestureDirection;
|
|
@@ -110,7 +112,7 @@ export class Card extends React.Component<Props> {
|
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
componentDidUpdate(prevProps: Props) {
|
|
113
|
-
const { layout, gestureDirection, closing } = this.props;
|
|
115
|
+
const { direction, layout, gestureDirection, closing } = this.props;
|
|
114
116
|
const { width, height } = layout;
|
|
115
117
|
|
|
116
118
|
if (width !== prevProps.layout.width) {
|
|
@@ -122,7 +124,9 @@ export class Card extends React.Component<Props> {
|
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
if (gestureDirection !== prevProps.gestureDirection) {
|
|
125
|
-
this.inverted.setValue(
|
|
127
|
+
this.inverted.setValue(
|
|
128
|
+
getInvertedMultiplier(gestureDirection, direction === 'rtl')
|
|
129
|
+
);
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
const toValue = this.getAnimateToValue(this.props);
|
|
@@ -151,7 +155,10 @@ export class Card extends React.Component<Props> {
|
|
|
151
155
|
private isClosing = new Animated.Value(FALSE);
|
|
152
156
|
|
|
153
157
|
private inverted = new Animated.Value(
|
|
154
|
-
getInvertedMultiplier(
|
|
158
|
+
getInvertedMultiplier(
|
|
159
|
+
this.props.gestureDirection,
|
|
160
|
+
this.props.direction === 'rtl'
|
|
161
|
+
)
|
|
155
162
|
);
|
|
156
163
|
|
|
157
164
|
private layout = {
|
|
@@ -227,16 +234,22 @@ export class Card extends React.Component<Props> {
|
|
|
227
234
|
closing,
|
|
228
235
|
layout,
|
|
229
236
|
gestureDirection,
|
|
237
|
+
direction,
|
|
230
238
|
}: {
|
|
231
239
|
closing?: boolean;
|
|
232
240
|
layout: Layout;
|
|
233
241
|
gestureDirection: GestureDirection;
|
|
242
|
+
direction: LocaleDirection;
|
|
234
243
|
}) => {
|
|
235
244
|
if (!closing) {
|
|
236
245
|
return 0;
|
|
237
246
|
}
|
|
238
247
|
|
|
239
|
-
return getDistanceForDirection(
|
|
248
|
+
return getDistanceForDirection(
|
|
249
|
+
layout,
|
|
250
|
+
gestureDirection,
|
|
251
|
+
direction === 'rtl'
|
|
252
|
+
);
|
|
240
253
|
};
|
|
241
254
|
|
|
242
255
|
private setPointerEventsEnabled = (enabled: boolean) => {
|
|
@@ -262,6 +275,7 @@ export class Card extends React.Component<Props> {
|
|
|
262
275
|
nativeEvent,
|
|
263
276
|
}: PanGestureHandlerGestureEvent) => {
|
|
264
277
|
const {
|
|
278
|
+
direction,
|
|
265
279
|
layout,
|
|
266
280
|
onClose,
|
|
267
281
|
onGestureBegin,
|
|
@@ -314,7 +328,7 @@ export class Card extends React.Component<Props> {
|
|
|
314
328
|
|
|
315
329
|
const closing =
|
|
316
330
|
(translation + velocity * gestureVelocityImpact) *
|
|
317
|
-
getInvertedMultiplier(gestureDirection) >
|
|
331
|
+
getInvertedMultiplier(gestureDirection, direction === 'rtl') >
|
|
318
332
|
distance / 2
|
|
319
333
|
? velocity !== 0 || translation !== 0
|
|
320
334
|
: this.props.closing;
|
|
@@ -378,7 +392,8 @@ export class Card extends React.Component<Props> {
|
|
|
378
392
|
);
|
|
379
393
|
|
|
380
394
|
private gestureActivationCriteria() {
|
|
381
|
-
const { layout, gestureDirection, gestureResponseDistance } =
|
|
395
|
+
const { direction, layout, gestureDirection, gestureResponseDistance } =
|
|
396
|
+
this.props;
|
|
382
397
|
const enableTrackpadTwoFingerGesture = true;
|
|
383
398
|
|
|
384
399
|
const distance =
|
|
@@ -405,7 +420,10 @@ export class Card extends React.Component<Props> {
|
|
|
405
420
|
};
|
|
406
421
|
} else {
|
|
407
422
|
const hitSlop = -layout.width + distance;
|
|
408
|
-
const invertedMultiplier = getInvertedMultiplier(
|
|
423
|
+
const invertedMultiplier = getInvertedMultiplier(
|
|
424
|
+
gestureDirection,
|
|
425
|
+
direction === 'rtl'
|
|
426
|
+
);
|
|
409
427
|
|
|
410
428
|
if (invertedMultiplier === 1) {
|
|
411
429
|
return {
|
|
@@ -446,6 +464,19 @@ export class Card extends React.Component<Props> {
|
|
|
446
464
|
children,
|
|
447
465
|
containerStyle: customContainerStyle,
|
|
448
466
|
contentStyle,
|
|
467
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
468
|
+
closing,
|
|
469
|
+
direction,
|
|
470
|
+
gestureResponseDistance,
|
|
471
|
+
gestureVelocityImpact,
|
|
472
|
+
onClose,
|
|
473
|
+
onGestureBegin,
|
|
474
|
+
onGestureCanceled,
|
|
475
|
+
onGestureEnd,
|
|
476
|
+
onOpen,
|
|
477
|
+
onTransition,
|
|
478
|
+
transitionSpec,
|
|
479
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
449
480
|
...rest
|
|
450
481
|
} = this.props;
|
|
451
482
|
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
HeaderHeightContext,
|
|
5
5
|
HeaderShownContext,
|
|
6
6
|
} from '@react-navigation/elements';
|
|
7
|
-
import { Route, useTheme } from '@react-navigation/native';
|
|
7
|
+
import { Route, useLocale, useTheme } from '@react-navigation/native';
|
|
8
8
|
import * as React from 'react';
|
|
9
9
|
import { Animated, StyleSheet, View } from 'react-native';
|
|
10
10
|
|
|
@@ -89,6 +89,8 @@ function CardContainerInner({
|
|
|
89
89
|
safeAreaInsetTop,
|
|
90
90
|
scene,
|
|
91
91
|
}: Props) {
|
|
92
|
+
const { direction } = useLocale();
|
|
93
|
+
|
|
92
94
|
const parentHeaderHeight = React.useContext(HeaderHeightContext);
|
|
93
95
|
|
|
94
96
|
const { onPageChangeStart, onPageChangeCancel, onPageChangeConfirm } =
|
|
@@ -221,6 +223,7 @@ function CardContainerInner({
|
|
|
221
223
|
gestureDirection={gestureDirection}
|
|
222
224
|
layout={layout}
|
|
223
225
|
insets={insets}
|
|
226
|
+
direction={direction}
|
|
224
227
|
gesture={gesture}
|
|
225
228
|
current={scene.progress.current}
|
|
226
229
|
next={scene.progress.next}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
SafeAreaProviderCompat,
|
|
5
5
|
} from '@react-navigation/elements';
|
|
6
6
|
import type {
|
|
7
|
+
LocaleDirection,
|
|
7
8
|
ParamListBase,
|
|
8
9
|
Route,
|
|
9
10
|
StackNavigationState,
|
|
@@ -47,6 +48,8 @@ type GestureValues = {
|
|
|
47
48
|
};
|
|
48
49
|
|
|
49
50
|
type Props = {
|
|
51
|
+
// eslint-disable-next-line react/no-unused-prop-types
|
|
52
|
+
direction: LocaleDirection;
|
|
50
53
|
insets: EdgeInsets;
|
|
51
54
|
state: StackNavigationState<ParamListBase>;
|
|
52
55
|
descriptors: StackDescriptorMap;
|
|
@@ -162,7 +165,8 @@ const getHeaderHeights = (
|
|
|
162
165
|
|
|
163
166
|
const getDistanceFromOptions = (
|
|
164
167
|
layout: Layout,
|
|
165
|
-
descriptor
|
|
168
|
+
descriptor: StackDescriptor,
|
|
169
|
+
isRTL: boolean
|
|
166
170
|
) => {
|
|
167
171
|
const {
|
|
168
172
|
presentation,
|
|
@@ -171,13 +175,14 @@ const getDistanceFromOptions = (
|
|
|
171
175
|
: DefaultTransition.gestureDirection,
|
|
172
176
|
} = (descriptor?.options || {}) as StackNavigationOptions;
|
|
173
177
|
|
|
174
|
-
return getDistanceForDirection(layout, gestureDirection);
|
|
178
|
+
return getDistanceForDirection(layout, gestureDirection, isRTL);
|
|
175
179
|
};
|
|
176
180
|
|
|
177
181
|
const getProgressFromGesture = (
|
|
178
182
|
gesture: Animated.Value,
|
|
179
183
|
layout: Layout,
|
|
180
|
-
descriptor
|
|
184
|
+
descriptor: StackDescriptor,
|
|
185
|
+
isRTL: boolean
|
|
181
186
|
) => {
|
|
182
187
|
const distance = getDistanceFromOptions(
|
|
183
188
|
{
|
|
@@ -186,7 +191,8 @@ const getProgressFromGesture = (
|
|
|
186
191
|
width: Math.max(1, layout.width),
|
|
187
192
|
height: Math.max(1, layout.height),
|
|
188
193
|
},
|
|
189
|
-
descriptor
|
|
194
|
+
descriptor,
|
|
195
|
+
isRTL
|
|
190
196
|
);
|
|
191
197
|
|
|
192
198
|
if (distance > 0) {
|
|
@@ -223,7 +229,11 @@ export class CardStack extends React.Component<Props, State> {
|
|
|
223
229
|
new Animated.Value(
|
|
224
230
|
props.openingRouteKeys.includes(curr.key) &&
|
|
225
231
|
animationEnabled !== false
|
|
226
|
-
? getDistanceFromOptions(
|
|
232
|
+
? getDistanceFromOptions(
|
|
233
|
+
state.layout,
|
|
234
|
+
descriptor,
|
|
235
|
+
props.direction === 'rtl'
|
|
236
|
+
)
|
|
227
237
|
: 0
|
|
228
238
|
);
|
|
229
239
|
|
|
@@ -304,6 +314,8 @@ export class CardStack extends React.Component<Props, State> {
|
|
|
304
314
|
? 'float'
|
|
305
315
|
: 'screen');
|
|
306
316
|
|
|
317
|
+
const isRTL = props.direction === 'rtl';
|
|
318
|
+
|
|
307
319
|
const scene = {
|
|
308
320
|
route,
|
|
309
321
|
descriptor: {
|
|
@@ -324,7 +336,8 @@ export class CardStack extends React.Component<Props, State> {
|
|
|
324
336
|
current: getProgressFromGesture(
|
|
325
337
|
currentGesture,
|
|
326
338
|
state.layout,
|
|
327
|
-
descriptor
|
|
339
|
+
descriptor,
|
|
340
|
+
isRTL
|
|
328
341
|
),
|
|
329
342
|
next:
|
|
330
343
|
nextGesture &&
|
|
@@ -332,14 +345,16 @@ export class CardStack extends React.Component<Props, State> {
|
|
|
332
345
|
? getProgressFromGesture(
|
|
333
346
|
nextGesture,
|
|
334
347
|
state.layout,
|
|
335
|
-
nextDescriptor
|
|
348
|
+
nextDescriptor,
|
|
349
|
+
isRTL
|
|
336
350
|
)
|
|
337
351
|
: undefined,
|
|
338
352
|
previous: previousGesture
|
|
339
353
|
? getProgressFromGesture(
|
|
340
354
|
previousGesture,
|
|
341
355
|
state.layout,
|
|
342
|
-
previousDescriptor
|
|
356
|
+
previousDescriptor,
|
|
357
|
+
isRTL
|
|
343
358
|
)
|
|
344
359
|
: undefined,
|
|
345
360
|
},
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
} from '@react-navigation/elements';
|
|
5
5
|
import {
|
|
6
6
|
CommonActions,
|
|
7
|
+
LocaleDirection,
|
|
7
8
|
ParamListBase,
|
|
8
9
|
Route,
|
|
9
10
|
StackActions,
|
|
@@ -11,10 +12,7 @@ import {
|
|
|
11
12
|
} from '@react-navigation/native';
|
|
12
13
|
import * as React from 'react';
|
|
13
14
|
import { StyleSheet, View } from 'react-native';
|
|
14
|
-
import {
|
|
15
|
-
EdgeInsets,
|
|
16
|
-
SafeAreaInsetsContext,
|
|
17
|
-
} from 'react-native-safe-area-context';
|
|
15
|
+
import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
|
|
18
16
|
|
|
19
17
|
import type {
|
|
20
18
|
StackDescriptorMap,
|
|
@@ -30,6 +28,7 @@ import {
|
|
|
30
28
|
import { CardStack } from './CardStack';
|
|
31
29
|
|
|
32
30
|
type Props = StackNavigationConfig & {
|
|
31
|
+
direction: LocaleDirection;
|
|
33
32
|
state: StackNavigationState<ParamListBase>;
|
|
34
33
|
navigation: StackNavigationHelpers;
|
|
35
34
|
descriptors: StackDescriptorMap;
|
|
@@ -448,7 +447,7 @@ export class StackView extends React.Component<Props, State> {
|
|
|
448
447
|
<HeaderShownContext.Consumer>
|
|
449
448
|
{(isParentHeaderShown) => (
|
|
450
449
|
<CardStack
|
|
451
|
-
insets={insets
|
|
450
|
+
insets={insets!}
|
|
452
451
|
isParentHeaderShown={isParentHeaderShown}
|
|
453
452
|
isParentModal={isParentModal}
|
|
454
453
|
getPreviousRoute={this.getPreviousRoute}
|