@react-navigation/stack 7.6.12 → 8.0.0-alpha.0
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/module/TransitionConfigs/HeaderStyleInterpolators.js +44 -52
- package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js.map +1 -1
- package/lib/module/TransitionConfigs/TransitionPresets.js +4 -4
- package/lib/module/TransitionConfigs/TransitionPresets.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/navigators/createStackNavigator.js +7 -6
- package/lib/module/navigators/createStackNavigator.js.map +1 -1
- package/lib/module/utils/getShadowStyle.js +3 -5
- package/lib/module/utils/getShadowStyle.js.map +1 -1
- package/lib/module/views/Header/Header.js +0 -2
- package/lib/module/views/Header/Header.js.map +1 -1
- package/lib/module/views/Header/HeaderContainer.js +27 -28
- package/lib/module/views/Header/HeaderContainer.js.map +1 -1
- package/lib/module/views/Header/HeaderSegment.js +14 -51
- package/lib/module/views/Header/HeaderSegment.js.map +1 -1
- package/lib/module/views/Stack/Card.js +12 -30
- package/lib/module/views/Stack/Card.js.map +1 -1
- package/lib/module/views/Stack/CardA11yWrapper.js +1 -1
- package/lib/module/views/Stack/CardA11yWrapper.js.map +1 -1
- package/lib/module/views/Stack/CardContainer.js +0 -1
- package/lib/module/views/Stack/CardContainer.js.map +1 -1
- package/lib/module/views/Stack/CardContent.js +3 -2
- package/lib/module/views/Stack/CardContent.js.map +1 -1
- package/lib/module/views/Stack/CardStack.js +23 -19
- package/lib/module/views/Stack/CardStack.js.map +1 -1
- package/lib/module/views/Stack/StackView.js +2 -1
- package/lib/module/views/Stack/StackView.js.map +1 -1
- package/lib/typescript/src/TransitionConfigs/HeaderStyleInterpolators.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/navigators/createStackNavigator.d.ts +10 -6
- package/lib/typescript/src/navigators/createStackNavigator.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +12 -28
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/getShadowStyle.d.ts +1 -2
- package/lib/typescript/src/utils/getShadowStyle.d.ts.map +1 -1
- package/lib/typescript/src/views/Header/Header.d.ts.map +1 -1
- package/lib/typescript/src/views/Header/HeaderContainer.d.ts +2 -3
- package/lib/typescript/src/views/Header/HeaderContainer.d.ts.map +1 -1
- package/lib/typescript/src/views/Header/HeaderSegment.d.ts +1 -2
- package/lib/typescript/src/views/Header/HeaderSegment.d.ts.map +1 -1
- 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/CardContent.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/CardStack.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/StackView.d.ts +22 -2
- package/lib/typescript/src/views/Stack/StackView.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/TransitionConfigs/HeaderStyleInterpolators.tsx +43 -80
- package/src/TransitionConfigs/TransitionPresets.tsx +4 -4
- package/src/index.tsx +4 -1
- package/src/navigators/createStackNavigator.tsx +42 -25
- package/src/types.tsx +18 -33
- package/src/utils/getShadowStyle.tsx +3 -14
- package/src/views/Header/Header.tsx +0 -2
- package/src/views/Header/HeaderContainer.tsx +36 -37
- package/src/views/Header/HeaderSegment.tsx +27 -92
- package/src/views/Stack/Card.tsx +8 -33
- package/src/views/Stack/CardA11yWrapper.tsx +1 -1
- package/src/views/Stack/CardContainer.tsx +0 -1
- package/src/views/Stack/CardContent.tsx +5 -2
- package/src/views/Stack/CardStack.tsx +24 -21
- package/src/views/Stack/StackView.tsx +2 -4
- package/lib/module/views/Screens.js +0 -42
- package/lib/module/views/Screens.js.map +0 -1
- package/lib/typescript/src/views/Screens.d.ts +0 -15
- package/lib/typescript/src/views/Screens.d.ts.map +0 -1
- package/src/views/Screens.tsx +0 -45
|
@@ -4,18 +4,13 @@ import {
|
|
|
4
4
|
HeaderBackButton,
|
|
5
5
|
type HeaderBackButtonProps,
|
|
6
6
|
HeaderTitle,
|
|
7
|
+
useFrameSize,
|
|
7
8
|
} from '@react-navigation/elements';
|
|
8
9
|
import { useLocale } from '@react-navigation/native';
|
|
9
10
|
import * as React from 'react';
|
|
10
|
-
import {
|
|
11
|
-
type LayoutChangeEvent,
|
|
12
|
-
Platform,
|
|
13
|
-
StyleSheet,
|
|
14
|
-
type ViewStyle,
|
|
15
|
-
} from 'react-native';
|
|
11
|
+
import { StyleSheet, type ViewStyle } from 'react-native';
|
|
16
12
|
|
|
17
13
|
import type {
|
|
18
|
-
Layout,
|
|
19
14
|
SceneProgress,
|
|
20
15
|
StackHeaderOptions,
|
|
21
16
|
StackHeaderStyleInterpolator,
|
|
@@ -23,7 +18,6 @@ import type {
|
|
|
23
18
|
|
|
24
19
|
type Props = Omit<StackHeaderOptions, 'headerStatusBarHeight'> & {
|
|
25
20
|
headerStatusBarHeight: number;
|
|
26
|
-
layout: Layout;
|
|
27
21
|
title: string;
|
|
28
22
|
modal: boolean;
|
|
29
23
|
onGoBack?: () => void;
|
|
@@ -34,48 +28,10 @@ type Props = Omit<StackHeaderOptions, 'headerStatusBarHeight'> & {
|
|
|
34
28
|
|
|
35
29
|
export function HeaderSegment(props: Props) {
|
|
36
30
|
const { direction } = useLocale();
|
|
37
|
-
|
|
38
|
-
const [leftLabelLayout, setLeftLabelLayout] = React.useState<
|
|
39
|
-
Layout | undefined
|
|
40
|
-
>(undefined);
|
|
41
|
-
|
|
42
|
-
const [titleLayout, setTitleLayout] = React.useState<Layout | undefined>(
|
|
43
|
-
undefined
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const handleTitleLayout = (e: LayoutChangeEvent) => {
|
|
47
|
-
const { height, width } = e.nativeEvent.layout;
|
|
48
|
-
|
|
49
|
-
setTitleLayout((titleLayout) => {
|
|
50
|
-
if (
|
|
51
|
-
titleLayout &&
|
|
52
|
-
height === titleLayout.height &&
|
|
53
|
-
width === titleLayout.width
|
|
54
|
-
) {
|
|
55
|
-
return titleLayout;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return { height, width };
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const handleLeftLabelLayout = (e: LayoutChangeEvent) => {
|
|
63
|
-
const { height, width } = e.nativeEvent.layout;
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
leftLabelLayout &&
|
|
67
|
-
height === leftLabelLayout.height &&
|
|
68
|
-
width === leftLabelLayout.width
|
|
69
|
-
) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
setLeftLabelLayout({ height, width });
|
|
74
|
-
};
|
|
31
|
+
const layout = useFrameSize((frame) => frame, true);
|
|
75
32
|
|
|
76
33
|
const {
|
|
77
34
|
progress,
|
|
78
|
-
layout,
|
|
79
35
|
modal,
|
|
80
36
|
onGoBack,
|
|
81
37
|
backHref,
|
|
@@ -86,7 +42,7 @@ export function HeaderSegment(props: Props) {
|
|
|
86
42
|
headerRight: right,
|
|
87
43
|
headerBackImage,
|
|
88
44
|
headerBackTitle,
|
|
89
|
-
headerBackButtonDisplayMode
|
|
45
|
+
headerBackButtonDisplayMode,
|
|
90
46
|
headerBackTruncatedTitle,
|
|
91
47
|
headerBackAccessibilityLabel,
|
|
92
48
|
headerBackTestID,
|
|
@@ -102,11 +58,11 @@ export function HeaderSegment(props: Props) {
|
|
|
102
58
|
...rest
|
|
103
59
|
} = props;
|
|
104
60
|
|
|
105
|
-
const defaultHeight = getDefaultHeaderHeight(
|
|
106
|
-
layout,
|
|
107
|
-
modal,
|
|
108
|
-
headerStatusBarHeight
|
|
109
|
-
);
|
|
61
|
+
const defaultHeight = getDefaultHeaderHeight({
|
|
62
|
+
landscape: layout.width > layout.height,
|
|
63
|
+
modalPresentation: modal,
|
|
64
|
+
topInset: headerStatusBarHeight,
|
|
65
|
+
});
|
|
110
66
|
|
|
111
67
|
const { height = defaultHeight } = StyleSheet.flatten(
|
|
112
68
|
customHeaderStyle || {}
|
|
@@ -114,38 +70,23 @@ export function HeaderSegment(props: Props) {
|
|
|
114
70
|
|
|
115
71
|
const headerHeight = typeof height === 'number' ? height : defaultHeight;
|
|
116
72
|
|
|
117
|
-
const {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
header: {
|
|
131
|
-
height: headerHeight,
|
|
132
|
-
width: layout.width,
|
|
73
|
+
const { titleStyle, leftButtonStyle, rightButtonStyle, backgroundStyle } =
|
|
74
|
+
React.useMemo(
|
|
75
|
+
() =>
|
|
76
|
+
styleInterpolator({
|
|
77
|
+
current: { progress: progress.current },
|
|
78
|
+
next: progress.next && { progress: progress.next },
|
|
79
|
+
direction,
|
|
80
|
+
layouts: {
|
|
81
|
+
header: {
|
|
82
|
+
height: headerHeight,
|
|
83
|
+
width: layout.width,
|
|
84
|
+
},
|
|
85
|
+
screen: layout,
|
|
133
86
|
},
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
},
|
|
138
|
-
}),
|
|
139
|
-
[
|
|
140
|
-
styleInterpolator,
|
|
141
|
-
progress,
|
|
142
|
-
direction,
|
|
143
|
-
headerHeight,
|
|
144
|
-
layout,
|
|
145
|
-
titleLayout,
|
|
146
|
-
leftLabelLayout,
|
|
147
|
-
]
|
|
148
|
-
);
|
|
87
|
+
}),
|
|
88
|
+
[styleInterpolator, progress, direction, headerHeight, layout]
|
|
89
|
+
);
|
|
149
90
|
|
|
150
91
|
const headerLeft: StackHeaderOptions['headerLeft'] = left
|
|
151
92
|
? (props) =>
|
|
@@ -159,10 +100,7 @@ export function HeaderSegment(props: Props) {
|
|
|
159
100
|
onPress: onGoBack,
|
|
160
101
|
label: headerBackTitle,
|
|
161
102
|
truncatedLabel: headerBackTruncatedTitle,
|
|
162
|
-
labelStyle:
|
|
163
|
-
onLabelLayout: handleLeftLabelLayout,
|
|
164
|
-
screenLayout: layout,
|
|
165
|
-
titleLayout,
|
|
103
|
+
labelStyle: headerBackTitleStyle,
|
|
166
104
|
canGoBack: Boolean(onGoBack),
|
|
167
105
|
})
|
|
168
106
|
: undefined;
|
|
@@ -176,14 +114,11 @@ export function HeaderSegment(props: Props) {
|
|
|
176
114
|
: undefined;
|
|
177
115
|
|
|
178
116
|
const headerTitle: StackHeaderOptions['headerTitle'] =
|
|
179
|
-
typeof title !== 'function'
|
|
180
|
-
? (props) => <HeaderTitle {...props} onLayout={handleTitleLayout} />
|
|
181
|
-
: (props) => title({ ...props, onLayout: handleTitleLayout });
|
|
117
|
+
typeof title !== 'function' ? (props) => <HeaderTitle {...props} /> : title;
|
|
182
118
|
|
|
183
119
|
return (
|
|
184
120
|
<Header
|
|
185
121
|
modal={modal}
|
|
186
|
-
layout={layout}
|
|
187
122
|
headerTitle={headerTitle}
|
|
188
123
|
headerLeft={headerLeft}
|
|
189
124
|
headerRight={headerRight}
|
package/src/views/Stack/Card.tsx
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { Color } from '@react-navigation/elements/internal';
|
|
1
2
|
import type { LocaleDirection } from '@react-navigation/native';
|
|
2
|
-
import Color from 'color';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import {
|
|
5
5
|
Animated,
|
|
6
|
-
InteractionManager,
|
|
7
6
|
Platform,
|
|
8
7
|
type StyleProp,
|
|
9
8
|
StyleSheet,
|
|
@@ -118,10 +117,7 @@ const defaultOverlay = ({
|
|
|
118
117
|
style,
|
|
119
118
|
}: {
|
|
120
119
|
style: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
121
|
-
}) =>
|
|
122
|
-
style ? (
|
|
123
|
-
<Animated.View pointerEvents="none" style={[styles.overlay, style]} />
|
|
124
|
-
) : null;
|
|
120
|
+
}) => (style ? <Animated.View style={[styles.overlay, style]} /> : null);
|
|
125
121
|
|
|
126
122
|
function Card({
|
|
127
123
|
shadowEnabled = false,
|
|
@@ -160,7 +156,6 @@ function Card({
|
|
|
160
156
|
const didInitiallyAnimate = React.useRef(false);
|
|
161
157
|
const lastToValueRef = React.useRef<number | undefined>(undefined);
|
|
162
158
|
|
|
163
|
-
const interactionHandleRef = React.useRef<number | undefined>(undefined);
|
|
164
159
|
const animationHandleRef = React.useRef<number | undefined>(undefined);
|
|
165
160
|
const pendingGestureCallbackRef =
|
|
166
161
|
React.useRef<ReturnType<typeof setTimeout>>(undefined);
|
|
@@ -181,20 +176,6 @@ function Card({
|
|
|
181
176
|
|
|
182
177
|
const [isSwiping] = React.useState(() => new Animated.Value(FALSE));
|
|
183
178
|
|
|
184
|
-
const onStartInteraction = useLatestCallback(() => {
|
|
185
|
-
if (interactionHandleRef.current === undefined) {
|
|
186
|
-
interactionHandleRef.current =
|
|
187
|
-
InteractionManager.createInteractionHandle();
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
const onEndInteraction = useLatestCallback(() => {
|
|
192
|
-
if (interactionHandleRef.current !== undefined) {
|
|
193
|
-
InteractionManager.clearInteractionHandle(interactionHandleRef.current);
|
|
194
|
-
interactionHandleRef.current = undefined;
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
|
|
198
179
|
const animate = useLatestCallback(
|
|
199
180
|
({
|
|
200
181
|
closing: isClosingParam,
|
|
@@ -245,7 +226,6 @@ function Card({
|
|
|
245
226
|
};
|
|
246
227
|
|
|
247
228
|
if (animated) {
|
|
248
|
-
onStartInteraction();
|
|
249
229
|
animation(gesture, {
|
|
250
230
|
...spec.config,
|
|
251
231
|
velocity,
|
|
@@ -253,7 +233,6 @@ function Card({
|
|
|
253
233
|
useNativeDriver,
|
|
254
234
|
isInteraction: false,
|
|
255
235
|
}).start(({ finished }) => {
|
|
256
|
-
onEndInteraction();
|
|
257
236
|
clearTimeout(pendingGestureCallbackRef.current);
|
|
258
237
|
|
|
259
238
|
if (finished) {
|
|
@@ -271,13 +250,11 @@ function Card({
|
|
|
271
250
|
switch (nativeEvent.state) {
|
|
272
251
|
case GestureState.ACTIVE:
|
|
273
252
|
isSwiping.setValue(TRUE);
|
|
274
|
-
onStartInteraction();
|
|
275
253
|
onGestureBegin?.();
|
|
276
254
|
break;
|
|
277
255
|
case GestureState.CANCELLED:
|
|
278
256
|
case GestureState.FAILED: {
|
|
279
257
|
isSwiping.setValue(FALSE);
|
|
280
|
-
onEndInteraction();
|
|
281
258
|
|
|
282
259
|
const velocity =
|
|
283
260
|
gestureDirection === 'vertical' ||
|
|
@@ -368,8 +345,6 @@ function Card({
|
|
|
368
345
|
|
|
369
346
|
React.useEffect(() => {
|
|
370
347
|
return () => {
|
|
371
|
-
onEndInteraction();
|
|
372
|
-
|
|
373
348
|
if (animationHandleRef.current) {
|
|
374
349
|
cancelAnimationFrame(animationHandleRef.current);
|
|
375
350
|
}
|
|
@@ -378,7 +353,6 @@ function Card({
|
|
|
378
353
|
};
|
|
379
354
|
|
|
380
355
|
// We only want to clean up the animation on unmount
|
|
381
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
382
356
|
}, []);
|
|
383
357
|
|
|
384
358
|
const timeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
@@ -518,7 +492,8 @@ function Card({
|
|
|
518
492
|
|
|
519
493
|
const isTransparent =
|
|
520
494
|
typeof backgroundColor === 'string'
|
|
521
|
-
?
|
|
495
|
+
? backgroundColor === 'transparent' ||
|
|
496
|
+
Color(backgroundColor)?.alpha() === 0
|
|
522
497
|
: false;
|
|
523
498
|
|
|
524
499
|
return (
|
|
@@ -537,12 +512,11 @@ function Card({
|
|
|
537
512
|
/>
|
|
538
513
|
) : null}
|
|
539
514
|
{overlayEnabled ? (
|
|
540
|
-
<View
|
|
515
|
+
<View style={[StyleSheet.absoluteFill, { pointerEvents: 'box-none' }]}>
|
|
541
516
|
{overlay({ style: overlayStyle })}
|
|
542
517
|
</View>
|
|
543
518
|
) : null}
|
|
544
519
|
<Animated.View
|
|
545
|
-
pointerEvents="box-none"
|
|
546
520
|
style={[styles.container, containerStyle, customContainerStyle]}
|
|
547
521
|
>
|
|
548
522
|
<PanGestureHandler
|
|
@@ -557,13 +531,11 @@ function Card({
|
|
|
557
531
|
})}
|
|
558
532
|
>
|
|
559
533
|
<Animated.View
|
|
560
|
-
pointerEvents="box-none"
|
|
561
534
|
needsOffscreenAlphaCompositing={hasOpacityStyle(cardStyle)}
|
|
562
535
|
style={[styles.container, cardStyle]}
|
|
563
536
|
>
|
|
564
537
|
{shadowEnabled && shadowStyle && !isTransparent ? (
|
|
565
538
|
<Animated.View
|
|
566
|
-
pointerEvents="none"
|
|
567
539
|
style={[
|
|
568
540
|
styles.shadow,
|
|
569
541
|
gestureDirection === 'horizontal'
|
|
@@ -597,13 +569,16 @@ export { Card };
|
|
|
597
569
|
const styles = StyleSheet.create({
|
|
598
570
|
container: {
|
|
599
571
|
flex: 1,
|
|
572
|
+
pointerEvents: 'box-none',
|
|
600
573
|
},
|
|
601
574
|
overlay: {
|
|
602
575
|
flex: 1,
|
|
603
576
|
backgroundColor: '#000',
|
|
577
|
+
pointerEvents: 'none',
|
|
604
578
|
},
|
|
605
579
|
shadow: {
|
|
606
580
|
position: 'absolute',
|
|
581
|
+
pointerEvents: 'none',
|
|
607
582
|
},
|
|
608
583
|
shadowHorizontal: {
|
|
609
584
|
top: 0,
|
|
@@ -39,10 +39,10 @@ export const CardA11yWrapper = React.forwardRef(
|
|
|
39
39
|
return (
|
|
40
40
|
<View
|
|
41
41
|
aria-hidden={!focused}
|
|
42
|
-
pointerEvents={(animated ? inert : !focused) ? 'none' : 'box-none'}
|
|
43
42
|
style={[
|
|
44
43
|
StyleSheet.absoluteFill,
|
|
45
44
|
{
|
|
45
|
+
pointerEvents: (animated ? inert : !focused) ? 'none' : 'box-none',
|
|
46
46
|
// This is necessary to avoid unfocused larger pages increasing scroll area
|
|
47
47
|
// The issue can be seen on the web when a smaller screen is pushed over a larger one
|
|
48
48
|
overflow: active ? undefined : 'hidden',
|
|
@@ -75,8 +75,11 @@ export function CardContent({ enabled, layout, style, ...rest }: Props) {
|
|
|
75
75
|
return (
|
|
76
76
|
<View
|
|
77
77
|
{...rest}
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
style={[
|
|
79
|
+
{ pointerEvents: 'box-none' },
|
|
80
|
+
enabled && fill ? styles.page : styles.card,
|
|
81
|
+
style,
|
|
82
|
+
]}
|
|
80
83
|
/>
|
|
81
84
|
);
|
|
82
85
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
SafeAreaProviderCompat,
|
|
4
|
-
} from '@react-navigation/elements';
|
|
1
|
+
import { getDefaultHeaderHeight } from '@react-navigation/elements';
|
|
2
|
+
import { SafeAreaProviderCompat } from '@react-navigation/elements/internal';
|
|
5
3
|
import type {
|
|
6
4
|
LocaleDirection,
|
|
7
5
|
ParamListBase,
|
|
@@ -17,6 +15,7 @@ import {
|
|
|
17
15
|
View,
|
|
18
16
|
} from 'react-native';
|
|
19
17
|
import type { EdgeInsets } from 'react-native-safe-area-context';
|
|
18
|
+
import { Screen, ScreenContainer } from 'react-native-screens';
|
|
20
19
|
|
|
21
20
|
import {
|
|
22
21
|
forModalPresentationIOS,
|
|
@@ -49,7 +48,6 @@ import { findLastIndex } from '../../utils/findLastIndex';
|
|
|
49
48
|
import { getDistanceForDirection } from '../../utils/getDistanceForDirection';
|
|
50
49
|
import { getModalRouteKeys } from '../../utils/getModalRoutesKeys';
|
|
51
50
|
import type { Props as HeaderContainerProps } from '../Header/HeaderContainer';
|
|
52
|
-
import { MaybeScreen, MaybeScreenContainer } from '../Screens';
|
|
53
51
|
import { CardContainer } from './CardContainer';
|
|
54
52
|
|
|
55
53
|
type GestureValues = {
|
|
@@ -191,7 +189,11 @@ const getHeaderHeights = (
|
|
|
191
189
|
acc[curr.route.key] =
|
|
192
190
|
typeof height === 'number'
|
|
193
191
|
? height
|
|
194
|
-
: getDefaultHeaderHeight(
|
|
192
|
+
: getDefaultHeaderHeight({
|
|
193
|
+
landscape: layout.width > layout.height,
|
|
194
|
+
modalPresentation: isModal,
|
|
195
|
+
topInset: headerStatusBarHeight,
|
|
196
|
+
});
|
|
195
197
|
|
|
196
198
|
return acc;
|
|
197
199
|
}, {});
|
|
@@ -678,9 +680,8 @@ export class CardStack extends React.Component<Props, State> {
|
|
|
678
680
|
this.state;
|
|
679
681
|
|
|
680
682
|
const focusedRoute = state.routes[state.index];
|
|
681
|
-
const focusedHeaderHeight = headerHeights[focusedRoute.key];
|
|
682
683
|
|
|
683
|
-
const isFloatHeaderAbsolute =
|
|
684
|
+
const isFloatHeaderAbsolute = scenes.slice(-2).some((scene) => {
|
|
684
685
|
const options = scene.descriptor.options ?? {};
|
|
685
686
|
const { headerMode, headerTransparent, headerShown = true } = options;
|
|
686
687
|
|
|
@@ -695,25 +696,30 @@ export class CardStack extends React.Component<Props, State> {
|
|
|
695
696
|
return false;
|
|
696
697
|
});
|
|
697
698
|
|
|
699
|
+
const isFloatHeaderFocused =
|
|
700
|
+
scenes.findLast((scene) => scene.route.key === focusedRoute.key)
|
|
701
|
+
?.descriptor.options.headerMode === 'float';
|
|
702
|
+
|
|
698
703
|
return (
|
|
699
704
|
<View style={styles.container}>
|
|
700
705
|
{renderHeader({
|
|
701
706
|
mode: 'float',
|
|
702
|
-
layout,
|
|
703
707
|
scenes,
|
|
704
708
|
getPreviousScene: this.getPreviousScene,
|
|
705
709
|
getFocusedRoute: this.getFocusedRoute,
|
|
706
710
|
onContentHeightChange: this.handleHeaderLayout,
|
|
707
711
|
style: [
|
|
708
|
-
styles.floating,
|
|
709
712
|
isFloatHeaderAbsolute && [
|
|
710
|
-
// Without this, the header buttons won't be touchable on Android when headerTransparent: true
|
|
711
|
-
{ height: focusedHeaderHeight },
|
|
712
713
|
styles.absolute,
|
|
714
|
+
// The header title can't be found with maestro without this
|
|
715
|
+
// In some cases, header buttons may not be touchable as well
|
|
716
|
+
isFloatHeaderFocused && {
|
|
717
|
+
height: headerHeights[focusedRoute.key],
|
|
718
|
+
},
|
|
713
719
|
],
|
|
714
720
|
],
|
|
715
721
|
})}
|
|
716
|
-
<
|
|
722
|
+
<ScreenContainer
|
|
717
723
|
enabled={detachInactiveScreens}
|
|
718
724
|
style={styles.container}
|
|
719
725
|
onLayout={this.handleLayout}
|
|
@@ -772,15 +778,14 @@ export class CardStack extends React.Component<Props, State> {
|
|
|
772
778
|
: activeStates[index];
|
|
773
779
|
|
|
774
780
|
return (
|
|
775
|
-
<
|
|
781
|
+
<Screen
|
|
776
782
|
key={route.key}
|
|
777
|
-
style={[StyleSheet.absoluteFill]}
|
|
783
|
+
style={[StyleSheet.absoluteFill, { pointerEvents: 'box-none' }]}
|
|
778
784
|
enabled={detachInactiveScreens}
|
|
779
|
-
|
|
785
|
+
activityState={activityState}
|
|
780
786
|
freezeOnBlur={freezeOnBlur}
|
|
781
787
|
shouldFreeze={activityState === STATE_INACTIVE && !isPreloaded}
|
|
782
788
|
homeIndicatorHidden={autoHideHomeIndicator}
|
|
783
|
-
pointerEvents="box-none"
|
|
784
789
|
>
|
|
785
790
|
<CardContainer
|
|
786
791
|
index={index}
|
|
@@ -817,10 +822,10 @@ export class CardStack extends React.Component<Props, State> {
|
|
|
817
822
|
detachCurrentScreen={detachCurrentScreen}
|
|
818
823
|
preloaded={isPreloaded}
|
|
819
824
|
/>
|
|
820
|
-
</
|
|
825
|
+
</Screen>
|
|
821
826
|
);
|
|
822
827
|
})}
|
|
823
|
-
</
|
|
828
|
+
</ScreenContainer>
|
|
824
829
|
</View>
|
|
825
830
|
);
|
|
826
831
|
}
|
|
@@ -835,8 +840,6 @@ const styles = StyleSheet.create({
|
|
|
835
840
|
top: 0,
|
|
836
841
|
start: 0,
|
|
837
842
|
end: 0,
|
|
838
|
-
},
|
|
839
|
-
floating: {
|
|
840
843
|
zIndex: 1,
|
|
841
844
|
},
|
|
842
845
|
});
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
SafeAreaProviderCompat,
|
|
4
|
-
} from '@react-navigation/elements';
|
|
1
|
+
import { HeaderShownContext } from '@react-navigation/elements';
|
|
2
|
+
import { SafeAreaProviderCompat } from '@react-navigation/elements/internal';
|
|
5
3
|
import {
|
|
6
4
|
CommonActions,
|
|
7
5
|
type LocaleDirection,
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { View } from 'react-native';
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
let Screens;
|
|
7
|
-
try {
|
|
8
|
-
Screens = require('react-native-screens');
|
|
9
|
-
} catch (e) {
|
|
10
|
-
// Ignore
|
|
11
|
-
}
|
|
12
|
-
export const MaybeScreenContainer = ({
|
|
13
|
-
enabled,
|
|
14
|
-
...rest
|
|
15
|
-
}) => {
|
|
16
|
-
if (Screens != null) {
|
|
17
|
-
return /*#__PURE__*/_jsx(Screens.ScreenContainer, {
|
|
18
|
-
enabled: enabled,
|
|
19
|
-
...rest
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return /*#__PURE__*/_jsx(View, {
|
|
23
|
-
...rest
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
export const MaybeScreen = ({
|
|
27
|
-
enabled,
|
|
28
|
-
active,
|
|
29
|
-
...rest
|
|
30
|
-
}) => {
|
|
31
|
-
if (Screens != null) {
|
|
32
|
-
return /*#__PURE__*/_jsx(Screens.Screen, {
|
|
33
|
-
enabled: enabled,
|
|
34
|
-
activityState: active,
|
|
35
|
-
...rest
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return /*#__PURE__*/_jsx(View, {
|
|
39
|
-
...rest
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=Screens.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","View","jsx","_jsx","Screens","require","e","MaybeScreenContainer","enabled","rest","ScreenContainer","MaybeScreen","active","Screen","activityState"],"sourceRoot":"../../../src","sources":["views/Screens.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAAmBC,IAAI,QAAwB,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE9D,IAAIC,OAA0D;AAE9D,IAAI;EACFA,OAAO,GAAGC,OAAO,CAAC,sBAAsB,CAAC;AAC3C,CAAC,CAAC,OAAOC,CAAC,EAAE;EACV;AAAA;AAGF,OAAO,MAAMC,oBAAoB,GAAGA,CAAC;EACnCC,OAAO;EACP,GAAGC;AAIL,CAAC,KAAK;EACJ,IAAIL,OAAO,IAAI,IAAI,EAAE;IACnB,oBAAOD,IAAA,CAACC,OAAO,CAACM,eAAe;MAACF,OAAO,EAAEA,OAAQ;MAAA,GAAKC;IAAI,CAAG,CAAC;EAChE;EAEA,oBAAON,IAAA,CAACF,IAAI;IAAA,GAAKQ;EAAI,CAAG,CAAC;AAC3B,CAAC;AAED,OAAO,MAAME,WAAW,GAAGA,CAAC;EAC1BH,OAAO;EACPI,MAAM;EACN,GAAGH;AAQL,CAAC,KAAK;EACJ,IAAIL,OAAO,IAAI,IAAI,EAAE;IACnB,oBACED,IAAA,CAACC,OAAO,CAACS,MAAM;MAACL,OAAO,EAAEA,OAAQ;MAACM,aAAa,EAAEF,MAAO;MAAA,GAAKH;IAAI,CAAG,CAAC;EAEzE;EAEA,oBAAON,IAAA,CAACF,IAAI;IAAA,GAAKQ;EAAI,CAAG,CAAC;AAC3B,CAAC","ignoreList":[]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Animated, type ViewProps } from 'react-native';
|
|
3
|
-
export declare const MaybeScreenContainer: ({ enabled, ...rest }: ViewProps & {
|
|
4
|
-
enabled: boolean;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export declare const MaybeScreen: ({ enabled, active, ...rest }: ViewProps & {
|
|
8
|
-
enabled: boolean;
|
|
9
|
-
active: 0 | 1 | Animated.AnimatedInterpolation<0 | 1>;
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
freezeOnBlur?: boolean;
|
|
12
|
-
shouldFreeze: boolean;
|
|
13
|
-
homeIndicatorHidden?: boolean;
|
|
14
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
//# sourceMappingURL=Screens.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Screens.d.ts","sourceRoot":"","sources":["../../../../src/views/Screens.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAQ,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAU9D,eAAO,MAAM,oBAAoB,GAAI,sBAGlC,SAAS,GAAG;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,4CAMA,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,8BAIzB,SAAS,GAAG;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,qBAAqB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,4CAQA,CAAC"}
|
package/src/views/Screens.tsx
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Animated, View, type ViewProps } from 'react-native';
|
|
3
|
-
|
|
4
|
-
let Screens: typeof import('react-native-screens') | undefined;
|
|
5
|
-
|
|
6
|
-
try {
|
|
7
|
-
Screens = require('react-native-screens');
|
|
8
|
-
} catch (e) {
|
|
9
|
-
// Ignore
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const MaybeScreenContainer = ({
|
|
13
|
-
enabled,
|
|
14
|
-
...rest
|
|
15
|
-
}: ViewProps & {
|
|
16
|
-
enabled: boolean;
|
|
17
|
-
children: React.ReactNode;
|
|
18
|
-
}) => {
|
|
19
|
-
if (Screens != null) {
|
|
20
|
-
return <Screens.ScreenContainer enabled={enabled} {...rest} />;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return <View {...rest} />;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const MaybeScreen = ({
|
|
27
|
-
enabled,
|
|
28
|
-
active,
|
|
29
|
-
...rest
|
|
30
|
-
}: ViewProps & {
|
|
31
|
-
enabled: boolean;
|
|
32
|
-
active: 0 | 1 | Animated.AnimatedInterpolation<0 | 1>;
|
|
33
|
-
children: React.ReactNode;
|
|
34
|
-
freezeOnBlur?: boolean;
|
|
35
|
-
shouldFreeze: boolean;
|
|
36
|
-
homeIndicatorHidden?: boolean;
|
|
37
|
-
}) => {
|
|
38
|
-
if (Screens != null) {
|
|
39
|
-
return (
|
|
40
|
-
<Screens.Screen enabled={enabled} activityState={active} {...rest} />
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return <View {...rest} />;
|
|
45
|
-
};
|