@react-navigation/native-stack 7.9.0 → 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 +123 -172
- package/lib/module/views/NativeStackView.native.js.map +1 -1
- package/lib/module/views/useHeaderConfigProps.js +11 -14
- 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 +16 -83
- 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 +11 -12
- package/src/index.tsx +4 -1
- package/src/navigators/createNativeStackNavigator.tsx +48 -25
- package/src/types.tsx +16 -88
- package/src/views/NativeStackView.native.tsx +138 -215
- package/src/views/NativeStackView.tsx +6 -9
- package/src/views/useHeaderConfigProps.tsx +13 -25
- 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,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createNavigatorFactory,
|
|
3
3
|
type EventArg,
|
|
4
|
-
type NavigatorTypeBagBase,
|
|
5
4
|
type ParamListBase,
|
|
6
5
|
type StackActionHelpers,
|
|
7
6
|
StackActions,
|
|
@@ -9,6 +8,10 @@ import {
|
|
|
9
8
|
StackRouter,
|
|
10
9
|
type StackRouterOptions,
|
|
11
10
|
type StaticConfig,
|
|
11
|
+
type StaticParamList,
|
|
12
|
+
type StaticScreenConfig,
|
|
13
|
+
type StaticScreenConfigLinking,
|
|
14
|
+
type StaticScreenConfigScreen,
|
|
12
15
|
type TypedNavigator,
|
|
13
16
|
useNavigationBuilder,
|
|
14
17
|
} from '@react-navigation/native';
|
|
@@ -23,15 +26,14 @@ import type {
|
|
|
23
26
|
import { NativeStackView } from '../views/NativeStackView';
|
|
24
27
|
|
|
25
28
|
function NativeStackNavigator({
|
|
26
|
-
id,
|
|
27
29
|
initialRouteName,
|
|
28
|
-
|
|
30
|
+
routeNamesChangeBehavior,
|
|
29
31
|
children,
|
|
30
32
|
layout,
|
|
31
33
|
screenListeners,
|
|
32
34
|
screenOptions,
|
|
33
35
|
screenLayout,
|
|
34
|
-
|
|
36
|
+
router,
|
|
35
37
|
...rest
|
|
36
38
|
}: NativeStackNavigatorProps) {
|
|
37
39
|
const { state, describe, descriptors, navigation, NavigationContent } =
|
|
@@ -42,15 +44,14 @@ function NativeStackNavigator({
|
|
|
42
44
|
NativeStackNavigationOptions,
|
|
43
45
|
NativeStackNavigationEventMap
|
|
44
46
|
>(StackRouter, {
|
|
45
|
-
id,
|
|
46
47
|
initialRouteName,
|
|
47
|
-
|
|
48
|
+
routeNamesChangeBehavior,
|
|
48
49
|
children,
|
|
49
50
|
layout,
|
|
50
51
|
screenListeners,
|
|
51
52
|
screenOptions,
|
|
52
53
|
screenLayout,
|
|
53
|
-
|
|
54
|
+
router,
|
|
54
55
|
});
|
|
55
56
|
|
|
56
57
|
React.useEffect(
|
|
@@ -92,25 +93,47 @@ function NativeStackNavigator({
|
|
|
92
93
|
);
|
|
93
94
|
}
|
|
94
95
|
|
|
96
|
+
type NativeStackTypeBag<ParamList extends {}> = {
|
|
97
|
+
ParamList: ParamList;
|
|
98
|
+
State: StackNavigationState<ParamList>;
|
|
99
|
+
ScreenOptions: NativeStackNavigationOptions;
|
|
100
|
+
EventMap: NativeStackNavigationEventMap;
|
|
101
|
+
NavigationList: {
|
|
102
|
+
[RouteName in keyof ParamList]: NativeStackNavigationProp<
|
|
103
|
+
ParamList,
|
|
104
|
+
RouteName
|
|
105
|
+
>;
|
|
106
|
+
};
|
|
107
|
+
Navigator: typeof NativeStackNavigator;
|
|
108
|
+
};
|
|
109
|
+
|
|
95
110
|
export function createNativeStackNavigator<
|
|
96
111
|
const ParamList extends ParamListBase,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
RouteName,
|
|
108
|
-
NavigatorID
|
|
109
|
-
>;
|
|
110
|
-
};
|
|
111
|
-
Navigator: typeof NativeStackNavigator;
|
|
112
|
-
},
|
|
113
|
-
const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,
|
|
114
|
-
>(config?: Config): TypedNavigator<TypeBag, Config> {
|
|
112
|
+
>(): TypedNavigator<NativeStackTypeBag<ParamList>, undefined>;
|
|
113
|
+
export function createNativeStackNavigator<
|
|
114
|
+
const Config extends StaticConfig<NativeStackTypeBag<ParamListBase>>,
|
|
115
|
+
>(
|
|
116
|
+
config: Config
|
|
117
|
+
): TypedNavigator<
|
|
118
|
+
NativeStackTypeBag<StaticParamList<{ config: Config }>>,
|
|
119
|
+
Config
|
|
120
|
+
>;
|
|
121
|
+
export function createNativeStackNavigator(config?: unknown) {
|
|
115
122
|
return createNavigatorFactory(NativeStackNavigator)(config);
|
|
116
123
|
}
|
|
124
|
+
|
|
125
|
+
export function createNativeStackScreen<
|
|
126
|
+
const Linking extends StaticScreenConfigLinking,
|
|
127
|
+
const Screen extends StaticScreenConfigScreen,
|
|
128
|
+
>(
|
|
129
|
+
config: StaticScreenConfig<
|
|
130
|
+
Linking,
|
|
131
|
+
Screen,
|
|
132
|
+
StackNavigationState<ParamListBase>,
|
|
133
|
+
NativeStackNavigationOptions,
|
|
134
|
+
NativeStackNavigationEventMap,
|
|
135
|
+
NativeStackNavigationProp<ParamListBase>
|
|
136
|
+
>
|
|
137
|
+
) {
|
|
138
|
+
return config;
|
|
139
|
+
}
|
package/src/types.tsx
CHANGED
|
@@ -53,31 +53,27 @@ export type NativeStackNavigationEventMap = {
|
|
|
53
53
|
export type NativeStackNavigationProp<
|
|
54
54
|
ParamList extends ParamListBase,
|
|
55
55
|
RouteName extends keyof ParamList = string,
|
|
56
|
-
NavigatorID extends string | undefined = undefined,
|
|
57
56
|
> = NavigationProp<
|
|
58
57
|
ParamList,
|
|
59
58
|
RouteName,
|
|
60
|
-
NavigatorID,
|
|
61
59
|
StackNavigationState<ParamList>,
|
|
62
60
|
NativeStackNavigationOptions,
|
|
63
|
-
NativeStackNavigationEventMap
|
|
64
|
-
>
|
|
65
|
-
|
|
61
|
+
NativeStackNavigationEventMap,
|
|
62
|
+
StackActionHelpers<ParamList>
|
|
63
|
+
>;
|
|
66
64
|
|
|
67
65
|
export type NativeStackScreenProps<
|
|
68
66
|
ParamList extends ParamListBase,
|
|
69
67
|
RouteName extends keyof ParamList = string,
|
|
70
|
-
NavigatorID extends string | undefined = undefined,
|
|
71
68
|
> = {
|
|
72
|
-
navigation: NativeStackNavigationProp<ParamList, RouteName
|
|
69
|
+
navigation: NativeStackNavigationProp<ParamList, RouteName>;
|
|
73
70
|
route: RouteProp<ParamList, RouteName>;
|
|
74
71
|
};
|
|
75
72
|
|
|
76
73
|
export type NativeStackOptionsArgs<
|
|
77
74
|
ParamList extends ParamListBase,
|
|
78
75
|
RouteName extends keyof ParamList = keyof ParamList,
|
|
79
|
-
|
|
80
|
-
> = NativeStackScreenProps<ParamList, RouteName, NavigatorID> & {
|
|
76
|
+
> = NativeStackScreenProps<ParamList, RouteName> & {
|
|
81
77
|
theme: Theme;
|
|
82
78
|
};
|
|
83
79
|
|
|
@@ -121,7 +117,7 @@ export type NativeStackHeaderItemProps = {
|
|
|
121
117
|
/**
|
|
122
118
|
* Tint color for the header.
|
|
123
119
|
*/
|
|
124
|
-
tintColor?:
|
|
120
|
+
tintColor?: ColorValue;
|
|
125
121
|
/**
|
|
126
122
|
* Whether it's possible to navigate back in stack.
|
|
127
123
|
*/
|
|
@@ -193,7 +189,6 @@ export type NativeStackNavigationOptions = {
|
|
|
193
189
|
}>;
|
|
194
190
|
/**
|
|
195
191
|
* Icon to display in the header as the icon in the back button.
|
|
196
|
-
*
|
|
197
192
|
* Defaults to back icon image for the platform
|
|
198
193
|
* - A chevron on iOS
|
|
199
194
|
* - An arrow on Android
|
|
@@ -210,15 +205,9 @@ export type NativeStackNavigationOptions = {
|
|
|
210
205
|
type: 'image';
|
|
211
206
|
source: ImageSourcePropType;
|
|
212
207
|
};
|
|
213
|
-
/**
|
|
214
|
-
* Image to display in the header as the icon in the back button.
|
|
215
|
-
*
|
|
216
|
-
* @deprecated Use `headerBackIcon` instead.
|
|
217
|
-
*/
|
|
218
|
-
headerBackImageSource?: ImageSourcePropType;
|
|
219
208
|
/**
|
|
220
209
|
* Style of the header when a large title is shown.
|
|
221
|
-
* The large title is shown if `
|
|
210
|
+
* The large title is shown if `headerLargeTitleEnabled` is `true` and
|
|
222
211
|
* the edge of any scrollable content reaches the matching edge of the header.
|
|
223
212
|
*
|
|
224
213
|
* Supported properties:
|
|
@@ -229,7 +218,7 @@ export type NativeStackNavigationOptions = {
|
|
|
229
218
|
* @platform ios
|
|
230
219
|
*/
|
|
231
220
|
headerLargeStyle?: StyleProp<{
|
|
232
|
-
backgroundColor?:
|
|
221
|
+
backgroundColor?: ColorValue;
|
|
233
222
|
}>;
|
|
234
223
|
/**
|
|
235
224
|
* Whether to enable header with large title which collapses to regular header on scroll.
|
|
@@ -243,12 +232,6 @@ export type NativeStackNavigationOptions = {
|
|
|
243
232
|
* @platform ios
|
|
244
233
|
*/
|
|
245
234
|
headerLargeTitleEnabled?: boolean;
|
|
246
|
-
/**
|
|
247
|
-
* Whether to enable header with large title which collapses to regular header on scroll.
|
|
248
|
-
*
|
|
249
|
-
* @deprecated Use `headerLargeTitleEnabled` instead.
|
|
250
|
-
*/
|
|
251
|
-
headerLargeTitle?: boolean;
|
|
252
235
|
/**
|
|
253
236
|
* Whether drop shadow of header is visible when a large title is shown.
|
|
254
237
|
*
|
|
@@ -272,7 +255,7 @@ export type NativeStackNavigationOptions = {
|
|
|
272
255
|
fontFamily?: string;
|
|
273
256
|
fontSize?: number;
|
|
274
257
|
fontWeight?: string;
|
|
275
|
-
color?:
|
|
258
|
+
color?: ColorValue;
|
|
276
259
|
}>;
|
|
277
260
|
/**
|
|
278
261
|
* Whether to show the header. The header is shown by default.
|
|
@@ -284,7 +267,7 @@ export type NativeStackNavigationOptions = {
|
|
|
284
267
|
* - backgroundColor
|
|
285
268
|
*/
|
|
286
269
|
headerStyle?: StyleProp<{
|
|
287
|
-
backgroundColor?:
|
|
270
|
+
backgroundColor?: ColorValue;
|
|
288
271
|
}>;
|
|
289
272
|
/**
|
|
290
273
|
* Whether to hide the elevation shadow (Android) or the bottom border (iOS) on the header.
|
|
@@ -310,7 +293,7 @@ export type NativeStackNavigationOptions = {
|
|
|
310
293
|
/**
|
|
311
294
|
* Tint color for the header. Changes the color of back button and title.
|
|
312
295
|
*/
|
|
313
|
-
headerTintColor?:
|
|
296
|
+
headerTintColor?: ColorValue;
|
|
314
297
|
/**
|
|
315
298
|
* Function which returns a React Element to render as the background of the header.
|
|
316
299
|
* This is useful for using backgrounds such as an image, a gradient, blur effect etc.
|
|
@@ -369,7 +352,7 @@ export type NativeStackNavigationOptions = {
|
|
|
369
352
|
/**
|
|
370
353
|
* Tint color for the header.
|
|
371
354
|
*/
|
|
372
|
-
tintColor?:
|
|
355
|
+
tintColor?: ColorValue;
|
|
373
356
|
}) => React.ReactNode);
|
|
374
357
|
/**
|
|
375
358
|
* How to align the the header title.
|
|
@@ -387,7 +370,7 @@ export type NativeStackNavigationOptions = {
|
|
|
387
370
|
*/
|
|
388
371
|
headerTitleStyle?: StyleProp<
|
|
389
372
|
Pick<TextStyle, 'fontFamily' | 'fontSize' | 'fontWeight'> & {
|
|
390
|
-
color?:
|
|
373
|
+
color?: ColorValue;
|
|
391
374
|
}
|
|
392
375
|
>;
|
|
393
376
|
/**
|
|
@@ -395,7 +378,9 @@ export type NativeStackNavigationOptions = {
|
|
|
395
378
|
* You also need to specify `contentInsetAdjustmentBehavior="automatic"` in your `ScrollView`, `FlatList` etc.
|
|
396
379
|
* If you don't have a `ScrollView`, specify `headerTransparent: false`.
|
|
397
380
|
*/
|
|
398
|
-
headerSearchBarOptions?: SearchBarProps
|
|
381
|
+
headerSearchBarOptions?: Omit<SearchBarProps, 'onChangeText'> & {
|
|
382
|
+
onChange?: SearchBarProps['onChangeText'];
|
|
383
|
+
};
|
|
399
384
|
/**
|
|
400
385
|
* Boolean indicating whether to show the menu on longPress of iOS >= 14 back button. Defaults to `true`.
|
|
401
386
|
* Requires `react-native-screens` version >=3.3.0.
|
|
@@ -439,26 +424,6 @@ export type NativeStackNavigationOptions = {
|
|
|
439
424
|
* @platform ios
|
|
440
425
|
*/
|
|
441
426
|
keyboardHandlingEnabled?: boolean;
|
|
442
|
-
/**
|
|
443
|
-
* Sets the navigation bar color. Defaults to initial navigation bar color.
|
|
444
|
-
*
|
|
445
|
-
* @deprecated For all apps targeting Android SDK 35 or above edge-to-edge is enabled by default.
|
|
446
|
-
* This prop is subject to removal in the future.
|
|
447
|
-
* See: https://developer.android.com/about/versions/15/behavior-changes-15#ux.
|
|
448
|
-
*
|
|
449
|
-
* @platform android
|
|
450
|
-
*/
|
|
451
|
-
navigationBarColor?: string;
|
|
452
|
-
/**
|
|
453
|
-
* Boolean indicating whether the content should be visible behind the navigation bar. Defaults to `false`.
|
|
454
|
-
*
|
|
455
|
-
* @deprecated For all apps targeting Android SDK 35 or above edge-to-edge is enabled by default.
|
|
456
|
-
* This prop is subject to removal in the future.
|
|
457
|
-
* See: https://developer.android.com/about/versions/15/behavior-changes-15#ux.
|
|
458
|
-
*
|
|
459
|
-
* @platform android
|
|
460
|
-
*/
|
|
461
|
-
navigationBarTranslucent?: boolean;
|
|
462
427
|
/**
|
|
463
428
|
* Sets the visibility of the navigation bar. Defaults to `false`.
|
|
464
429
|
*
|
|
@@ -477,16 +442,6 @@ export type NativeStackNavigationOptions = {
|
|
|
477
442
|
* @platform android, ios
|
|
478
443
|
*/
|
|
479
444
|
statusBarAnimation?: ScreenProps['statusBarAnimation'];
|
|
480
|
-
/**
|
|
481
|
-
* Sets the status bar color (similar to the `StatusBar` component). Defaults to initial status bar color.
|
|
482
|
-
*
|
|
483
|
-
* @deprecated For all apps targeting Android SDK 35 or above edge-to-edge is enabled by default.
|
|
484
|
-
* This prop is subject to removal in the future.
|
|
485
|
-
* See: https://developer.android.com/about/versions/15/behavior-changes-15#ux.
|
|
486
|
-
*
|
|
487
|
-
* @platform android
|
|
488
|
-
*/
|
|
489
|
-
statusBarBackgroundColor?: string;
|
|
490
445
|
/**
|
|
491
446
|
* Whether the status bar should be hidden on this screen.
|
|
492
447
|
* Requires setting `View controller-based status bar appearance -> YES` in your Info.plist file.
|
|
@@ -508,16 +463,6 @@ export type NativeStackNavigationOptions = {
|
|
|
508
463
|
* @platform android, ios
|
|
509
464
|
*/
|
|
510
465
|
statusBarStyle?: ScreenProps['statusBarStyle'];
|
|
511
|
-
/**
|
|
512
|
-
* Sets the translucency of the status bar. Defaults to `false`.
|
|
513
|
-
*
|
|
514
|
-
* @deprecated For all apps targeting Android SDK 35 or above edge-to-edge is enabled by default.
|
|
515
|
-
* This prop is subject to removal in the future.
|
|
516
|
-
* See: https://developer.android.com/about/versions/15/behavior-changes-15#ux.
|
|
517
|
-
*
|
|
518
|
-
* @platform android
|
|
519
|
-
*/
|
|
520
|
-
statusBarTranslucent?: boolean;
|
|
521
466
|
/**
|
|
522
467
|
* Sets the direction in which you should swipe to dismiss the screen.
|
|
523
468
|
* When using `vertical` option, options `fullScreenGestureEnabled: true`, `animationMatchesGesture: true` and `animation: 'slide_from_bottom'` are set by default.
|
|
@@ -724,22 +669,6 @@ export type NativeStackNavigationOptions = {
|
|
|
724
669
|
* Defaults to `none`, indicating that the dimming view should be always present.
|
|
725
670
|
*/
|
|
726
671
|
sheetLargestUndimmedDetentIndex?: number | 'none' | 'last';
|
|
727
|
-
/**
|
|
728
|
-
* Whether the sheet content should be rendered behind the Status Bar or display cutouts.
|
|
729
|
-
*
|
|
730
|
-
* When set to `true`, the sheet will extend to the physical edges of the stack,
|
|
731
|
-
* allowing content to be visible behind the status bar or display cutouts.
|
|
732
|
-
* Detent ratios in sheetAllowedDetents will be measured relative to the full stack height.
|
|
733
|
-
*
|
|
734
|
-
* When set to `false`, the sheet's layout will be constrained by the inset from the top
|
|
735
|
-
* and the detent ratios will then be measured relative to the adjusted height (excluding the top inset).
|
|
736
|
-
* This means that sheetAllowedDetents will result in different sheet heights depending on this prop.
|
|
737
|
-
*
|
|
738
|
-
* Defaults to `false`.
|
|
739
|
-
*
|
|
740
|
-
* @platform android
|
|
741
|
-
*/
|
|
742
|
-
sheetShouldOverflowTopInset?: boolean;
|
|
743
672
|
/**
|
|
744
673
|
* The display orientation to use for the screen.
|
|
745
674
|
*
|
|
@@ -1149,7 +1078,6 @@ export type NativeStackHeaderItem =
|
|
|
1149
1078
|
|
|
1150
1079
|
export type NativeStackNavigatorProps = DefaultNavigatorOptions<
|
|
1151
1080
|
ParamListBase,
|
|
1152
|
-
string | undefined,
|
|
1153
1081
|
StackNavigationState<ParamListBase>,
|
|
1154
1082
|
NativeStackNavigationOptions,
|
|
1155
1083
|
NativeStackNavigationEventMap,
|