@react-navigation/native-stack 7.0.0-rc.26 → 7.0.0-rc.28
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/navigators/createNativeStackNavigator.js +3 -1
- package/lib/commonjs/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/commonjs/views/DebugContainer.native.js +8 -10
- package/lib/commonjs/views/DebugContainer.native.js.map +1 -1
- package/lib/commonjs/views/FooterComponent.js +19 -0
- package/lib/commonjs/views/FooterComponent.js.map +1 -0
- package/lib/commonjs/views/HeaderConfig.js +24 -14
- package/lib/commonjs/views/HeaderConfig.js.map +1 -1
- package/lib/commonjs/views/NativeStackView.js +10 -7
- package/lib/commonjs/views/NativeStackView.js.map +1 -1
- package/lib/commonjs/views/NativeStackView.native.js +56 -18
- package/lib/commonjs/views/NativeStackView.native.js.map +1 -1
- package/lib/module/navigators/createNativeStackNavigator.js +3 -1
- package/lib/module/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/module/views/DebugContainer.native.js +9 -11
- package/lib/module/views/DebugContainer.native.js.map +1 -1
- package/lib/module/views/FooterComponent.js +14 -0
- package/lib/module/views/FooterComponent.js.map +1 -0
- package/lib/module/views/HeaderConfig.js +24 -14
- package/lib/module/views/HeaderConfig.js.map +1 -1
- package/lib/module/views/NativeStackView.js +10 -7
- package/lib/module/views/NativeStackView.js.map +1 -1
- package/lib/module/views/NativeStackView.native.js +56 -18
- package/lib/module/views/NativeStackView.native.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/navigators/createNativeStackNavigator.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +80 -18
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/views/DebugContainer.d.ts +1 -1
- package/lib/typescript/commonjs/src/views/DebugContainer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/views/DebugContainer.native.d.ts +1 -1
- package/lib/typescript/commonjs/src/views/DebugContainer.native.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/views/FooterComponent.d.ts +7 -0
- package/lib/typescript/commonjs/src/views/FooterComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/views/HeaderConfig.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/views/NativeStackView.d.ts +4 -3
- package/lib/typescript/commonjs/src/views/NativeStackView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/views/NativeStackView.native.d.ts +4 -3
- package/lib/typescript/commonjs/src/views/NativeStackView.native.d.ts.map +1 -1
- package/lib/typescript/commonjs/tsconfig.build.tsbuildinfo +1 -1
- package/lib/typescript/module/src/index.d.ts +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/navigators/createNativeStackNavigator.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +80 -18
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/views/DebugContainer.d.ts +1 -1
- package/lib/typescript/module/src/views/DebugContainer.d.ts.map +1 -1
- package/lib/typescript/module/src/views/DebugContainer.native.d.ts +1 -1
- package/lib/typescript/module/src/views/DebugContainer.native.d.ts.map +1 -1
- package/lib/typescript/module/src/views/FooterComponent.d.ts +7 -0
- package/lib/typescript/module/src/views/FooterComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/views/HeaderConfig.d.ts.map +1 -1
- package/lib/typescript/module/src/views/NativeStackView.d.ts +4 -3
- package/lib/typescript/module/src/views/NativeStackView.d.ts.map +1 -1
- package/lib/typescript/module/src/views/NativeStackView.native.d.ts +4 -3
- package/lib/typescript/module/src/views/NativeStackView.native.d.ts.map +1 -1
- package/lib/typescript/module/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/index.tsx +2 -0
- package/src/navigators/createNativeStackNavigator.tsx +2 -1
- package/src/types.tsx +74 -18
- package/src/views/DebugContainer.native.tsx +13 -6
- package/src/views/DebugContainer.tsx +1 -1
- package/src/views/FooterComponent.tsx +10 -0
- package/src/views/HeaderConfig.tsx +23 -21
- package/src/views/NativeStackView.native.tsx +81 -14
- package/src/views/NativeStackView.tsx +23 -11
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from '@react-navigation/elements';
|
|
10
10
|
import {
|
|
11
11
|
type ParamListBase,
|
|
12
|
+
type RouteProp,
|
|
12
13
|
type StackNavigationState,
|
|
13
14
|
useLinkBuilder,
|
|
14
15
|
useTheme,
|
|
@@ -17,6 +18,7 @@ import * as React from 'react';
|
|
|
17
18
|
import { Animated, Image, StyleSheet, View } from 'react-native';
|
|
18
19
|
|
|
19
20
|
import type {
|
|
21
|
+
NativeStackDescriptor,
|
|
20
22
|
NativeStackDescriptorMap,
|
|
21
23
|
NativeStackNavigationHelpers,
|
|
22
24
|
} from '../types';
|
|
@@ -27,6 +29,10 @@ type Props = {
|
|
|
27
29
|
// This is used for the native implementation of the stack.
|
|
28
30
|
navigation: NativeStackNavigationHelpers;
|
|
29
31
|
descriptors: NativeStackDescriptorMap;
|
|
32
|
+
describe: (
|
|
33
|
+
route: RouteProp<ParamListBase>,
|
|
34
|
+
placeholder: boolean
|
|
35
|
+
) => NativeStackDescriptor;
|
|
30
36
|
};
|
|
31
37
|
|
|
32
38
|
const TRANSPARENT_PRESENTATIONS = [
|
|
@@ -34,20 +40,20 @@ const TRANSPARENT_PRESENTATIONS = [
|
|
|
34
40
|
'containedTransparentModal',
|
|
35
41
|
];
|
|
36
42
|
|
|
37
|
-
export function NativeStackView({ state, descriptors }: Props) {
|
|
43
|
+
export function NativeStackView({ state, descriptors, describe }: Props) {
|
|
38
44
|
const parentHeaderBack = React.useContext(HeaderBackContext);
|
|
39
45
|
const { buildHref } = useLinkBuilder();
|
|
40
46
|
const { colors } = useTheme();
|
|
41
47
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
const preloadedDescriptors =
|
|
49
|
+
state.preloadedRoutes.reduce<NativeStackDescriptorMap>((acc, route) => {
|
|
50
|
+
acc[route.key] = acc[route.key] || describe(route, true);
|
|
51
|
+
return acc;
|
|
52
|
+
}, {});
|
|
47
53
|
|
|
48
54
|
return (
|
|
49
55
|
<SafeAreaProviderCompat style={{ backgroundColor: colors.background }}>
|
|
50
|
-
{state.routes.map((route, i) => {
|
|
56
|
+
{state.routes.concat(state.preloadedRoutes).map((route, i) => {
|
|
51
57
|
const isFocused = state.index === i;
|
|
52
58
|
const previousKey = state.routes[i - 1]?.key;
|
|
53
59
|
const nextKey = state.routes[i + 1]?.key;
|
|
@@ -55,7 +61,8 @@ export function NativeStackView({ state, descriptors }: Props) {
|
|
|
55
61
|
? descriptors[previousKey]
|
|
56
62
|
: undefined;
|
|
57
63
|
const nextDescriptor = nextKey ? descriptors[nextKey] : undefined;
|
|
58
|
-
const { options, navigation, render } =
|
|
64
|
+
const { options, navigation, render } =
|
|
65
|
+
descriptors[route.key] ?? preloadedDescriptors[route.key];
|
|
59
66
|
|
|
60
67
|
const headerBack = previousDescriptor
|
|
61
68
|
? {
|
|
@@ -86,6 +93,10 @@ export function NativeStackView({ state, descriptors }: Props) {
|
|
|
86
93
|
|
|
87
94
|
const nextPresentation = nextDescriptor?.options.presentation;
|
|
88
95
|
|
|
96
|
+
const isPreloaded =
|
|
97
|
+
preloadedDescriptors[route.key] !== undefined &&
|
|
98
|
+
descriptors[route.key] === undefined;
|
|
99
|
+
|
|
89
100
|
return (
|
|
90
101
|
<Screen
|
|
91
102
|
key={route.key}
|
|
@@ -146,9 +157,10 @@ export function NativeStackView({ state, descriptors }: Props) {
|
|
|
146
157
|
StyleSheet.absoluteFill,
|
|
147
158
|
{
|
|
148
159
|
display:
|
|
149
|
-
isFocused ||
|
|
150
|
-
|
|
151
|
-
|
|
160
|
+
(isFocused ||
|
|
161
|
+
(nextPresentation != null &&
|
|
162
|
+
TRANSPARENT_PRESENTATIONS.includes(nextPresentation))) &&
|
|
163
|
+
!isPreloaded
|
|
152
164
|
? 'flex'
|
|
153
165
|
: 'none',
|
|
154
166
|
},
|