@react-navigation/native-stack 7.20.0 → 7.21.1
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/README.md +1 -1
- package/lib/module/utils/useAnimatedHeaderHeight.js.map +1 -1
- package/lib/module/views/NativeStackView.js +100 -77
- package/lib/module/views/NativeStackView.js.map +1 -1
- package/lib/module/views/NativeStackView.native.js +101 -95
- package/lib/module/views/NativeStackView.native.js.map +1 -1
- package/lib/module/views/useHeaderConfigProps.js +26 -15
- package/lib/module/views/useHeaderConfigProps.js.map +1 -1
- package/lib/typescript/src/types.d.ts +40 -5
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/useAnimatedHeaderHeight.d.ts.map +1 -1
- package/lib/typescript/src/views/NativeStackView.d.ts.map +1 -1
- package/lib/typescript/src/views/NativeStackView.native.d.ts.map +1 -1
- package/lib/typescript/src/views/useHeaderConfigProps.d.ts +1 -1
- package/lib/typescript/src/views/useHeaderConfigProps.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/types.tsx +44 -7
- package/src/utils/useAnimatedHeaderHeight.tsx +5 -3
- package/src/views/NativeStackView.native.tsx +114 -108
- package/src/views/NativeStackView.tsx +149 -113
- package/src/views/useHeaderConfigProps.tsx +41 -28
- package/lib/module/views/FontProcessor.js +0 -6
- package/lib/module/views/FontProcessor.js.map +0 -1
- package/lib/module/views/FontProcessor.native.js +0 -12
- package/lib/module/views/FontProcessor.native.js.map +0 -1
- package/lib/typescript/src/views/FontProcessor.d.ts +0 -2
- package/lib/typescript/src/views/FontProcessor.d.ts.map +0 -1
- package/lib/typescript/src/views/FontProcessor.native.d.ts +0 -2
- package/lib/typescript/src/views/FontProcessor.native.d.ts.map +0 -1
- package/src/views/FontProcessor.native.tsx +0 -12
- package/src/views/FontProcessor.tsx +0 -5
|
@@ -10,6 +10,7 @@ import { Platform, StyleSheet, type TextStyle, View } from 'react-native';
|
|
|
10
10
|
import {
|
|
11
11
|
type HeaderBarButtonItemMenuAction,
|
|
12
12
|
type HeaderBarButtonItemSubmenu,
|
|
13
|
+
type HeaderBarButtonItemVisibilityPriority,
|
|
13
14
|
type HeaderBarButtonItemWithAction,
|
|
14
15
|
type HeaderBarButtonItemWithMenu,
|
|
15
16
|
isSearchBarAvailableForCurrentPlatform,
|
|
@@ -29,7 +30,6 @@ import type {
|
|
|
29
30
|
NativeStackHeaderItemMenuSubmenu,
|
|
30
31
|
NativeStackNavigationOptions,
|
|
31
32
|
} from '../types';
|
|
32
|
-
import { processFonts } from './FontProcessor';
|
|
33
33
|
|
|
34
34
|
type Props = NativeStackNavigationOptions & {
|
|
35
35
|
headerTopInsetEnabled: boolean;
|
|
@@ -71,7 +71,13 @@ const processBarButtonItems = (
|
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
const { badge, label, labelStyle, icon, ...rest } =
|
|
74
|
+
const { badge, label, labelStyle, icon, visibilityPriority, ...rest } =
|
|
75
|
+
item;
|
|
76
|
+
|
|
77
|
+
const processedVisibilityPriority:
|
|
78
|
+
| HeaderBarButtonItemVisibilityPriority
|
|
79
|
+
| undefined =
|
|
80
|
+
visibilityPriority === 'default' ? 'standard' : visibilityPriority;
|
|
75
81
|
|
|
76
82
|
const processedItemCommon = {
|
|
77
83
|
...rest,
|
|
@@ -82,6 +88,7 @@ const processBarButtonItems = (
|
|
|
82
88
|
...labelStyle,
|
|
83
89
|
},
|
|
84
90
|
icon: transformIcon(icon),
|
|
91
|
+
visibilityPriority: processedVisibilityPriority,
|
|
85
92
|
};
|
|
86
93
|
|
|
87
94
|
let processedItem:
|
|
@@ -164,13 +171,22 @@ const getMenuItem = (
|
|
|
164
171
|
item: NativeStackHeaderItemMenuAction | NativeStackHeaderItemMenuSubmenu
|
|
165
172
|
): HeaderBarButtonItemMenuAction | HeaderBarButtonItemSubmenu => {
|
|
166
173
|
if (item.type === 'submenu') {
|
|
167
|
-
const {
|
|
168
|
-
|
|
174
|
+
const {
|
|
175
|
+
label,
|
|
176
|
+
description,
|
|
177
|
+
icon,
|
|
178
|
+
inline,
|
|
179
|
+
layout,
|
|
180
|
+
items,
|
|
181
|
+
multiselectable,
|
|
182
|
+
...rest
|
|
183
|
+
} = item;
|
|
169
184
|
|
|
170
185
|
return {
|
|
171
186
|
...rest,
|
|
172
187
|
icon: transformIcon(icon),
|
|
173
188
|
title: label,
|
|
189
|
+
subtitle: description,
|
|
174
190
|
displayAsPalette: layout === 'palette',
|
|
175
191
|
displayInline: inline,
|
|
176
192
|
singleSelection:
|
|
@@ -190,6 +206,7 @@ const getMenuItem = (
|
|
|
190
206
|
};
|
|
191
207
|
|
|
192
208
|
export function useHeaderConfigProps({
|
|
209
|
+
header,
|
|
193
210
|
headerBackIcon,
|
|
194
211
|
headerBackImageSource,
|
|
195
212
|
headerBackButtonDisplayMode,
|
|
@@ -205,7 +222,9 @@ export function useHeaderConfigProps({
|
|
|
205
222
|
headerLargeTitleStyle,
|
|
206
223
|
headerBackground,
|
|
207
224
|
headerLeft,
|
|
225
|
+
headerLeftBackgroundVisible,
|
|
208
226
|
headerRight,
|
|
227
|
+
headerRightBackgroundVisible,
|
|
209
228
|
headerShown,
|
|
210
229
|
headerStyle,
|
|
211
230
|
headerBlurEffect,
|
|
@@ -253,17 +272,11 @@ export function useHeaderConfigProps({
|
|
|
253
272
|
? 'transparent'
|
|
254
273
|
: colors.card);
|
|
255
274
|
|
|
256
|
-
const [backTitleFontFamily, largeTitleFontFamily, titleFontFamily] =
|
|
257
|
-
processFonts([
|
|
258
|
-
headerBackTitleStyleFlattened.fontFamily,
|
|
259
|
-
headerLargeTitleStyleFlattened.fontFamily,
|
|
260
|
-
headerTitleStyleFlattened.fontFamily,
|
|
261
|
-
]);
|
|
262
|
-
|
|
263
275
|
const backTitleFontSize =
|
|
264
276
|
'fontSize' in headerBackTitleStyleFlattened
|
|
265
277
|
? headerBackTitleStyleFlattened.fontSize
|
|
266
278
|
: undefined;
|
|
279
|
+
const backTitleFontFamily = headerBackTitleStyleFlattened.fontFamily;
|
|
267
280
|
|
|
268
281
|
const titleText = getHeaderTitle({ title, headerTitle }, route.name);
|
|
269
282
|
const titleColor =
|
|
@@ -281,6 +294,7 @@ export function useHeaderConfigProps({
|
|
|
281
294
|
? headerTitleStyleFlattened.fontSize
|
|
282
295
|
: undefined;
|
|
283
296
|
const titleFontWeight = headerTitleStyleFlattened.fontWeight;
|
|
297
|
+
const titleFontFamily = headerTitleStyleFlattened.fontFamily;
|
|
284
298
|
|
|
285
299
|
const largeTitleBackgroundColor = headerLargeStyleFlattened.backgroundColor;
|
|
286
300
|
const largeTitleColor =
|
|
@@ -292,20 +306,14 @@ export function useHeaderConfigProps({
|
|
|
292
306
|
? headerLargeTitleStyleFlattened.fontSize
|
|
293
307
|
: undefined;
|
|
294
308
|
const largeTitleFontWeight = headerLargeTitleStyleFlattened.fontWeight;
|
|
309
|
+
const largeTitleFontFamily = headerLargeTitleStyleFlattened.fontFamily;
|
|
295
310
|
|
|
296
|
-
const headerTitleStyleSupported: TextStyle = {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if (titleFontSize != null) {
|
|
303
|
-
headerTitleStyleSupported.fontSize = titleFontSize;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if (titleFontWeight != null) {
|
|
307
|
-
headerTitleStyleSupported.fontWeight = titleFontWeight;
|
|
308
|
-
}
|
|
311
|
+
const headerTitleStyleSupported: TextStyle = {
|
|
312
|
+
color: titleColor,
|
|
313
|
+
...(titleFontFamily != null ? { fontFamily: titleFontFamily } : null),
|
|
314
|
+
...(titleFontSize != null ? { fontSize: titleFontSize } : null),
|
|
315
|
+
...(titleFontWeight != null ? { fontWeight: titleFontWeight } : null),
|
|
316
|
+
};
|
|
309
317
|
|
|
310
318
|
const canGoBack = headerBack != null;
|
|
311
319
|
|
|
@@ -407,7 +415,9 @@ export function useHeaderConfigProps({
|
|
|
407
415
|
return null;
|
|
408
416
|
})
|
|
409
417
|
) : headerLeftElement != null ? (
|
|
410
|
-
<ScreenStackHeaderLeftView
|
|
418
|
+
<ScreenStackHeaderLeftView
|
|
419
|
+
hidesSharedBackground={headerLeftBackgroundVisible === false}
|
|
420
|
+
>
|
|
411
421
|
{headerLeftElement}
|
|
412
422
|
</ScreenStackHeaderLeftView>
|
|
413
423
|
) : null}
|
|
@@ -481,7 +491,9 @@ export function useHeaderConfigProps({
|
|
|
481
491
|
return null;
|
|
482
492
|
})
|
|
483
493
|
) : headerRightElement != null ? (
|
|
484
|
-
<ScreenStackHeaderRightView
|
|
494
|
+
<ScreenStackHeaderRightView
|
|
495
|
+
hidesSharedBackground={headerRightBackgroundVisible === false}
|
|
496
|
+
>
|
|
485
497
|
{headerRightElement}
|
|
486
498
|
</ScreenStackHeaderRightView>
|
|
487
499
|
) : null}
|
|
@@ -520,7 +532,8 @@ export function useHeaderConfigProps({
|
|
|
520
532
|
largeTitleColor,
|
|
521
533
|
largeTitleFontFamily,
|
|
522
534
|
largeTitleFontSize,
|
|
523
|
-
largeTitleFontWeight
|
|
535
|
+
largeTitleFontWeight:
|
|
536
|
+
largeTitleFontWeight != null ? String(largeTitleFontWeight) : undefined,
|
|
524
537
|
largeTitleHideShadow: headerLargeTitleShadowVisible === false,
|
|
525
538
|
title: titleText,
|
|
526
539
|
titleColor,
|
|
@@ -539,7 +552,7 @@ export function useHeaderConfigProps({
|
|
|
539
552
|
disableBottomInsetApplication:
|
|
540
553
|
headerInsets?.bottom !== undefined ? !headerInsets.bottom : undefined,
|
|
541
554
|
translucent: translucent === true,
|
|
542
|
-
children,
|
|
555
|
+
children: header === undefined ? children : null,
|
|
543
556
|
headerLeftBarButtonItems: processBarButtonItems(leftItems, colors, fonts),
|
|
544
557
|
headerRightBarButtonItems: processBarButtonItems(rightItems, colors, fonts),
|
|
545
558
|
experimental_userInterfaceStyle: dark ? 'dark' : 'light',
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["processFonts","_","Error"],"sourceRoot":"../../../src","sources":["views/FontProcessor.tsx"],"mappings":";;AAAA,OAAO,SAASA,YAAYA,CAC1BC,CAAyB,EACD;EACxB,MAAM,IAAIC,KAAK,CAAC,sBAAsB,CAAC;AACzC","ignoreList":[]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// @ts-expect-error importing private module
|
|
4
|
-
import ReactNativeStyleAttributes from 'react-native/Libraries/Components/View/ReactNativeStyleAttributes';
|
|
5
|
-
export function processFonts(fontFamilies) {
|
|
6
|
-
const fontFamilyProcessor = ReactNativeStyleAttributes.fontFamily?.process;
|
|
7
|
-
if (typeof fontFamilyProcessor === 'function') {
|
|
8
|
-
return fontFamilies.map(fontFamilyProcessor);
|
|
9
|
-
}
|
|
10
|
-
return fontFamilies;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=FontProcessor.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["ReactNativeStyleAttributes","processFonts","fontFamilies","fontFamilyProcessor","fontFamily","process","map"],"sourceRoot":"../../../src","sources":["views/FontProcessor.native.tsx"],"mappings":";;AAAA;AACA,OAAOA,0BAA0B,MAAM,mEAAmE;AAE1G,OAAO,SAASC,YAAYA,CAC1BC,YAAoC,EACZ;EACxB,MAAMC,mBAAmB,GAAGH,0BAA0B,CAACI,UAAU,EAAEC,OAAO;EAC1E,IAAI,OAAOF,mBAAmB,KAAK,UAAU,EAAE;IAC7C,OAAOD,YAAY,CAACI,GAAG,CAACH,mBAAmB,CAAC;EAC9C;EACA,OAAOD,YAAY;AACrB","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FontProcessor.d.ts","sourceRoot":"","sources":["../../../../src/views/FontProcessor.tsx"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAC1B,CAAC,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GACxB,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAExB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FontProcessor.native.d.ts","sourceRoot":"","sources":["../../../../src/views/FontProcessor.native.tsx"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,CAC1B,YAAY,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GACnC,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAMxB"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// @ts-expect-error importing private module
|
|
2
|
-
import ReactNativeStyleAttributes from 'react-native/Libraries/Components/View/ReactNativeStyleAttributes';
|
|
3
|
-
|
|
4
|
-
export function processFonts(
|
|
5
|
-
fontFamilies: (string | undefined)[]
|
|
6
|
-
): (string | undefined)[] {
|
|
7
|
-
const fontFamilyProcessor = ReactNativeStyleAttributes.fontFamily?.process;
|
|
8
|
-
if (typeof fontFamilyProcessor === 'function') {
|
|
9
|
-
return fontFamilies.map(fontFamilyProcessor);
|
|
10
|
-
}
|
|
11
|
-
return fontFamilies;
|
|
12
|
-
}
|