@react-navigation/native-stack 7.0.0-alpha.0 → 7.0.0-alpha.10
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/index.js +11 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/navigators/createNativeStackNavigator.js +27 -28
- package/lib/commonjs/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/useAnimatedHeaderHeight.js +19 -0
- package/lib/commonjs/utils/useAnimatedHeaderHeight.js.map +1 -0
- package/lib/commonjs/utils/useDismissedRouteError.js +5 -6
- package/lib/commonjs/utils/useDismissedRouteError.js.map +1 -1
- package/lib/commonjs/utils/useInvalidPreventRemoveError.js +5 -6
- package/lib/commonjs/utils/useInvalidPreventRemoveError.js.map +1 -1
- package/lib/commonjs/views/DebugContainer.js +4 -4
- package/lib/commonjs/views/DebugContainer.js.map +1 -1
- package/lib/commonjs/views/DebugContainer.native.js +22 -12
- package/lib/commonjs/views/DebugContainer.native.js.map +1 -1
- package/lib/commonjs/views/FontProcessor.js.map +1 -1
- package/lib/commonjs/views/FontProcessor.native.js +2 -4
- package/lib/commonjs/views/FontProcessor.native.js.map +1 -1
- package/lib/commonjs/views/HeaderConfig.js +36 -36
- package/lib/commonjs/views/HeaderConfig.js.map +1 -1
- package/lib/commonjs/views/NativeStackView.js +24 -12
- package/lib/commonjs/views/NativeStackView.js.map +1 -1
- package/lib/commonjs/views/NativeStackView.native.js +128 -50
- package/lib/commonjs/views/NativeStackView.native.js.map +1 -1
- package/lib/module/index.js +7 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/navigators/createNativeStackNavigator.js +23 -22
- package/lib/module/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/useAnimatedHeaderHeight.js +10 -0
- package/lib/module/utils/useAnimatedHeaderHeight.js.map +1 -0
- package/lib/module/utils/useDismissedRouteError.js +2 -3
- package/lib/module/utils/useDismissedRouteError.js.map +1 -1
- package/lib/module/utils/useInvalidPreventRemoveError.js +3 -4
- package/lib/module/utils/useInvalidPreventRemoveError.js.map +1 -1
- package/lib/module/views/DebugContainer.js +1 -1
- package/lib/module/views/DebugContainer.js.map +1 -1
- package/lib/module/views/DebugContainer.native.js +19 -7
- package/lib/module/views/DebugContainer.native.js.map +1 -1
- package/lib/module/views/FontProcessor.js.map +1 -1
- package/lib/module/views/FontProcessor.native.js +2 -4
- package/lib/module/views/FontProcessor.native.js.map +1 -1
- package/lib/module/views/HeaderConfig.js +36 -36
- package/lib/module/views/HeaderConfig.js.map +1 -1
- package/lib/module/views/NativeStackView.js +22 -10
- package/lib/module/views/NativeStackView.js.map +1 -1
- package/lib/module/views/NativeStackView.native.js +124 -46
- package/lib/module/views/NativeStackView.native.js.map +1 -1
- package/lib/typescript/src/index.d.ts +6 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/navigators/createNativeStackNavigator.d.ts +6 -6
- package/lib/typescript/src/navigators/createNativeStackNavigator.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +88 -10
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/useAnimatedHeaderHeight.d.ts +5 -0
- package/lib/typescript/src/utils/useAnimatedHeaderHeight.d.ts.map +1 -0
- package/lib/typescript/src/utils/useDismissedRouteError.d.ts +1 -1
- package/lib/typescript/src/utils/useDismissedRouteError.d.ts.map +1 -1
- package/lib/typescript/src/utils/useInvalidPreventRemoveError.d.ts +1 -1
- package/lib/typescript/src/utils/useInvalidPreventRemoveError.d.ts.map +1 -1
- package/lib/typescript/src/views/DebugContainer.d.ts +2 -2
- package/lib/typescript/src/views/DebugContainer.d.ts.map +1 -1
- package/lib/typescript/src/views/DebugContainer.native.d.ts +8 -3
- package/lib/typescript/src/views/DebugContainer.native.d.ts.map +1 -1
- package/lib/typescript/src/views/FontProcessor.native.d.ts.map +1 -1
- package/lib/typescript/src/views/HeaderConfig.d.ts +2 -3
- package/lib/typescript/src/views/HeaderConfig.d.ts.map +1 -1
- package/lib/typescript/src/views/NativeStackView.d.ts +3 -3
- package/lib/typescript/src/views/NativeStackView.d.ts.map +1 -1
- package/lib/typescript/src/views/NativeStackView.native.d.ts +3 -3
- package/lib/typescript/src/views/NativeStackView.native.d.ts.map +1 -1
- package/package.json +16 -17
- package/src/index.tsx +7 -2
- package/src/navigators/createNativeStackNavigator.tsx +11 -7
- package/src/types.tsx +88 -11
- package/src/utils/useAnimatedHeaderHeight.tsx +18 -0
- package/src/utils/useDismissedRouteError.tsx +1 -1
- package/src/utils/useInvalidPreventRemoveError.tsx +1 -1
- package/src/views/DebugContainer.native.tsx +13 -10
- package/src/views/DebugContainer.tsx +2 -2
- package/src/views/FontProcessor.native.tsx +1 -2
- package/src/views/HeaderConfig.tsx +142 -143
- package/src/views/NativeStackView.native.tsx +203 -97
- package/src/views/NativeStackView.tsx +41 -27
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { getHeaderTitle, HeaderTitle } from '@react-navigation/elements';
|
|
2
|
-
import { Route, useTheme } from '@react-navigation/native';
|
|
2
|
+
import { type Route, useLocale, useTheme } from '@react-navigation/native';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
I18nManager,
|
|
6
|
-
Platform,
|
|
7
|
-
StyleSheet,
|
|
8
|
-
TextStyle,
|
|
9
|
-
View,
|
|
10
|
-
} from 'react-native';
|
|
4
|
+
import { Platform, StyleSheet, type TextStyle, View } from 'react-native';
|
|
11
5
|
import {
|
|
12
6
|
isSearchBarAvailableForCurrentPlatform,
|
|
13
7
|
ScreenStackHeaderBackButtonImage,
|
|
@@ -29,8 +23,7 @@ type Props = NativeStackNavigationOptions & {
|
|
|
29
23
|
canGoBack: boolean;
|
|
30
24
|
};
|
|
31
25
|
|
|
32
|
-
export
|
|
33
|
-
headerHeight,
|
|
26
|
+
export function HeaderConfig({
|
|
34
27
|
headerBackImageSource,
|
|
35
28
|
headerBackButtonMenuEnabled,
|
|
36
29
|
headerBackTitle,
|
|
@@ -59,15 +52,23 @@ export default function HeaderConfig({
|
|
|
59
52
|
title,
|
|
60
53
|
canGoBack,
|
|
61
54
|
}: Props): JSX.Element {
|
|
62
|
-
const {
|
|
55
|
+
const { direction } = useLocale();
|
|
56
|
+
const { colors, fonts } = useTheme();
|
|
63
57
|
const tintColor =
|
|
64
58
|
headerTintColor ?? (Platform.OS === 'ios' ? colors.primary : colors.text);
|
|
65
59
|
|
|
66
60
|
const headerBackTitleStyleFlattened =
|
|
67
|
-
StyleSheet.flatten(headerBackTitleStyle) || {};
|
|
61
|
+
StyleSheet.flatten([headerBackTitleStyle, fonts.regular]) || {};
|
|
68
62
|
const headerLargeTitleStyleFlattened =
|
|
69
|
-
StyleSheet.flatten(
|
|
70
|
-
|
|
63
|
+
StyleSheet.flatten([
|
|
64
|
+
headerLargeTitleStyle,
|
|
65
|
+
Platform.select({ ios: fonts.heavy, default: fonts.medium }),
|
|
66
|
+
]) || {};
|
|
67
|
+
const headerTitleStyleFlattened =
|
|
68
|
+
StyleSheet.flatten([
|
|
69
|
+
headerTitleStyle,
|
|
70
|
+
Platform.select({ ios: fonts.bold, default: fonts.medium }),
|
|
71
|
+
]) || {};
|
|
71
72
|
const headerStyleFlattened = StyleSheet.flatten(headerStyle) || {};
|
|
72
73
|
const headerLargeStyleFlattened = StyleSheet.flatten(headerLargeStyle) || {};
|
|
73
74
|
|
|
@@ -78,12 +79,33 @@ export default function HeaderConfig({
|
|
|
78
79
|
headerTitleStyleFlattened.fontFamily,
|
|
79
80
|
]);
|
|
80
81
|
|
|
82
|
+
const backTitleFontSize =
|
|
83
|
+
'fontSize' in headerBackTitleStyleFlattened
|
|
84
|
+
? headerBackTitleStyleFlattened.fontSize
|
|
85
|
+
: undefined;
|
|
86
|
+
|
|
81
87
|
const titleText = getHeaderTitle({ title, headerTitle }, route.name);
|
|
82
88
|
const titleColor =
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
'color' in headerTitleStyleFlattened
|
|
90
|
+
? headerTitleStyleFlattened.color
|
|
91
|
+
: headerTintColor ?? colors.text;
|
|
92
|
+
const titleFontSize =
|
|
93
|
+
'fontSize' in headerTitleStyleFlattened
|
|
94
|
+
? headerTitleStyleFlattened.fontSize
|
|
95
|
+
: undefined;
|
|
85
96
|
const titleFontWeight = headerTitleStyleFlattened.fontWeight;
|
|
86
97
|
|
|
98
|
+
const largeTitleBackgroundColor = headerLargeStyleFlattened.backgroundColor;
|
|
99
|
+
const largeTitleColor =
|
|
100
|
+
'color' in headerLargeTitleStyleFlattened
|
|
101
|
+
? headerLargeTitleStyleFlattened.color
|
|
102
|
+
: undefined;
|
|
103
|
+
const largeTitleFontSize =
|
|
104
|
+
'fontSize' in headerLargeTitleStyleFlattened
|
|
105
|
+
? headerLargeTitleStyleFlattened.fontSize
|
|
106
|
+
: undefined;
|
|
107
|
+
const largeTitleFontWeight = headerLargeTitleStyleFlattened.fontWeight;
|
|
108
|
+
|
|
87
109
|
const headerTitleStyleSupported: TextStyle = { color: titleColor };
|
|
88
110
|
|
|
89
111
|
if (headerTitleStyleFlattened.fontFamily != null) {
|
|
@@ -98,6 +120,12 @@ export default function HeaderConfig({
|
|
|
98
120
|
headerTitleStyleSupported.fontWeight = titleFontWeight;
|
|
99
121
|
}
|
|
100
122
|
|
|
123
|
+
const headerBackgroundColor =
|
|
124
|
+
headerStyleFlattened.backgroundColor ??
|
|
125
|
+
(headerBackground != null || headerTransparent
|
|
126
|
+
? 'transparent'
|
|
127
|
+
: colors.card);
|
|
128
|
+
|
|
101
129
|
const headerLeftElement = headerLeft?.({
|
|
102
130
|
tintColor,
|
|
103
131
|
canGoBack,
|
|
@@ -148,123 +176,105 @@ export default function HeaderConfig({
|
|
|
148
176
|
headerTransparent !== false);
|
|
149
177
|
|
|
150
178
|
return (
|
|
151
|
-
|
|
152
|
-
{
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
<>
|
|
205
|
-
{headerLeftElement != null ? (
|
|
206
|
-
<ScreenStackHeaderLeftView>
|
|
179
|
+
<ScreenStackHeaderConfig
|
|
180
|
+
backButtonInCustomView={backButtonInCustomView}
|
|
181
|
+
backgroundColor={headerBackgroundColor}
|
|
182
|
+
backTitle={headerBackTitleVisible ? headerBackTitle : ' '}
|
|
183
|
+
backTitleFontFamily={backTitleFontFamily}
|
|
184
|
+
backTitleFontSize={backTitleFontSize}
|
|
185
|
+
blurEffect={headerBlurEffect}
|
|
186
|
+
color={tintColor}
|
|
187
|
+
direction={direction}
|
|
188
|
+
disableBackButtonMenu={headerBackButtonMenuEnabled === false}
|
|
189
|
+
hidden={headerShown === false}
|
|
190
|
+
hideBackButton={headerBackVisible === false}
|
|
191
|
+
hideShadow={
|
|
192
|
+
headerShadowVisible === false ||
|
|
193
|
+
headerBackground != null ||
|
|
194
|
+
(headerTransparent && headerShadowVisible !== true)
|
|
195
|
+
}
|
|
196
|
+
largeTitle={headerLargeTitle}
|
|
197
|
+
largeTitleBackgroundColor={largeTitleBackgroundColor}
|
|
198
|
+
largeTitleColor={largeTitleColor}
|
|
199
|
+
largeTitleFontFamily={largeTitleFontFamily}
|
|
200
|
+
largeTitleFontSize={largeTitleFontSize}
|
|
201
|
+
largeTitleFontWeight={largeTitleFontWeight}
|
|
202
|
+
largeTitleHideShadow={headerLargeTitleShadowVisible === false}
|
|
203
|
+
title={titleText}
|
|
204
|
+
titleColor={titleColor}
|
|
205
|
+
titleFontFamily={titleFontFamily}
|
|
206
|
+
titleFontSize={titleFontSize}
|
|
207
|
+
titleFontWeight={titleFontWeight}
|
|
208
|
+
topInsetEnabled={headerTopInsetEnabled}
|
|
209
|
+
translucent={
|
|
210
|
+
// This defaults to `true`, so we can't pass `undefined`
|
|
211
|
+
translucent === true
|
|
212
|
+
}
|
|
213
|
+
>
|
|
214
|
+
{Platform.OS === 'ios' ? (
|
|
215
|
+
<>
|
|
216
|
+
{headerLeftElement != null ? (
|
|
217
|
+
<ScreenStackHeaderLeftView>
|
|
218
|
+
{headerLeftElement}
|
|
219
|
+
</ScreenStackHeaderLeftView>
|
|
220
|
+
) : null}
|
|
221
|
+
{headerTitleElement != null ? (
|
|
222
|
+
<ScreenStackHeaderCenterView>
|
|
223
|
+
{headerTitleElement}
|
|
224
|
+
</ScreenStackHeaderCenterView>
|
|
225
|
+
) : null}
|
|
226
|
+
</>
|
|
227
|
+
) : (
|
|
228
|
+
<>
|
|
229
|
+
{headerLeftElement != null || typeof headerTitle === 'function' ? (
|
|
230
|
+
<ScreenStackHeaderLeftView>
|
|
231
|
+
<View style={styles.row}>
|
|
207
232
|
{headerLeftElement}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
{headerBackImageSource !== undefined ? (
|
|
254
|
-
<ScreenStackHeaderBackButtonImage source={headerBackImageSource} />
|
|
255
|
-
) : null}
|
|
256
|
-
{headerRightElement != null ? (
|
|
257
|
-
<ScreenStackHeaderRightView>
|
|
258
|
-
{headerRightElement}
|
|
259
|
-
</ScreenStackHeaderRightView>
|
|
260
|
-
) : null}
|
|
261
|
-
{hasHeaderSearchBar ? (
|
|
262
|
-
<ScreenStackHeaderSearchBarView>
|
|
263
|
-
<SearchBar {...headerSearchBarOptions} />
|
|
264
|
-
</ScreenStackHeaderSearchBarView>
|
|
265
|
-
) : null}
|
|
266
|
-
</ScreenStackHeaderConfig>
|
|
267
|
-
</>
|
|
233
|
+
{headerTitleAlign !== 'center' ? (
|
|
234
|
+
typeof headerTitle === 'function' ? (
|
|
235
|
+
headerTitleElement
|
|
236
|
+
) : (
|
|
237
|
+
<HeaderTitle
|
|
238
|
+
tintColor={tintColor}
|
|
239
|
+
style={headerTitleStyleSupported}
|
|
240
|
+
>
|
|
241
|
+
{titleText}
|
|
242
|
+
</HeaderTitle>
|
|
243
|
+
)
|
|
244
|
+
) : null}
|
|
245
|
+
</View>
|
|
246
|
+
</ScreenStackHeaderLeftView>
|
|
247
|
+
) : null}
|
|
248
|
+
{headerTitleAlign === 'center' ? (
|
|
249
|
+
<ScreenStackHeaderCenterView>
|
|
250
|
+
{typeof headerTitle === 'function' ? (
|
|
251
|
+
headerTitleElement
|
|
252
|
+
) : (
|
|
253
|
+
<HeaderTitle
|
|
254
|
+
tintColor={tintColor}
|
|
255
|
+
style={headerTitleStyleSupported}
|
|
256
|
+
>
|
|
257
|
+
{titleText}
|
|
258
|
+
</HeaderTitle>
|
|
259
|
+
)}
|
|
260
|
+
</ScreenStackHeaderCenterView>
|
|
261
|
+
) : null}
|
|
262
|
+
</>
|
|
263
|
+
)}
|
|
264
|
+
{headerBackImageSource !== undefined ? (
|
|
265
|
+
<ScreenStackHeaderBackButtonImage source={headerBackImageSource} />
|
|
266
|
+
) : null}
|
|
267
|
+
{headerRightElement != null ? (
|
|
268
|
+
<ScreenStackHeaderRightView>
|
|
269
|
+
{headerRightElement}
|
|
270
|
+
</ScreenStackHeaderRightView>
|
|
271
|
+
) : null}
|
|
272
|
+
{hasHeaderSearchBar ? (
|
|
273
|
+
<ScreenStackHeaderSearchBarView>
|
|
274
|
+
<SearchBar {...headerSearchBarOptions} />
|
|
275
|
+
</ScreenStackHeaderSearchBarView>
|
|
276
|
+
) : null}
|
|
277
|
+
</ScreenStackHeaderConfig>
|
|
268
278
|
);
|
|
269
279
|
}
|
|
270
280
|
|
|
@@ -273,15 +283,4 @@ const styles = StyleSheet.create({
|
|
|
273
283
|
flexDirection: 'row',
|
|
274
284
|
alignItems: 'center',
|
|
275
285
|
},
|
|
276
|
-
translucent: {
|
|
277
|
-
position: 'absolute',
|
|
278
|
-
top: 0,
|
|
279
|
-
left: 0,
|
|
280
|
-
right: 0,
|
|
281
|
-
zIndex: 1,
|
|
282
|
-
elevation: 1,
|
|
283
|
-
},
|
|
284
|
-
background: {
|
|
285
|
-
overflow: 'hidden',
|
|
286
|
-
},
|
|
287
286
|
});
|