@react-navigation/bottom-tabs 7.5.0 → 7.7.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.
Files changed (61) hide show
  1. package/lib/module/navigators/createBottomTabNavigator.js +2 -0
  2. package/lib/module/navigators/createBottomTabNavigator.js.map +1 -1
  3. package/lib/module/unstable/NativeBottomTabView.js +6 -0
  4. package/lib/module/unstable/NativeBottomTabView.js.map +1 -0
  5. package/lib/module/unstable/NativeBottomTabView.native.js +225 -0
  6. package/lib/module/unstable/NativeBottomTabView.native.js.map +1 -0
  7. package/lib/module/unstable/NativeScreen/NativeScreen.js +166 -0
  8. package/lib/module/unstable/NativeScreen/NativeScreen.js.map +1 -0
  9. package/lib/module/unstable/NativeScreen/debounce.js +12 -0
  10. package/lib/module/unstable/NativeScreen/debounce.js.map +1 -0
  11. package/lib/module/unstable/NativeScreen/types.js +4 -0
  12. package/lib/module/unstable/NativeScreen/types.js.map +1 -0
  13. package/lib/module/unstable/NativeScreen/useAnimatedHeaderHeight.js +12 -0
  14. package/lib/module/unstable/NativeScreen/useAnimatedHeaderHeight.js.map +1 -0
  15. package/lib/module/unstable/NativeScreen/useHeaderConfig.js +283 -0
  16. package/lib/module/unstable/NativeScreen/useHeaderConfig.js.map +1 -0
  17. package/lib/module/unstable/createNativeBottomTabNavigator.js +6 -0
  18. package/lib/module/unstable/createNativeBottomTabNavigator.js.map +1 -0
  19. package/lib/module/unstable/createNativeBottomTabNavigator.native.js +65 -0
  20. package/lib/module/unstable/createNativeBottomTabNavigator.native.js.map +1 -0
  21. package/lib/module/unstable/index.js +16 -0
  22. package/lib/module/unstable/index.js.map +1 -0
  23. package/lib/module/unstable/types.js +4 -0
  24. package/lib/module/unstable/types.js.map +1 -0
  25. package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts +1 -1
  26. package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts.map +1 -1
  27. package/lib/typescript/src/unstable/NativeBottomTabView.d.ts +10 -0
  28. package/lib/typescript/src/unstable/NativeBottomTabView.d.ts.map +1 -0
  29. package/lib/typescript/src/unstable/NativeBottomTabView.native.d.ts +10 -0
  30. package/lib/typescript/src/unstable/NativeBottomTabView.native.d.ts.map +1 -0
  31. package/lib/typescript/src/unstable/NativeScreen/NativeScreen.d.ts +8 -0
  32. package/lib/typescript/src/unstable/NativeScreen/NativeScreen.d.ts.map +1 -0
  33. package/lib/typescript/src/unstable/NativeScreen/debounce.d.ts +2 -0
  34. package/lib/typescript/src/unstable/NativeScreen/debounce.d.ts.map +1 -0
  35. package/lib/typescript/src/unstable/NativeScreen/types.d.ts +467 -0
  36. package/lib/typescript/src/unstable/NativeScreen/types.d.ts.map +1 -0
  37. package/lib/typescript/src/unstable/NativeScreen/useAnimatedHeaderHeight.d.ts +5 -0
  38. package/lib/typescript/src/unstable/NativeScreen/useAnimatedHeaderHeight.d.ts.map +1 -0
  39. package/lib/typescript/src/unstable/NativeScreen/useHeaderConfig.d.ts +11 -0
  40. package/lib/typescript/src/unstable/NativeScreen/useHeaderConfig.d.ts.map +1 -0
  41. package/lib/typescript/src/unstable/createNativeBottomTabNavigator.d.ts +2 -0
  42. package/lib/typescript/src/unstable/createNativeBottomTabNavigator.d.ts.map +1 -0
  43. package/lib/typescript/src/unstable/createNativeBottomTabNavigator.native.d.ts +16 -0
  44. package/lib/typescript/src/unstable/createNativeBottomTabNavigator.native.d.ts.map +1 -0
  45. package/lib/typescript/src/unstable/index.d.ts +13 -0
  46. package/lib/typescript/src/unstable/index.d.ts.map +1 -0
  47. package/lib/typescript/src/unstable/types.d.ts +276 -0
  48. package/lib/typescript/src/unstable/types.d.ts.map +1 -0
  49. package/package.json +12 -6
  50. package/src/navigators/createBottomTabNavigator.tsx +2 -0
  51. package/src/unstable/NativeBottomTabView.native.tsx +303 -0
  52. package/src/unstable/NativeBottomTabView.tsx +20 -0
  53. package/src/unstable/NativeScreen/NativeScreen.tsx +242 -0
  54. package/src/unstable/NativeScreen/debounce.tsx +14 -0
  55. package/src/unstable/NativeScreen/types.ts +517 -0
  56. package/src/unstable/NativeScreen/useAnimatedHeaderHeight.tsx +18 -0
  57. package/src/unstable/NativeScreen/useHeaderConfig.tsx +423 -0
  58. package/src/unstable/createNativeBottomTabNavigator.native.tsx +116 -0
  59. package/src/unstable/createNativeBottomTabNavigator.tsx +4 -0
  60. package/src/unstable/index.tsx +22 -0
  61. package/src/unstable/types.tsx +353 -0
