@react-navigation/bottom-tabs 8.0.0-alpha.53 → 8.0.0-alpha.55
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/views/BottomTabBar.js +8 -1
- package/lib/module/views/BottomTabBar.js.map +1 -1
- package/lib/module/views/BottomTabViewCustom.js +3 -3
- package/lib/module/views/BottomTabViewCustom.js.map +1 -1
- package/lib/module/views/BottomTabViewNativeImpl.js +26 -13
- package/lib/module/views/BottomTabViewNativeImpl.js.map +1 -1
- package/lib/typescript/src/types.d.ts +77 -53
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabBar.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabViewCustom.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabViewNativeImpl.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/types.tsx +137 -82
- package/src/views/BottomTabBar.tsx +13 -0
- package/src/views/BottomTabViewCustom.tsx +1 -3
- package/src/views/BottomTabViewNativeImpl.tsx +26 -11
package/src/types.tsx
CHANGED
|
@@ -39,8 +39,23 @@ export type BottomTabNavigationEventMap = {
|
|
|
39
39
|
*
|
|
40
40
|
* Preventing default is only supported with `custom` implementation.
|
|
41
41
|
* Use `tabBarSelectionEnabled: false` option with `native` implementation.
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
*
|
|
43
|
+
* The `data` object contains the following properties:
|
|
44
|
+
* - `origin`: set to `native` when event originated from the native tab bar.
|
|
45
|
+
* - `behavior`: specifies how consumers of the event should handle the tab press:
|
|
46
|
+
* - `scrollToTop`: whether the content should scroll to top.
|
|
47
|
+
* - `popToTop`: whether the nested stack should pop to top.
|
|
48
|
+
*/
|
|
49
|
+
tabPress: {
|
|
50
|
+
data: {
|
|
51
|
+
origin?: 'native';
|
|
52
|
+
behavior: {
|
|
53
|
+
scrollToTop: boolean;
|
|
54
|
+
popToTop: boolean;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
canPreventDefault: true;
|
|
58
|
+
};
|
|
44
59
|
/**
|
|
45
60
|
* Event which fires on long press on the tab in the tab bar.
|
|
46
61
|
*
|
|
@@ -61,6 +76,7 @@ export type LabelPosition = 'beside-icon' | 'below-icon';
|
|
|
61
76
|
|
|
62
77
|
export type BottomTabNavigationHelpers = NavigationHelpers<
|
|
63
78
|
ParamListBase,
|
|
79
|
+
TabNavigationState<ParamListBase>,
|
|
64
80
|
BottomTabNavigationEventMap
|
|
65
81
|
> &
|
|
66
82
|
TabActionHelpers<ParamListBase>;
|
|
@@ -94,18 +110,22 @@ export type BottomTabOptionsArgs<
|
|
|
94
110
|
|
|
95
111
|
export type TimingKeyboardAnimationConfig = {
|
|
96
112
|
animation: 'timing';
|
|
97
|
-
config?:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
113
|
+
config?:
|
|
114
|
+
| Omit<
|
|
115
|
+
Partial<Animated.TimingAnimationConfig>,
|
|
116
|
+
'toValue' | 'useNativeDriver'
|
|
117
|
+
>
|
|
118
|
+
| undefined;
|
|
101
119
|
};
|
|
102
120
|
|
|
103
121
|
export type SpringKeyboardAnimationConfig = {
|
|
104
122
|
animation: 'spring';
|
|
105
|
-
config?:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
123
|
+
config?:
|
|
124
|
+
| Omit<
|
|
125
|
+
Partial<Animated.SpringAnimationConfig>,
|
|
126
|
+
'toValue' | 'useNativeDriver'
|
|
127
|
+
>
|
|
128
|
+
| undefined;
|
|
109
129
|
};
|
|
110
130
|
|
|
111
131
|
export type TabBarVisibilityAnimationConfig =
|
|
@@ -125,21 +145,21 @@ type BottomTabCustomOptions = {
|
|
|
125
145
|
*
|
|
126
146
|
* Only supported with `custom` implementation.
|
|
127
147
|
*/
|
|
128
|
-
animation?: TabAnimationName;
|
|
148
|
+
animation?: TabAnimationName | undefined;
|
|
129
149
|
|
|
130
150
|
/**
|
|
131
151
|
* Function which specifies interpolated styles for bottom-tab scenes.
|
|
132
152
|
*
|
|
133
153
|
* Only supported with `custom` implementation.
|
|
134
154
|
*/
|
|
135
|
-
sceneStyleInterpolator?: BottomTabSceneStyleInterpolator;
|
|
155
|
+
sceneStyleInterpolator?: BottomTabSceneStyleInterpolator | undefined;
|
|
136
156
|
|
|
137
157
|
/**
|
|
138
158
|
* Object which specifies the animation type (timing or spring) and their options (such as duration for timing).
|
|
139
159
|
*
|
|
140
160
|
* Only supported with `custom` implementation.
|
|
141
161
|
*/
|
|
142
|
-
transitionSpec?: TransitionSpec;
|
|
162
|
+
transitionSpec?: TransitionSpec | undefined;
|
|
143
163
|
|
|
144
164
|
/**
|
|
145
165
|
* Whether the label is shown below the icon or beside the icon.
|
|
@@ -160,7 +180,7 @@ type BottomTabCustomOptions = {
|
|
|
160
180
|
*
|
|
161
181
|
* Only supported with `custom` implementation.
|
|
162
182
|
*/
|
|
163
|
-
tabBarAllowFontScaling?: boolean;
|
|
183
|
+
tabBarAllowFontScaling?: boolean | undefined;
|
|
164
184
|
|
|
165
185
|
/**
|
|
166
186
|
* Style object for the tab item container.
|
|
@@ -183,24 +203,26 @@ type BottomTabCustomOptions = {
|
|
|
183
203
|
*
|
|
184
204
|
* Only supported with `custom` implementation.
|
|
185
205
|
*/
|
|
186
|
-
tabBarHideOnKeyboard?: boolean;
|
|
206
|
+
tabBarHideOnKeyboard?: boolean | undefined;
|
|
187
207
|
|
|
188
208
|
/**
|
|
189
209
|
* Animation config for showing and hiding the tab bar when the keyboard is shown/hidden.
|
|
190
210
|
*
|
|
191
211
|
* Only supported with `custom` implementation.
|
|
192
212
|
*/
|
|
193
|
-
tabBarVisibilityAnimationConfig?:
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
213
|
+
tabBarVisibilityAnimationConfig?:
|
|
214
|
+
| {
|
|
215
|
+
show?: TabBarVisibilityAnimationConfig | undefined;
|
|
216
|
+
hide?: TabBarVisibilityAnimationConfig | undefined;
|
|
217
|
+
}
|
|
218
|
+
| undefined;
|
|
197
219
|
|
|
198
220
|
/**
|
|
199
221
|
* Variant of the tab bar. Defaults to `uikit`.
|
|
200
222
|
*
|
|
201
223
|
* Only supported with `custom` implementation.
|
|
202
224
|
*/
|
|
203
|
-
tabBarVariant?: Variant;
|
|
225
|
+
tabBarVariant?: Variant | undefined;
|
|
204
226
|
|
|
205
227
|
/**
|
|
206
228
|
* Style object for the tab bar container.
|
|
@@ -218,28 +240,28 @@ type BottomTabCustomOptions = {
|
|
|
218
240
|
*
|
|
219
241
|
* Only supported with `custom` implementation.
|
|
220
242
|
*/
|
|
221
|
-
tabBarBackground?: () => React.ReactNode;
|
|
243
|
+
tabBarBackground?: (() => React.ReactNode) | undefined;
|
|
222
244
|
|
|
223
245
|
/**
|
|
224
246
|
* Position of the tab bar on the screen. Defaults to `bottom`.
|
|
225
247
|
*
|
|
226
248
|
* Only supported with `custom` implementation or if custom tab bar is provided.
|
|
227
249
|
*/
|
|
228
|
-
tabBarPosition?: 'bottom' | 'left' | 'right' | 'top';
|
|
250
|
+
tabBarPosition?: 'bottom' | 'left' | 'right' | 'top' | undefined;
|
|
229
251
|
|
|
230
252
|
/**
|
|
231
253
|
* Background color for the active tab.
|
|
232
254
|
*
|
|
233
255
|
* Only supported with `custom` implementation.
|
|
234
256
|
*/
|
|
235
|
-
tabBarActiveBackgroundColor?: ColorValue;
|
|
257
|
+
tabBarActiveBackgroundColor?: ColorValue | undefined;
|
|
236
258
|
|
|
237
259
|
/**
|
|
238
260
|
* Background color for the inactive tabs.
|
|
239
261
|
*
|
|
240
262
|
* Only supported with `custom` implementation.
|
|
241
263
|
*/
|
|
242
|
-
tabBarInactiveBackgroundColor?: ColorValue;
|
|
264
|
+
tabBarInactiveBackgroundColor?: ColorValue | undefined;
|
|
243
265
|
|
|
244
266
|
/**
|
|
245
267
|
* Function which returns a React element to render as the tab bar button.
|
|
@@ -247,7 +269,9 @@ type BottomTabCustomOptions = {
|
|
|
247
269
|
*
|
|
248
270
|
* Only supported with `custom` implementation.
|
|
249
271
|
*/
|
|
250
|
-
tabBarButton?:
|
|
272
|
+
tabBarButton?:
|
|
273
|
+
| ((props: BottomTabBarButtonProps) => React.ReactNode)
|
|
274
|
+
| undefined;
|
|
251
275
|
};
|
|
252
276
|
|
|
253
277
|
type BottomTabNativeOptions = {
|
|
@@ -261,7 +285,7 @@ type BottomTabNativeOptions = {
|
|
|
261
285
|
*
|
|
262
286
|
* @platform ios
|
|
263
287
|
*/
|
|
264
|
-
tabBarSystemItem?: TabsScreenSystemItem;
|
|
288
|
+
tabBarSystemItem?: TabsScreenSystemItem | undefined;
|
|
265
289
|
|
|
266
290
|
/**
|
|
267
291
|
* Blur effect applied to the tab bar when tab screen is selected.
|
|
@@ -283,7 +307,7 @@ type BottomTabNativeOptions = {
|
|
|
283
307
|
*
|
|
284
308
|
* @platform ios
|
|
285
309
|
*/
|
|
286
|
-
tabBarBlurEffect?: TabsScreenBlurEffect;
|
|
310
|
+
tabBarBlurEffect?: TabsScreenBlurEffect | undefined;
|
|
287
311
|
|
|
288
312
|
/**
|
|
289
313
|
* Minimize behavior for the tab bar.
|
|
@@ -306,7 +330,12 @@ type BottomTabNativeOptions = {
|
|
|
306
330
|
*
|
|
307
331
|
* @platform ios
|
|
308
332
|
*/
|
|
309
|
-
tabBarMinimizeBehavior?:
|
|
333
|
+
tabBarMinimizeBehavior?:
|
|
334
|
+
| 'auto'
|
|
335
|
+
| 'none'
|
|
336
|
+
| 'onScrollDown'
|
|
337
|
+
| 'onScrollUp'
|
|
338
|
+
| undefined;
|
|
310
339
|
|
|
311
340
|
/**
|
|
312
341
|
* Background color of the active indicator.
|
|
@@ -315,7 +344,7 @@ type BottomTabNativeOptions = {
|
|
|
315
344
|
*
|
|
316
345
|
* @platform android
|
|
317
346
|
*/
|
|
318
|
-
tabBarActiveIndicatorColor?: ColorValue;
|
|
347
|
+
tabBarActiveIndicatorColor?: ColorValue | undefined;
|
|
319
348
|
|
|
320
349
|
/**
|
|
321
350
|
* Specifies if the active indicator should be used. Defaults to `true`.
|
|
@@ -324,7 +353,7 @@ type BottomTabNativeOptions = {
|
|
|
324
353
|
*
|
|
325
354
|
* @platform android
|
|
326
355
|
*/
|
|
327
|
-
tabBarActiveIndicatorEnabled?: boolean;
|
|
356
|
+
tabBarActiveIndicatorEnabled?: boolean | undefined;
|
|
328
357
|
|
|
329
358
|
/**
|
|
330
359
|
* Function which returns a React element to display as an accessory view.
|
|
@@ -342,9 +371,9 @@ type BottomTabNativeOptions = {
|
|
|
342
371
|
*
|
|
343
372
|
* @platform ios
|
|
344
373
|
*/
|
|
345
|
-
bottomAccessory?:
|
|
346
|
-
placement: 'regular' | 'inline'
|
|
347
|
-
|
|
374
|
+
bottomAccessory?:
|
|
375
|
+
| ((options: { placement: 'regular' | 'inline' }) => React.ReactNode)
|
|
376
|
+
| undefined;
|
|
348
377
|
|
|
349
378
|
/**
|
|
350
379
|
* Specifies whether `contentInsetAdjustmentBehavior` of the `ScrollView`
|
|
@@ -365,14 +394,14 @@ type BottomTabNativeOptions = {
|
|
|
365
394
|
*
|
|
366
395
|
* @platform ios
|
|
367
396
|
*/
|
|
368
|
-
overrideScrollViewContentInsetAdjustmentBehavior?: boolean;
|
|
397
|
+
overrideScrollViewContentInsetAdjustmentBehavior?: boolean | undefined;
|
|
369
398
|
};
|
|
370
399
|
|
|
371
400
|
export type BottomTabNavigationOptions = {
|
|
372
401
|
/**
|
|
373
402
|
* Title text for the screen.
|
|
374
403
|
*/
|
|
375
|
-
title?: string;
|
|
404
|
+
title?: string | undefined;
|
|
376
405
|
|
|
377
406
|
/**
|
|
378
407
|
* Title string of the tab displayed in the tab bar
|
|
@@ -383,7 +412,7 @@ export type BottomTabNavigationOptions = {
|
|
|
383
412
|
* - The system values are used if `tabBarSystemItem` is set on iOS.
|
|
384
413
|
* - Otherwise, it falls back to the `title` or route name.
|
|
385
414
|
*/
|
|
386
|
-
tabBarLabel?: string;
|
|
415
|
+
tabBarLabel?: string | undefined;
|
|
387
416
|
|
|
388
417
|
/**
|
|
389
418
|
* Label visibility mode for the tab bar items.
|
|
@@ -400,15 +429,17 @@ export type BottomTabNavigationOptions = {
|
|
|
400
429
|
* Supported on all platforms with `custom` implementation.
|
|
401
430
|
* Only supported on Android with `native` implementation.
|
|
402
431
|
*/
|
|
403
|
-
tabBarLabelVisibilityMode?: TabBarItemLabelVisibilityMode;
|
|
432
|
+
tabBarLabelVisibilityMode?: TabBarItemLabelVisibilityMode | undefined;
|
|
404
433
|
|
|
405
434
|
/**
|
|
406
435
|
* Style object for the tab label.
|
|
407
436
|
*/
|
|
408
|
-
tabBarLabelStyle?:
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
437
|
+
tabBarLabelStyle?:
|
|
438
|
+
| Pick<
|
|
439
|
+
TextStyle,
|
|
440
|
+
'fontFamily' | 'fontSize' | 'fontWeight' | 'fontStyle' | 'color'
|
|
441
|
+
>
|
|
442
|
+
| undefined;
|
|
412
443
|
|
|
413
444
|
/**
|
|
414
445
|
* Icon to display for the tab.
|
|
@@ -429,7 +460,8 @@ export type BottomTabNavigationOptions = {
|
|
|
429
460
|
focused: boolean;
|
|
430
461
|
color: ColorValue;
|
|
431
462
|
size: number;
|
|
432
|
-
}) => Icon | React.ReactNode)
|
|
463
|
+
}) => Icon | React.ReactNode)
|
|
464
|
+
| undefined;
|
|
433
465
|
|
|
434
466
|
/**
|
|
435
467
|
* Text to show in a badge on the tab icon.
|
|
@@ -444,10 +476,12 @@ export type BottomTabNavigationOptions = {
|
|
|
444
476
|
* - on iOS, you can only set the background color.
|
|
445
477
|
* - on Android, you can set both background and text colors.
|
|
446
478
|
*/
|
|
447
|
-
tabBarBadgeStyle?:
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
479
|
+
tabBarBadgeStyle?:
|
|
480
|
+
| {
|
|
481
|
+
backgroundColor?: ColorValue | undefined;
|
|
482
|
+
color?: ColorValue | undefined;
|
|
483
|
+
}
|
|
484
|
+
| undefined;
|
|
451
485
|
|
|
452
486
|
/**
|
|
453
487
|
* Color for the icon and label in the active tab.
|
|
@@ -457,14 +491,14 @@ export type BottomTabNavigationOptions = {
|
|
|
457
491
|
/**
|
|
458
492
|
* Color for the icon and label in the inactive tabs.
|
|
459
493
|
*/
|
|
460
|
-
tabBarInactiveTintColor?: ColorValue;
|
|
494
|
+
tabBarInactiveTintColor?: ColorValue | undefined;
|
|
461
495
|
|
|
462
496
|
/**
|
|
463
497
|
* Color of tab bar item's ripple effect.
|
|
464
498
|
*
|
|
465
499
|
* @platform android
|
|
466
500
|
*/
|
|
467
|
-
tabBarRippleColor?: ColorValue;
|
|
501
|
+
tabBarRippleColor?: ColorValue | undefined;
|
|
468
502
|
|
|
469
503
|
/**
|
|
470
504
|
* Display mode for the tab bar.
|
|
@@ -483,41 +517,43 @@ export type BottomTabNavigationOptions = {
|
|
|
483
517
|
* Supported on iOS 18 and above with `native` implementation.
|
|
484
518
|
* Not supported on tvOS.
|
|
485
519
|
*/
|
|
486
|
-
tabBarControllerMode?: 'auto' | 'tabBar' | 'tabSidebar';
|
|
520
|
+
tabBarControllerMode?: 'auto' | 'tabBar' | 'tabSidebar' | undefined;
|
|
487
521
|
|
|
488
522
|
/**
|
|
489
523
|
* Accessibility label for the tab button. This is read by the screen reader when the user taps the tab.
|
|
490
524
|
* It's recommended to set this if you don't have a label for the tab.
|
|
491
525
|
*/
|
|
492
|
-
tabBarAccessibilityLabel?: string;
|
|
526
|
+
tabBarAccessibilityLabel?: string | undefined;
|
|
493
527
|
|
|
494
528
|
/**
|
|
495
529
|
* ID to locate this tab button in tests.
|
|
496
530
|
*/
|
|
497
|
-
tabBarButtonTestID?: string;
|
|
531
|
+
tabBarButtonTestID?: string | undefined;
|
|
498
532
|
|
|
499
533
|
/**
|
|
500
534
|
* Style object for the tab bar container.
|
|
501
535
|
*/
|
|
502
|
-
tabBarStyle?:
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
536
|
+
tabBarStyle?:
|
|
537
|
+
| {
|
|
538
|
+
/**
|
|
539
|
+
* Background color of the tab bar.
|
|
540
|
+
*
|
|
541
|
+
* Only supported on Android and iOS 18 and below.
|
|
542
|
+
*/
|
|
543
|
+
backgroundColor?: ColorValue | undefined;
|
|
544
|
+
/**
|
|
545
|
+
* Shadow color of the tab bar.
|
|
546
|
+
*
|
|
547
|
+
* Only supported on iOS 18 and below.
|
|
548
|
+
*/
|
|
549
|
+
shadowColor?: ColorValue | undefined;
|
|
550
|
+
/**
|
|
551
|
+
* Whether the tab bar is visible.
|
|
552
|
+
* Setting this to `'none'` hides the tab bar.
|
|
553
|
+
*/
|
|
554
|
+
display?: 'flex' | 'none' | undefined;
|
|
555
|
+
}
|
|
556
|
+
| undefined;
|
|
521
557
|
|
|
522
558
|
/**
|
|
523
559
|
* Whether this tab can be selected.
|
|
@@ -526,7 +562,22 @@ export type BottomTabNavigationOptions = {
|
|
|
526
562
|
*
|
|
527
563
|
* Defaults to `true`.
|
|
528
564
|
*/
|
|
529
|
-
tabBarSelectionEnabled?: boolean;
|
|
565
|
+
tabBarSelectionEnabled?: boolean | undefined;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Behavior when pressing the tab in the tab bar while it's already focused.
|
|
569
|
+
*
|
|
570
|
+
* - `scrollToTop`: scroll the first scroll view in the screen to top
|
|
571
|
+
* - `popToTop`: pop a nested stack to its first screen
|
|
572
|
+
*
|
|
573
|
+
* Both default to `true`. Ignored when `tabBarSelectionEnabled` is `false`.
|
|
574
|
+
*/
|
|
575
|
+
tabBarRepeatedPressBehavior?:
|
|
576
|
+
| {
|
|
577
|
+
scrollToTop?: boolean | undefined;
|
|
578
|
+
popToTop?: boolean | undefined;
|
|
579
|
+
}
|
|
580
|
+
| undefined;
|
|
530
581
|
|
|
531
582
|
/**
|
|
532
583
|
* Whether this screen should render only when first accessed.
|
|
@@ -538,13 +589,13 @@ export type BottomTabNavigationOptions = {
|
|
|
538
589
|
* Enabling in native implementation may result in flicker
|
|
539
590
|
* as React renders after native transition is already finished.
|
|
540
591
|
*/
|
|
541
|
-
lazy?: boolean;
|
|
592
|
+
lazy?: boolean | undefined;
|
|
542
593
|
|
|
543
594
|
/**
|
|
544
595
|
* Whether any nested stack should be popped to top when navigating away from the tab.
|
|
545
596
|
* Defaults to `false`.
|
|
546
597
|
*/
|
|
547
|
-
popToTopOnBlur?: boolean; // TODO: handle natively
|
|
598
|
+
popToTopOnBlur?: boolean | undefined; // TODO: handle natively
|
|
548
599
|
|
|
549
600
|
/**
|
|
550
601
|
* Style object for the component wrapping the screen content.
|
|
@@ -554,14 +605,14 @@ export type BottomTabNavigationOptions = {
|
|
|
554
605
|
/**
|
|
555
606
|
* Function that returns a React Element to display as a header.
|
|
556
607
|
*/
|
|
557
|
-
header?: (props: BottomTabHeaderProps) => React.ReactNode;
|
|
608
|
+
header?: ((props: BottomTabHeaderProps) => React.ReactNode) | undefined;
|
|
558
609
|
|
|
559
610
|
/**
|
|
560
611
|
* Whether to show the header.
|
|
561
612
|
*
|
|
562
613
|
* Defaults to `false` unless a header is provided.
|
|
563
614
|
*/
|
|
564
|
-
headerShown?: boolean;
|
|
615
|
+
headerShown?: boolean | undefined;
|
|
565
616
|
|
|
566
617
|
/**
|
|
567
618
|
* What should happen when screens become inactive.
|
|
@@ -574,7 +625,7 @@ export type BottomTabNavigationOptions = {
|
|
|
574
625
|
* It won't be paused until after the first time it becomes focused.
|
|
575
626
|
* This makes sure that effects are run to initialize the screen.
|
|
576
627
|
*/
|
|
577
|
-
inactiveBehavior?: 'pause' | 'none';
|
|
628
|
+
inactiveBehavior?: 'pause' | 'none' | undefined;
|
|
578
629
|
} & HeaderOptions &
|
|
579
630
|
BottomTabNativeOptions &
|
|
580
631
|
BottomTabCustomOptions;
|
|
@@ -659,12 +710,12 @@ export type BottomTabNavigationConfig = {
|
|
|
659
710
|
*
|
|
660
711
|
* On other platforms, it's always `custom` and this option has no effect.
|
|
661
712
|
*/
|
|
662
|
-
implementation?: 'native' | 'custom';
|
|
713
|
+
implementation?: 'native' | 'custom' | undefined;
|
|
663
714
|
|
|
664
715
|
/**
|
|
665
716
|
* Function that returns a React element to display as the tab bar.
|
|
666
717
|
*/
|
|
667
|
-
tabBar?: (props: BottomTabBarProps) => React.ReactNode;
|
|
718
|
+
tabBar?: ((props: BottomTabBarProps) => React.ReactNode) | undefined;
|
|
668
719
|
};
|
|
669
720
|
|
|
670
721
|
export type BottomTabHeaderProps = {
|
|
@@ -685,7 +736,7 @@ export type BottomTabHeaderProps = {
|
|
|
685
736
|
export type BottomTabBarProps = {
|
|
686
737
|
state: TabNavigationState<ParamListBase>;
|
|
687
738
|
descriptors: BottomTabDescriptorMap;
|
|
688
|
-
navigation:
|
|
739
|
+
navigation: BottomTabNavigationHelpers;
|
|
689
740
|
};
|
|
690
741
|
|
|
691
742
|
export type BottomTabBarButtonProps = Omit<
|
|
@@ -695,9 +746,13 @@ export type BottomTabBarButtonProps = Omit<
|
|
|
695
746
|
href?: string | undefined;
|
|
696
747
|
children: React.ReactNode;
|
|
697
748
|
style?: StyleProp<ViewStyle>;
|
|
698
|
-
onPress?:
|
|
699
|
-
|
|
700
|
-
|
|
749
|
+
onPress?:
|
|
750
|
+
| ((
|
|
751
|
+
e:
|
|
752
|
+
| React.MouseEvent<HTMLAnchorElement, MouseEvent>
|
|
753
|
+
| GestureResponderEvent
|
|
754
|
+
) => void)
|
|
755
|
+
| undefined;
|
|
701
756
|
};
|
|
702
757
|
|
|
703
758
|
export type BottomTabNavigatorProps = DefaultNavigatorOptions<
|
|
@@ -438,10 +438,23 @@ export function BottomTabBar({ state, navigation, descriptors, style }: Props) {
|
|
|
438
438
|
const { options } = descriptor;
|
|
439
439
|
|
|
440
440
|
const onPress = () => {
|
|
441
|
+
const isRepeatedPress =
|
|
442
|
+
focused && options.tabBarSelectionEnabled !== false;
|
|
443
|
+
|
|
441
444
|
const event = navigation.emit({
|
|
442
445
|
type: 'tabPress',
|
|
443
446
|
target: route.key,
|
|
444
447
|
canPreventDefault: true,
|
|
448
|
+
data: {
|
|
449
|
+
behavior: {
|
|
450
|
+
scrollToTop:
|
|
451
|
+
isRepeatedPress &&
|
|
452
|
+
options.tabBarRepeatedPressBehavior?.scrollToTop !== false,
|
|
453
|
+
popToTop:
|
|
454
|
+
isRepeatedPress &&
|
|
455
|
+
options.tabBarRepeatedPressBehavior?.popToTop !== false,
|
|
456
|
+
},
|
|
457
|
+
},
|
|
445
458
|
});
|
|
446
459
|
|
|
447
460
|
if (
|
|
@@ -206,9 +206,7 @@ export function BottomTabViewCustom({
|
|
|
206
206
|
// Delay clearing `animating` state
|
|
207
207
|
// This will give time for `popToTop` to get handled before pause
|
|
208
208
|
timer = setTimeout(() => {
|
|
209
|
-
setLastUpdate(
|
|
210
|
-
update.animating ? { ...update, animating: false } : update
|
|
211
|
-
);
|
|
209
|
+
setLastUpdate({ current: focusedRouteKey, animating: false });
|
|
212
210
|
}, 32);
|
|
213
211
|
}
|
|
214
212
|
});
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
CommonActions,
|
|
9
9
|
MaterialSymbol,
|
|
10
|
-
NavigationMetaContext,
|
|
11
10
|
type ParamListBase,
|
|
12
11
|
type Route,
|
|
13
12
|
StackActions,
|
|
@@ -89,10 +88,6 @@ const ICON_SIZE = Platform.select({
|
|
|
89
88
|
default: 24,
|
|
90
89
|
});
|
|
91
90
|
|
|
92
|
-
const meta = {
|
|
93
|
-
type: 'native-tabs',
|
|
94
|
-
};
|
|
95
|
-
|
|
96
91
|
function reducer(state: NativeState, action: NativeAction): NativeState {
|
|
97
92
|
switch (action.type) {
|
|
98
93
|
case 'TRACK_TRANSITION':
|
|
@@ -214,7 +209,8 @@ export function BottomTabViewNative({
|
|
|
214
209
|
// JS sends a requested tab with the native provenance it was based on.
|
|
215
210
|
// Native replies with the selected tab and its new provenance.
|
|
216
211
|
const onTabSelected = (event: NativeSyntheticEvent<TabSelectedEvent>) => {
|
|
217
|
-
const { selectedScreenKey, provenance, actionOrigin } =
|
|
212
|
+
const { selectedScreenKey, provenance, actionOrigin, isRepeated } =
|
|
213
|
+
event.nativeEvent;
|
|
218
214
|
|
|
219
215
|
const confirmed = {
|
|
220
216
|
routeKey: selectedScreenKey,
|
|
@@ -232,10 +228,22 @@ export function BottomTabViewNative({
|
|
|
232
228
|
}
|
|
233
229
|
|
|
234
230
|
if (actionOrigin === 'user') {
|
|
231
|
+
const { tabBarRepeatedPressBehavior } =
|
|
232
|
+
descriptors[route.key]?.options ?? {};
|
|
233
|
+
|
|
235
234
|
const event = navigation.emit({
|
|
236
235
|
type: 'tabPress',
|
|
237
236
|
target: route.key,
|
|
238
237
|
canPreventDefault: true,
|
|
238
|
+
data: {
|
|
239
|
+
origin: 'native',
|
|
240
|
+
behavior: {
|
|
241
|
+
scrollToTop:
|
|
242
|
+
isRepeated && tabBarRepeatedPressBehavior?.scrollToTop !== false,
|
|
243
|
+
popToTop:
|
|
244
|
+
isRepeated && tabBarRepeatedPressBehavior?.popToTop !== false,
|
|
245
|
+
},
|
|
246
|
+
},
|
|
239
247
|
});
|
|
240
248
|
|
|
241
249
|
if (event.defaultPrevented) {
|
|
@@ -311,6 +319,13 @@ export function BottomTabViewNative({
|
|
|
311
319
|
type: 'tabPress',
|
|
312
320
|
target: preventedScreenKey,
|
|
313
321
|
canPreventDefault: true,
|
|
322
|
+
data: {
|
|
323
|
+
origin: 'native',
|
|
324
|
+
behavior: {
|
|
325
|
+
scrollToTop: false,
|
|
326
|
+
popToTop: false,
|
|
327
|
+
},
|
|
328
|
+
},
|
|
314
329
|
});
|
|
315
330
|
};
|
|
316
331
|
|
|
@@ -482,6 +497,7 @@ export function BottomTabViewNative({
|
|
|
482
497
|
inactiveBehavior = 'pause',
|
|
483
498
|
tabBarLabel,
|
|
484
499
|
tabBarSelectionEnabled,
|
|
500
|
+
tabBarRepeatedPressBehavior,
|
|
485
501
|
tabBarBadgeStyle,
|
|
486
502
|
tabBarIcon,
|
|
487
503
|
tabBarBadge,
|
|
@@ -594,8 +610,9 @@ export function BottomTabViewNative({
|
|
|
594
610
|
nativeContainerStyle={{ backgroundColor: colors.background }}
|
|
595
611
|
specialEffects={{
|
|
596
612
|
repeatedTabSelection: {
|
|
597
|
-
popToRoot:
|
|
598
|
-
scrollToTop:
|
|
613
|
+
popToRoot: tabBarRepeatedPressBehavior?.popToTop !== false,
|
|
614
|
+
scrollToTop:
|
|
615
|
+
tabBarRepeatedPressBehavior?.scrollToTop !== false,
|
|
599
616
|
},
|
|
600
617
|
}}
|
|
601
618
|
android={{
|
|
@@ -680,9 +697,7 @@ export function BottomTabViewNative({
|
|
|
680
697
|
>
|
|
681
698
|
<AnimatedScreenContent isFocused={isFocused}>
|
|
682
699
|
<BottomTabBarHeightContext.Provider value={0}>
|
|
683
|
-
|
|
684
|
-
{render()}
|
|
685
|
-
</NavigationMetaContext.Provider>
|
|
700
|
+
{render()}
|
|
686
701
|
</BottomTabBarHeightContext.Provider>
|
|
687
702
|
</AnimatedScreenContent>
|
|
688
703
|
</ScreenContent>
|