@react-navigation/native-stack 7.8.6 → 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/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/navigators/createNativeStackNavigator.js +7 -6
- package/lib/module/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/module/views/NativeStackView.js +4 -4
- package/lib/module/views/NativeStackView.js.map +1 -1
- package/lib/module/views/NativeStackView.native.js +159 -200
- package/lib/module/views/NativeStackView.native.js.map +1 -1
- package/lib/module/views/useHeaderConfigProps.js +44 -24
- package/lib/module/views/useHeaderConfigProps.js.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/createNativeStackNavigator.d.ts +10 -6
- package/lib/typescript/src/navigators/createNativeStackNavigator.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +72 -67
- package/lib/typescript/src/types.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 -17
- package/src/index.tsx +4 -1
- package/src/navigators/createNativeStackNavigator.tsx +48 -25
- package/src/types.tsx +72 -72
- package/src/views/NativeStackView.native.tsx +191 -253
- package/src/views/NativeStackView.tsx +6 -9
- package/src/views/useHeaderConfigProps.tsx +32 -30
- 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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getHeaderTitle, HeaderTitle } from '@react-navigation/elements';
|
|
2
|
+
import { Color } from '@react-navigation/elements/internal';
|
|
2
3
|
import {
|
|
3
4
|
type Route,
|
|
4
5
|
type Theme,
|
|
5
6
|
useLocale,
|
|
6
7
|
useTheme,
|
|
7
8
|
} from '@react-navigation/native';
|
|
8
|
-
import color from 'color';
|
|
9
9
|
import { Platform, StyleSheet, type TextStyle, View } from 'react-native';
|
|
10
10
|
import {
|
|
11
11
|
type HeaderBarButtonItem,
|
|
@@ -27,7 +27,6 @@ import type {
|
|
|
27
27
|
NativeStackHeaderItemMenuSubmenu,
|
|
28
28
|
NativeStackNavigationOptions,
|
|
29
29
|
} from '../types';
|
|
30
|
-
import { processFonts } from './FontProcessor';
|
|
31
30
|
|
|
32
31
|
type Props = NativeStackNavigationOptions & {
|
|
33
32
|
headerTopInsetEnabled: boolean;
|
|
@@ -94,10 +93,14 @@ const processBarButtonItems = (
|
|
|
94
93
|
};
|
|
95
94
|
|
|
96
95
|
if (processedItem.type === 'menu' && item.type === 'menu') {
|
|
96
|
+
const { multiselectable, layout } = item.menu;
|
|
97
|
+
|
|
97
98
|
processedItem = {
|
|
98
99
|
...processedItem,
|
|
99
100
|
menu: {
|
|
100
101
|
...processedItem.menu,
|
|
102
|
+
singleSelection: !multiselectable,
|
|
103
|
+
displayAsPalette: layout === 'palette',
|
|
101
104
|
items: item.menu.items.map(getMenuItem),
|
|
102
105
|
},
|
|
103
106
|
};
|
|
@@ -106,7 +109,7 @@ const processBarButtonItems = (
|
|
|
106
109
|
if (badge) {
|
|
107
110
|
const badgeBackgroundColor =
|
|
108
111
|
badge.style?.backgroundColor ?? colors.notification;
|
|
109
|
-
const badgeTextColor =
|
|
112
|
+
const badgeTextColor = Color(badgeBackgroundColor)?.isLight()
|
|
110
113
|
? 'black'
|
|
111
114
|
: 'white';
|
|
112
115
|
|
|
@@ -138,25 +141,30 @@ const processBarButtonItems = (
|
|
|
138
141
|
const getMenuItem = (
|
|
139
142
|
item: NativeStackHeaderItemMenuAction | NativeStackHeaderItemMenuSubmenu
|
|
140
143
|
): HeaderBarButtonItemMenuAction | HeaderBarButtonItemSubmenu => {
|
|
141
|
-
|
|
144
|
+
if (item.type === 'submenu') {
|
|
145
|
+
const { label, inline, layout, items, multiselectable, ...rest } = item;
|
|
142
146
|
|
|
143
|
-
if (rest.type === 'submenu') {
|
|
144
147
|
return {
|
|
145
148
|
...rest,
|
|
146
149
|
title: label,
|
|
147
|
-
|
|
150
|
+
displayAsPalette: layout === 'palette',
|
|
151
|
+
displayInline: inline,
|
|
152
|
+
singleSelection: !multiselectable,
|
|
153
|
+
items: items.map(getMenuItem),
|
|
148
154
|
};
|
|
149
155
|
}
|
|
150
156
|
|
|
157
|
+
const { label, description, ...rest } = item;
|
|
158
|
+
|
|
151
159
|
return {
|
|
152
160
|
...rest,
|
|
153
161
|
title: label,
|
|
162
|
+
subtitle: description,
|
|
154
163
|
};
|
|
155
164
|
};
|
|
156
165
|
|
|
157
166
|
export function useHeaderConfigProps({
|
|
158
167
|
headerBackIcon,
|
|
159
|
-
headerBackImageSource,
|
|
160
168
|
headerBackButtonDisplayMode,
|
|
161
169
|
headerBackButtonMenuEnabled,
|
|
162
170
|
headerBackTitle,
|
|
@@ -164,8 +172,7 @@ export function useHeaderConfigProps({
|
|
|
164
172
|
headerBackVisible,
|
|
165
173
|
headerShadowVisible,
|
|
166
174
|
headerLargeStyle,
|
|
167
|
-
|
|
168
|
-
headerLargeTitleEnabled = headerLargeTitleDeprecated,
|
|
175
|
+
headerLargeTitleEnabled,
|
|
169
176
|
headerLargeTitleShadowVisible,
|
|
170
177
|
headerLargeTitleStyle,
|
|
171
178
|
headerBackground,
|
|
@@ -188,7 +195,7 @@ export function useHeaderConfigProps({
|
|
|
188
195
|
unstable_headerRightItems: headerRightItems,
|
|
189
196
|
}: Props): ScreenStackHeaderConfigProps {
|
|
190
197
|
const { direction } = useLocale();
|
|
191
|
-
const { colors, fonts } = useTheme();
|
|
198
|
+
const { colors, fonts, dark } = useTheme();
|
|
192
199
|
const tintColor =
|
|
193
200
|
headerTintColor ?? (Platform.OS === 'ios' ? colors.primary : colors.text);
|
|
194
201
|
|
|
@@ -207,17 +214,11 @@ export function useHeaderConfigProps({
|
|
|
207
214
|
const headerStyleFlattened = StyleSheet.flatten(headerStyle) || {};
|
|
208
215
|
const headerLargeStyleFlattened = StyleSheet.flatten(headerLargeStyle) || {};
|
|
209
216
|
|
|
210
|
-
const [backTitleFontFamily, largeTitleFontFamily, titleFontFamily] =
|
|
211
|
-
processFonts([
|
|
212
|
-
headerBackTitleStyleFlattened.fontFamily,
|
|
213
|
-
headerLargeTitleStyleFlattened.fontFamily,
|
|
214
|
-
headerTitleStyleFlattened.fontFamily,
|
|
215
|
-
]);
|
|
216
|
-
|
|
217
217
|
const backTitleFontSize =
|
|
218
218
|
'fontSize' in headerBackTitleStyleFlattened
|
|
219
219
|
? headerBackTitleStyleFlattened.fontSize
|
|
220
220
|
: undefined;
|
|
221
|
+
const backTitleFontFamily = headerBackTitleStyleFlattened.fontFamily;
|
|
221
222
|
|
|
222
223
|
const titleText = getHeaderTitle({ title, headerTitle }, route.name);
|
|
223
224
|
const titleColor =
|
|
@@ -229,6 +230,7 @@ export function useHeaderConfigProps({
|
|
|
229
230
|
? headerTitleStyleFlattened.fontSize
|
|
230
231
|
: undefined;
|
|
231
232
|
const titleFontWeight = headerTitleStyleFlattened.fontWeight;
|
|
233
|
+
const titleFontFamily = headerTitleStyleFlattened.fontFamily;
|
|
232
234
|
|
|
233
235
|
const largeTitleBackgroundColor = headerLargeStyleFlattened.backgroundColor;
|
|
234
236
|
const largeTitleColor =
|
|
@@ -240,6 +242,7 @@ export function useHeaderConfigProps({
|
|
|
240
242
|
? headerLargeTitleStyleFlattened.fontSize
|
|
241
243
|
: undefined;
|
|
242
244
|
const largeTitleFontWeight = headerLargeTitleStyleFlattened.fontWeight;
|
|
245
|
+
const largeTitleFontFamily = headerLargeTitleStyleFlattened.fontFamily;
|
|
243
246
|
|
|
244
247
|
const headerTitleStyleSupported: TextStyle = { color: titleColor };
|
|
245
248
|
|
|
@@ -257,7 +260,10 @@ export function useHeaderConfigProps({
|
|
|
257
260
|
|
|
258
261
|
const headerBackgroundColor =
|
|
259
262
|
headerStyleFlattened.backgroundColor ??
|
|
260
|
-
(headerBackground != null ||
|
|
263
|
+
(headerBackground != null ||
|
|
264
|
+
headerTransparent ||
|
|
265
|
+
// The title becomes invisible if background color is set with large title on iOS 26
|
|
266
|
+
(Platform.OS === 'ios' && headerLargeTitleEnabled)
|
|
261
267
|
? 'transparent'
|
|
262
268
|
: colors.card);
|
|
263
269
|
|
|
@@ -284,14 +290,8 @@ export function useHeaderConfigProps({
|
|
|
284
290
|
})
|
|
285
291
|
: null;
|
|
286
292
|
|
|
287
|
-
const supportsHeaderSearchBar =
|
|
288
|
-
typeof isSearchBarAvailableForCurrentPlatform === 'boolean'
|
|
289
|
-
? isSearchBarAvailableForCurrentPlatform
|
|
290
|
-
: // Fallback for older versions of react-native-screens
|
|
291
|
-
Platform.OS === 'ios' && SearchBar != null;
|
|
292
|
-
|
|
293
293
|
const hasHeaderSearchBar =
|
|
294
|
-
|
|
294
|
+
isSearchBarAvailableForCurrentPlatform && headerSearchBarOptions != null;
|
|
295
295
|
|
|
296
296
|
/**
|
|
297
297
|
* We need to set this in if:
|
|
@@ -413,10 +413,8 @@ export function useHeaderConfigProps({
|
|
|
413
413
|
) : null}
|
|
414
414
|
</>
|
|
415
415
|
)}
|
|
416
|
-
{headerBackIcon !== undefined
|
|
417
|
-
<ScreenStackHeaderBackButtonImage
|
|
418
|
-
source={headerBackIcon?.source ?? headerBackImageSource}
|
|
419
|
-
/>
|
|
416
|
+
{headerBackIcon !== undefined ? (
|
|
417
|
+
<ScreenStackHeaderBackButtonImage source={headerBackIcon.source} />
|
|
420
418
|
) : null}
|
|
421
419
|
{Platform.OS === 'ios' && rightItems ? (
|
|
422
420
|
rightItems.map((item, index) => {
|
|
@@ -441,7 +439,10 @@ export function useHeaderConfigProps({
|
|
|
441
439
|
) : null}
|
|
442
440
|
{hasHeaderSearchBar ? (
|
|
443
441
|
<ScreenStackHeaderSearchBarView>
|
|
444
|
-
<SearchBar
|
|
442
|
+
<SearchBar
|
|
443
|
+
{...headerSearchBarOptions}
|
|
444
|
+
onChangeText={headerSearchBarOptions.onChange}
|
|
445
|
+
/>
|
|
445
446
|
</ScreenStackHeaderSearchBarView>
|
|
446
447
|
) : null}
|
|
447
448
|
</>
|
|
@@ -486,5 +487,6 @@ export function useHeaderConfigProps({
|
|
|
486
487
|
children,
|
|
487
488
|
headerLeftBarButtonItems: processBarButtonItems(leftItems, colors, fonts),
|
|
488
489
|
headerRightBarButtonItems: processBarButtonItems(rightItems, colors, fonts),
|
|
490
|
+
experimental_userInterfaceStyle: dark ? 'dark' : 'light',
|
|
489
491
|
} as const;
|
|
490
492
|
}
|
|
@@ -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
|
-
}
|