@@ -0,0 +1,517 @@
1
+ import * as React from 'react';
2
+ import type {
3
+ ColorValue,
4
+ ImageSourcePropType,
5
+ StyleProp,
6
+ TextStyle,
7
+ } from 'react-native';
8
+ import type {
9
+ ScreenStackHeaderConfigProps,
10
+ SearchBarProps,
11
+ } from 'react-native-screens';
12
+ import type { SFSymbol } from 'sf-symbols-typescript';
13
+
14
+ import type { NativeBottomTabHeaderProps } from '../types';
15
+
16
+ export type NativeHeaderOptions = {
17
+ /**
18
+ * String that can be displayed in the header as a fallback for `headerTitle`.
19
+ */
20
+ title?: string;
21
+ /**
22
+ * Style of the header when a large title is shown
23
+ * The large title is shown if `headerLargeTitle` is `true` and
24
+ * the edge of any scrollable content reaches the matching edge of the header.
25
+ *
26
+ * Supported properties:
27
+ * - backgroundColor
28
+ *
29
+ * Only supported on iOS.
30
+ *
31
+ * @platform ios
32
+ */
33
+ headerLargeStyle?: StyleProp<{
34
+ backgroundColor?: ColorValue;
35
+ }>;
36
+ /**
37
+ * Whether to enable header with large title which collapses to regular header on scroll.
38
+ *
39
+ * For large title to collapse on scroll, the content of the screen should be wrapped in a scrollable view such as `ScrollView` or `FlatList`.
40
+ * If the scrollable area doesn't fill the screen, the large title won't collapse on scroll.
41
+ * You also need to specify `contentInsetAdjustmentBehavior="automatic"` in your `ScrollView`, `FlatList` etc.
42
+ *
43
+ * Only supported on iOS.
44
+ *
45
+ * @platform ios
46
+ */
47
+ headerLargeTitle?: boolean;
48
+ /**
49
+ * Whether drop shadow of header is visible when a large title is shown.
50
+ *
51
+ * Only supported on iOS.
52
+ *
53
+ * @platform ios
54
+ */
55
+ headerLargeTitleShadowVisible?: boolean;
56
+ /**
57
+ * Style object for large title in header. Supported properties:
58
+ * - fontFamily
59
+ * - fontSize
60
+ * - fontWeight
61
+ * - color
62
+ *
63
+ * Only supported on iOS.
64
+ *
65
+ * @platform ios
66
+ */
67
+ headerLargeTitleStyle?: StyleProp<{
68
+ fontFamily?: string;
69
+ fontSize?: number;
70
+ fontWeight?: string;
71
+ color?: ColorValue;
72
+ }>;
73
+ /**
74
+ * Style object for header. Supported properties:
75
+ * - backgroundColor
76
+ */
77
+ headerStyle?: StyleProp<{
78
+ backgroundColor?: ColorValue;
79
+ }>;
80
+
81
+ /**
82
+ * Whether to hide the elevation shadow (Android) or the bottom border (iOS) on the header.
83
+ */
84
+ headerShadowVisible?: boolean;
85
+
86
+ /**
87
+ * Boolean indicating whether the navigation bar is translucent.
88
+ * Setting this to `true` makes the header absolutely positioned,
89
+ * and changes the background color to `transparent` unless specified in `headerStyle`.
90
+ */
91
+ headerTransparent?: boolean;
92
+
93
+ /**
94
+ * Blur effect for the translucent header.
95
+ * The `headerTransparent` option needs to be set to `true` for this to work.
96
+ *
97
+ * Only supported on iOS.
98
+ *
99
+ * @platform ios
100
+ */
101
+ headerBlurEffect?: ScreenStackHeaderConfigProps['blurEffect'];
102
+
103
+ /**
104
+ * Tint color for the header. Changes the color of back button and title.
105
+ */
106
+ headerTintColor?: string;
107
+
108
+ /**
109
+ * Function which returns a React Element to render as the background of the header.
110
+ * This is useful for using backgrounds such as an image, a gradient, blur effect etc.
111
+ * You can use this with `headerTransparent` to render content underneath a translucent header.
112
+ */
113
+ headerBackground?: () => React.ReactNode;
114
+
115
+ /**
116
+ * Function which returns a React Element to display on the left side of the header.
117
+ * This replaces the back button. See `headerBackVisible` to show the back button along side left element.
118
+ * Will be overriden by `headerLeftItems` on iOS.
119
+ */
120
+ headerLeft?: (props: NativeScreenHeaderItemProps) => React.ReactNode;
121
+
122
+ /**
123
+ * Function which returns a React Element to display on the right side of the header.
124
+ * Will be overriden by `headerRightItems` on iOS.
125
+ */
126
+ headerRight?: (props: NativeScreenHeaderItemProps) => React.ReactNode;
127
+
128
+ /**
129
+ * Function which returns an array of items to display as on the left side of the header.
130
+ * Overrides `headerLeft`.
131
+ *
132
+ * This is an unstable API and might change in the future.
133
+ *
134
+ * @platform ios
135
+ */
136
+ unstable_headerLeftItems?: (
137
+ props: NativeScreenHeaderItemProps
138
+ ) => NativeScreenHeaderItem[];
139
+
140
+ /**
141
+ * Function which returns an array of items to display as on the right side of the header.
142
+ * Overrides `headerRight`.
143
+ *
144
+ * This is an unstable API and might change in the future.
145
+ *
146
+ * @platform ios
147
+ */
148
+ unstable_headerRightItems?: (
149
+ props: NativeScreenHeaderItemProps
150
+ ) => NativeScreenHeaderItem[];
151
+
152
+ /**
153
+ * String or a function that returns a React Element to be used by the header.
154
+ * Defaults to screen `title` or route name.
155
+ *
156
+ * When a function is passed, it receives `tintColor` and`children` in the options object as an argument.
157
+ * The title string is passed in `children`.
158
+ *
159
+ * Note that if you render a custom element by passing a function, animations for the title won't work.
160
+ */
161
+ headerTitle?:
162
+ | string
163
+ | ((props: {
164
+ /**
165
+ * The title text of the header.
166
+ */
167
+ children: string;
168
+ /**
169
+ * Tint color for the header.
170
+ */
171
+ tintColor?: string;
172
+ }) => React.ReactNode);
173
+
174
+ /**
175
+ * How to align the the header title.
176
+ * Defaults to `left` on platforms other than iOS.
177
+ *
178
+ * Not supported on iOS. It's always `center` on iOS and cannot be changed.
179
+ */
180
+ headerTitleAlign?: 'left' | 'center';
181
+
182
+ /**
183
+ * Style object for header title. Supported properties:
184
+ * - fontFamily
185
+ * - fontSize
186
+ * - fontWeight
187
+ * - color
188
+ */
189
+ headerTitleStyle?: StyleProp<
190
+ Pick<TextStyle, 'fontFamily' | 'fontSize' | 'fontWeight'> & {
191
+ color?: string;
192
+ }
193
+ >;
194
+
195
+ /**
196
+ * Options to render a native search bar.
197
+ * You also need to specify `contentInsetAdjustmentBehavior="automatic"` in your `ScrollView`, `FlatList` etc.
198
+ * If you don't have a `ScrollView`, specify `headerTransparent: false`.
199
+ */
200
+ headerSearchBarOptions?: SearchBarProps;
201
+
202
+ /**
203
+ * Whether to show the header. Setting this to `false` hides the header.
204
+ * Defaults to `true`.
205
+ */
206
+ headerShown?: boolean;
207
+
208
+ /**
209
+ * Function that given returns a React Element to display as a header.
210
+ */
211
+ header?: (props: NativeBottomTabHeaderProps) => React.ReactNode;
212
+ };
213
+
214
+ export type NativeScreenHeaderItemProps = {
215
+ /**
216
+ * Tint color for the header.
217
+ */
218
+ tintColor?: ColorValue;
219
+ };
220
+
221
+ /**
222
+ * A button item in the header.
223
+ */
224
+ export type NativeScreenHeaderItemButton = SharedHeaderItem & {
225
+ /**
226
+ * Type of the item.
227
+ */
228
+ type: 'button';
229
+ /**
230
+ * Function to call when the item is pressed.
231
+ */
232
+ onPress: () => void;
233
+ /**
234
+ * Whether the item is in a selected state.
235
+ *
236
+ * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/isselected
237
+ */
238
+ selected?: boolean;
239
+ };
240
+
241
+ /**
242
+ * An action item in a menu.
243
+ */
244
+ export type NativeScreenHeaderItemMenuAction = {
245
+ type: 'action';
246
+ /**
247
+ * Label for the menu item.
248
+ */
249
+ label: string;
250
+ /**
251
+ * Icon for the menu item.
252
+ */
253
+ icon?: IconIOSSfSymbol;
254
+ /**
255
+ * Function to call when the menu item is pressed.
256
+ */
257
+ onPress: () => void;
258
+ /**
259
+ * The state of an action- or command-based menu item.
260
+ *
261
+ * Read more: https://developer.apple.com/documentation/uikit/uimenuelement/state
262
+ */
263
+ state?: 'on' | 'off' | 'mixed';
264
+ /**
265
+ * Whether to apply disabled style to the item.
266
+ *
267
+ * Read more: https://developer.apple.com/documentation/uikit/uimenuelement/attributes/disabled
268
+ */
269
+ disabled?: boolean;
270
+ /**
271
+ * Whether to apply destructive style to the item.
272
+ *
273
+ * Read more: https://developer.apple.com/documentation/uikit/uimenuelement/attributes/destructive
274
+ */
275
+ destructive?: boolean;
276
+ /**
277
+ * Whether to apply hidden style to the item.
278
+ *
279
+ * Read more: https://developer.apple.com/documentation/uikit/uimenuelement/attributes/hidden
280
+ */
281
+ hidden?: boolean;
282
+ /**
283
+ * Whether to keep the menu presented after firing the element’s action.
284
+ *
285
+ * Read more: https://developer.apple.com/documentation/uikit/uimenuelement/attributes/keepsmenupresented
286
+ */
287
+ keepsMenuPresented?: boolean;
288
+ /**
289
+ * An elaborated title that explains the purpose of the action.
290
+ *
291
+ * On iOS, the system displays this title in the discoverability heads-up display (HUD).
292
+ * If this is not set, the HUD displays the title property.
293
+ *
294
+ * Read more: https://developer.apple.com/documentation/uikit/uiaction/discoverabilitytitle
295
+ */
296
+ discoverabilityLabel?: string;
297
+ };
298
+
299
+ /**
300
+ * A submenu item that contains other menu items.
301
+ */
302
+ export type NativeScreenHeaderItemMenuSubmenu = {
303
+ type: 'submenu';
304
+ /**
305
+ * Label for the submenu item.
306
+ */
307
+ label: string;
308
+ /**
309
+ * Icon for the submenu item.
310
+ */
311
+ icon?: IconIOSSfSymbol;
312
+ /**
313
+ * Array of menu items (actions or submenus).
314
+ */
315
+ items: NativeScreenHeaderItemMenu['menu']['items'];
316
+ };
317
+
318
+ /**
319
+ * An item that shows a menu when pressed.
320
+ */
321
+ export type NativeScreenHeaderItemMenu = SharedHeaderItem & {
322
+ type: 'menu';
323
+ /**
324
+ * Whether the menu is a selection menu.
325
+ * Tapping an item in a selection menu will add a checkmark to the selected item.
326
+ *
327
+ * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/changesselectionasprimaryaction
328
+ */
329
+ changesSelectionAsPrimaryAction?: boolean;
330
+ /**
331
+ * Menu for the item.
332
+ */
333
+ menu: {
334
+ /**
335
+ * Optional title to show on top of the menu.
336
+ */
337
+ title?: string;
338
+ /**
339
+ * Array of menu items (actions or submenus).
340
+ */
341
+ items: (
342
+ | NativeScreenHeaderItemMenuAction
343
+ | NativeScreenHeaderItemMenuSubmenu
344
+ )[];
345
+ };
346
+ };
347
+
348
+ /**
349
+ * An item to add spacing between other items in the header.
350
+ */
351
+ export type NativeScreenHeaderItemSpacing = {
352
+ type: 'spacing';
353
+ /**
354
+ * The amount of spacing to add.
355
+ */
356
+ spacing: number;
357
+ };
358
+
359
+ /**
360
+ * A custom item to display any React Element in the header.
361
+ */
362
+ export type NativeScreenHeaderItemCustom = {
363
+ type: 'custom';
364
+ /**
365
+ * A React Element to display as the item.
366
+ */
367
+ element: React.ReactElement;
368
+ /**
369
+ * Whether the background this item may share with other items in the bar should be hidden.
370
+ * Only available from iOS 26.0 and later.
371
+ *
372
+ * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/hidessharedbackground
373
+ */
374
+ hidesSharedBackground?: boolean;
375
+ };
376
+
377
+ /**
378
+ * An item that can be displayed in the header.
379
+ * It can be a button, a menu, spacing, or a custom element.
380
+ *
381
+ * On iOS 26, when showing items on the right side of the header,
382
+ * if the items don't fit the available space, they will be collapsed into a menu automatically.
383
+ * Items with `type: 'custom'` will not be included in this automatic collapsing behavior.
384
+ */
385
+ export type NativeScreenHeaderItem =
386
+ | NativeScreenHeaderItemButton
387
+ | NativeScreenHeaderItemMenu
388
+ | NativeScreenHeaderItemSpacing
389
+ | NativeScreenHeaderItemCustom;
390
+
391
+ type IconImage = {
392
+ /**
393
+ * - `image` - Use a local image as the icon.
394
+ */
395
+ type: 'image';
396
+ /**
397
+ * Image source to use as the icon.
398
+ * e.g., `require('./path/to/image.png')`
399
+ */
400
+ source: ImageSourcePropType;
401
+ /**
402
+ * Whether to apply tint color to the icon.
403
+ * Defaults to `true`.
404
+ *
405
+ * @platform ios
406
+ */
407
+ tinted?: boolean;
408
+ };
409
+
410
+ type IconIOSSfSymbol = {
411
+ /**
412
+ * - `sfSymbol` - Use an SF Symbol as the icon on iOS.
413
+ */
414
+ type: 'sfSymbol';
415
+ /**
416
+ * Name of the SF Symbol to use as the icon.
417
+ *
418
+ * @platform ios
419
+ */
420
+ name: SFSymbol;
421
+ };
422
+
423
+ type IconIOS = IconIOSSfSymbol | IconImage;
424
+
425
+ type SharedHeaderItem = {
426
+ /**
427
+ * Label of the item.
428
+ */
429
+ label: string;
430
+ /**
431
+ * Style for the item label.
432
+ */
433
+ labelStyle?: {
434
+ fontFamily?: string;
435
+ fontSize?: number;
436
+ fontWeight?: string;
437
+ color?: ColorValue;
438
+ };
439
+ /**
440
+ * Icon for the item
441
+ */
442
+ icon?: IconIOS;
443
+ /**
444
+ * The variant of the item.
445
+ * "prominent" only available from iOS 26.0 and later.
446
+ *
447
+ * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/style-swift.property
448
+ */
449
+ variant?: 'plain' | 'done' | 'prominent';
450
+ /**
451
+ * The tint color to apply to the item.
452
+ *
453
+ * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/tintcolor
454
+ */
455
+ tintColor?: ColorValue;
456
+ /**
457
+ * Whether the item is in a disabled state.
458
+ */
459
+ disabled?: boolean;
460
+ /**
461
+ * The width of the item.
462
+ *
463
+ * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/width
464
+ */
465
+ width?: number;
466
+ /**
467
+ * Whether the background this item may share with other items in the bar should be hidden.
468
+ * Only available from iOS 26.0 and later.
469
+ *
470
+ * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/hidessharedbackground
471
+ */
472
+ hidesSharedBackground?: boolean;
473
+ /**
474
+ * Whether this item can share a background with other items.
475
+ * Only available from iOS 26.0 and later.
476
+ *
477
+ * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/sharesbackground
478
+ */
479
+ sharesBackground?: boolean;
480
+ /**
481
+ * An identifier used to match items across transitions.
482
+ * Only available from iOS 26.0 and later.
483
+ *
484
+ * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitem/identifier
485
+ */
486
+ identifier?: string;
487
+ /**
488
+ * A badge to display on a item.
489
+ * Only available from iOS 26.0 and later.
490
+ *
491
+ * Read more: https://developer.apple.com/documentation/uikit/uibarbuttonitembadge
492
+ */
493
+ badge?: {
494
+ /**
495
+ * The text to display in the badge.
496
+ */
497
+ value: number | string;
498
+ /**
499
+ * Style of the badge.
500
+ */
501
+ style?: {
502
+ color?: ColorValue;
503
+ backgroundColor?: ColorValue;
504
+ fontFamily?: string;
505
+ fontSize?: number;
506
+ fontWeight?: string;
507
+ };
508
+ };
509
+ /**
510
+ * Accessibility label for the item.
511
+ */
512
+ accessibilityLabel?: string;
513
+ /**
514
+ * Accessibility hint for the item.
515
+ */
516
+ accessibilityHint?: string;
517
+ };
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+ import type { Animated } from 'react-native';
3
+
4
+ export const AnimatedHeaderHeightContext = React.createContext<
5
+ Animated.AnimatedInterpolation<number> | undefined
6
+ >(undefined);
7
+
8
+ export function useAnimatedHeaderHeight() {
9
+ const animatedValue = React.useContext(AnimatedHeaderHeightContext);
10
+
11
+ if (animatedValue === undefined) {
12
+ throw new Error(
13
+ "Couldn't find the header height. Are you inside a screen in a native stack navigator?"
14
+ );
15
+ }
16
+
17
+ return animatedValue;
18
+ }