@react-navigation/bottom-tabs 8.0.0-alpha.3 → 8.0.0-alpha.31
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/createBottomTabNavigator.js +4 -25
- package/lib/module/navigators/createBottomTabNavigator.js.map +1 -1
- package/lib/module/utils/useBottomTabAnimation.js +1 -1
- package/lib/module/utils/useBottomTabAnimation.js.map +1 -1
- package/lib/module/utils/useBottomTabBarHeight.js +1 -1
- package/lib/module/utils/useBottomTabBarHeight.js.map +1 -1
- package/lib/module/views/BottomTabBar.js +14 -11
- package/lib/module/views/BottomTabBar.js.map +1 -1
- package/lib/module/views/BottomTabItem.js +1 -1
- package/lib/module/views/BottomTabItem.js.map +1 -1
- package/lib/module/views/{BottomTabViewCommon.js → BottomTabView.js} +1 -1
- package/lib/module/views/BottomTabView.js.map +1 -0
- package/lib/module/views/BottomTabViewCustom.js +64 -66
- package/lib/module/views/BottomTabViewCustom.js.map +1 -1
- package/lib/module/views/BottomTabViewNativeImpl.js +299 -100
- package/lib/module/views/BottomTabViewNativeImpl.js.map +1 -1
- package/lib/module/views/ScreenContent.js.map +1 -1
- package/lib/module/views/TabBarIcon.js +5 -14
- package/lib/module/views/TabBarIcon.js.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts +8 -14
- package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +56 -108
- 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/BottomTabItem.d.ts +16 -16
- package/lib/typescript/src/views/BottomTabItem.d.ts.map +1 -1
- package/lib/typescript/src/views/{BottomTabViewCommon.d.ts → BottomTabView.d.ts} +1 -1
- package/lib/typescript/src/views/BottomTabView.d.ts.map +1 -0
- package/lib/typescript/src/views/BottomTabViewCustom.d.ts +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/lib/typescript/src/views/ScreenContent.d.ts +2 -2
- package/lib/typescript/src/views/ScreenContent.d.ts.map +1 -1
- package/lib/typescript/src/views/TabBarIcon.d.ts +6 -6
- package/lib/typescript/src/views/TabBarIcon.d.ts.map +1 -1
- package/package.json +18 -21
- package/src/index.tsx +2 -2
- package/src/navigators/createBottomTabNavigator.tsx +10 -75
- package/src/types.tsx +56 -116
- package/src/utils/useBottomTabAnimation.tsx +1 -1
- package/src/utils/useBottomTabBarHeight.tsx +1 -1
- package/src/views/BottomTabBar.tsx +24 -12
- package/src/views/BottomTabItem.tsx +17 -19
- package/src/views/BottomTabViewCustom.tsx +119 -117
- package/src/views/BottomTabViewNativeImpl.tsx +447 -151
- package/src/views/ScreenContent.tsx +1 -2
- package/src/views/TabBarIcon.tsx +17 -24
- package/lib/module/views/BottomTabViewCommon.js.map +0 -1
- package/lib/typescript/src/views/BottomTabViewCommon.d.ts.map +0 -1
- /package/src/views/{BottomTabViewCommon.tsx → BottomTabView.tsx} +0 -0
package/src/types.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
HeaderOptions,
|
|
3
|
+
Icon,
|
|
3
4
|
PlatformPressable,
|
|
4
5
|
} from '@react-navigation/elements';
|
|
6
|
+
import type { Screen } from '@react-navigation/elements/internal';
|
|
5
7
|
import type {
|
|
6
8
|
DefaultNavigatorOptions,
|
|
7
9
|
Descriptor,
|
|
8
|
-
MaterialSymbolProps,
|
|
9
10
|
NavigationHelpers,
|
|
10
11
|
NavigationProp,
|
|
11
12
|
ParamListBase,
|
|
@@ -20,7 +21,6 @@ import type {
|
|
|
20
21
|
Animated,
|
|
21
22
|
ColorValue,
|
|
22
23
|
GestureResponderEvent,
|
|
23
|
-
ImageSourcePropType,
|
|
24
24
|
StyleProp,
|
|
25
25
|
TextStyle,
|
|
26
26
|
ViewStyle,
|
|
@@ -28,9 +28,8 @@ import type {
|
|
|
28
28
|
import type {
|
|
29
29
|
TabBarItemLabelVisibilityMode,
|
|
30
30
|
TabsScreenBlurEffect,
|
|
31
|
-
|
|
31
|
+
TabsScreenSystemItem,
|
|
32
32
|
} from 'react-native-screens';
|
|
33
|
-
import type { SFSymbol } from 'sf-symbols-typescript';
|
|
34
33
|
|
|
35
34
|
export type Variant = 'uikit' | 'material';
|
|
36
35
|
|
|
@@ -39,6 +38,7 @@ export type BottomTabNavigationEventMap = {
|
|
|
39
38
|
* Event which fires on tapping on the tab in the tab bar.
|
|
40
39
|
*
|
|
41
40
|
* Preventing default is only supported with `custom` implementation.
|
|
41
|
+
* Use `tabBarSelectionEnabled: false` option with `native` implementation.
|
|
42
42
|
*/
|
|
43
43
|
tabPress: { data: undefined; canPreventDefault: true };
|
|
44
44
|
/**
|
|
@@ -114,75 +114,6 @@ export type TabBarVisibilityAnimationConfig =
|
|
|
114
114
|
|
|
115
115
|
export type TabAnimationName = 'none' | 'fade' | 'shift';
|
|
116
116
|
|
|
117
|
-
type IconImage = {
|
|
118
|
-
/**
|
|
119
|
-
* - `image` - Use a local image as the icon.
|
|
120
|
-
*/
|
|
121
|
-
type: 'image';
|
|
122
|
-
/**
|
|
123
|
-
* Image source to use as the icon.
|
|
124
|
-
* e.g., `require('./path/to/image.png')`
|
|
125
|
-
*/
|
|
126
|
-
source: ImageSourcePropType;
|
|
127
|
-
/**
|
|
128
|
-
* Whether to apply tint color to the icon.
|
|
129
|
-
* Defaults to `true`.
|
|
130
|
-
*
|
|
131
|
-
* @platform ios
|
|
132
|
-
*/
|
|
133
|
-
tinted?: boolean;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
type IconSfSymbol = {
|
|
137
|
-
/**
|
|
138
|
-
* - `sfSymbol` - Use an SF Symbol as the icon on iOS.
|
|
139
|
-
*/
|
|
140
|
-
type: 'sfSymbol';
|
|
141
|
-
/**
|
|
142
|
-
* Name of the SF Symbol to use as the icon.
|
|
143
|
-
*
|
|
144
|
-
* @platform ios
|
|
145
|
-
*/
|
|
146
|
-
name: SFSymbol;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
type IconMaterialSymbol = {
|
|
150
|
-
/**
|
|
151
|
-
* - `materialSymbol` - Use a Material Symbol as the icon on Android.
|
|
152
|
-
*/
|
|
153
|
-
type: 'materialSymbol';
|
|
154
|
-
/**
|
|
155
|
-
* Name of the Material Symbol to use as the icon.
|
|
156
|
-
*
|
|
157
|
-
* @platform android
|
|
158
|
-
*/
|
|
159
|
-
name: MaterialSymbolProps['name'];
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
type IconResource = {
|
|
163
|
-
/**
|
|
164
|
-
* - `resource` - Use a resource from drawables on Android and xcassets asset catalog on iOS as the icon.
|
|
165
|
-
*/
|
|
166
|
-
type: 'resource';
|
|
167
|
-
/**
|
|
168
|
-
* Name of the drawable resource or xcasset to use as the icon.
|
|
169
|
-
*/
|
|
170
|
-
name: string;
|
|
171
|
-
/**
|
|
172
|
-
* Whether to apply tint color to the icon.
|
|
173
|
-
* Only supported with custom implementation.
|
|
174
|
-
*
|
|
175
|
-
* Defaults to `true`.
|
|
176
|
-
*/
|
|
177
|
-
tinted?: boolean;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
type IconIOS = IconSfSymbol | IconImage;
|
|
181
|
-
|
|
182
|
-
type IconAndroid = IconMaterialSymbol | IconResource | IconImage;
|
|
183
|
-
|
|
184
|
-
export type BottomTabIcon = IconIOS | IconAndroid;
|
|
185
|
-
|
|
186
117
|
type BottomTabCustomOptions = {
|
|
187
118
|
/**
|
|
188
119
|
* How the screen should animate when switching tabs.
|
|
@@ -220,7 +151,7 @@ type BottomTabCustomOptions = {
|
|
|
220
151
|
*
|
|
221
152
|
* Only supported with `custom` implementation.
|
|
222
153
|
*/
|
|
223
|
-
tabBarLabelPosition?: LabelPosition;
|
|
154
|
+
tabBarLabelPosition?: LabelPosition | undefined;
|
|
224
155
|
|
|
225
156
|
/**
|
|
226
157
|
* Whether label font should scale to respect Text Size accessibility settings.
|
|
@@ -319,8 +250,6 @@ type BottomTabCustomOptions = {
|
|
|
319
250
|
tabBarButton?: (props: BottomTabBarButtonProps) => React.ReactNode;
|
|
320
251
|
};
|
|
321
252
|
|
|
322
|
-
type ScrollEdgeEffect = 'auto' | 'hard' | 'soft' | 'hidden';
|
|
323
|
-
|
|
324
253
|
type BottomTabNativeOptions = {
|
|
325
254
|
/**
|
|
326
255
|
* Uses iOS built-in tab bar items with standard iOS styling and localized titles.
|
|
@@ -332,7 +261,7 @@ type BottomTabNativeOptions = {
|
|
|
332
261
|
*
|
|
333
262
|
* @platform ios
|
|
334
263
|
*/
|
|
335
|
-
tabBarSystemItem?:
|
|
264
|
+
tabBarSystemItem?: TabsScreenSystemItem;
|
|
336
265
|
|
|
337
266
|
/**
|
|
338
267
|
* Blur effect applied to the tab bar when tab screen is selected.
|
|
@@ -418,36 +347,25 @@ type BottomTabNativeOptions = {
|
|
|
418
347
|
}) => React.ReactNode;
|
|
419
348
|
|
|
420
349
|
/**
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
* for the specified edge of the ScrollView.
|
|
424
|
-
*
|
|
425
|
-
* When set in nested containers, i.e. Native Stack inside Native Bottom Tabs, or the other way around,
|
|
426
|
-
* the ScrollView will use only the innermost one's config.
|
|
350
|
+
* Specifies whether `contentInsetAdjustmentBehavior` of the `ScrollView`
|
|
351
|
+
* in the screen is automatically adjusted.
|
|
427
352
|
*
|
|
428
|
-
*
|
|
353
|
+
* `react-native`'s `ScrollView`s has `contentInsetAdjustmentBehavior` set to `never` by default.
|
|
354
|
+
* To provide a better UX, it is overridden to `automatic` - so it respects the tab bar.
|
|
355
|
+
* Otherwise, content can get hidden behind the tab bar as it's translucent on iOS 26+.
|
|
429
356
|
*
|
|
430
|
-
*
|
|
357
|
+
* Note that this only affects the `ScrollView` in first descendant chain of the screen,
|
|
358
|
+
* i.e., first view of each nested view is checked until a `ScrollView` is found.
|
|
431
359
|
*
|
|
432
|
-
*
|
|
433
|
-
* - `hard` - a scroll edge effect with a hard cutoff and dividing line,
|
|
434
|
-
* - `soft` - a soft-edged scroll edge effect,
|
|
435
|
-
* - `hidden` - no scroll edge effect.
|
|
436
|
-
*
|
|
437
|
-
* Defaults to `automatic` for each edge.
|
|
438
|
-
*
|
|
439
|
-
* Available starting from iOS 26.
|
|
360
|
+
* To disable this behavior for specific screens, set this option to `false`.
|
|
440
361
|
*
|
|
441
362
|
* Only supported with `native` implementation.
|
|
442
363
|
*
|
|
364
|
+
* Defaults to `true`.
|
|
365
|
+
*
|
|
443
366
|
* @platform ios
|
|
444
367
|
*/
|
|
445
|
-
|
|
446
|
-
bottom?: ScrollEdgeEffect;
|
|
447
|
-
left?: ScrollEdgeEffect;
|
|
448
|
-
right?: ScrollEdgeEffect;
|
|
449
|
-
top?: ScrollEdgeEffect;
|
|
450
|
-
};
|
|
368
|
+
overrideScrollViewContentInsetAdjustmentBehavior?: boolean;
|
|
451
369
|
};
|
|
452
370
|
|
|
453
371
|
export type BottomTabNavigationOptions = {
|
|
@@ -489,7 +407,7 @@ export type BottomTabNavigationOptions = {
|
|
|
489
407
|
*/
|
|
490
408
|
tabBarLabelStyle?: Pick<
|
|
491
409
|
TextStyle,
|
|
492
|
-
'fontFamily' | 'fontSize' | 'fontWeight' | 'fontStyle'
|
|
410
|
+
'fontFamily' | 'fontSize' | 'fontWeight' | 'fontStyle' | 'color'
|
|
493
411
|
>;
|
|
494
412
|
|
|
495
413
|
/**
|
|
@@ -501,26 +419,30 @@ export type BottomTabNavigationOptions = {
|
|
|
501
419
|
* - on all platforms with `custom` implementation
|
|
502
420
|
* - on iOS with `native` implementation
|
|
503
421
|
*
|
|
422
|
+
* With `native` implementation, `tinted` for `image` can only be disabled on iOS.
|
|
423
|
+
*
|
|
504
424
|
* A React element is only supported with `custom` implementation.
|
|
505
425
|
*/
|
|
506
426
|
tabBarIcon?:
|
|
507
|
-
|
|
|
427
|
+
| Icon
|
|
508
428
|
| ((props: {
|
|
509
429
|
focused: boolean;
|
|
510
430
|
color: ColorValue;
|
|
511
431
|
size: number;
|
|
512
|
-
}) =>
|
|
432
|
+
}) => Icon | React.ReactNode);
|
|
513
433
|
|
|
514
434
|
/**
|
|
515
435
|
* Text to show in a badge on the tab icon.
|
|
516
436
|
*/
|
|
517
|
-
tabBarBadge?: number | string;
|
|
437
|
+
tabBarBadge?: number | string | undefined;
|
|
518
438
|
|
|
519
439
|
/**
|
|
520
440
|
* Custom style for the tab bar badge.
|
|
521
441
|
* You can specify a background color or text color here.
|
|
522
442
|
*
|
|
523
|
-
*
|
|
443
|
+
* With `native` implementation, limited customization is supported:
|
|
444
|
+
* - on iOS, you can only set the background color.
|
|
445
|
+
* - on Android, you can set both background and text colors.
|
|
524
446
|
*/
|
|
525
447
|
tabBarBadgeStyle?: {
|
|
526
448
|
backgroundColor?: ColorValue;
|
|
@@ -530,7 +452,7 @@ export type BottomTabNavigationOptions = {
|
|
|
530
452
|
/**
|
|
531
453
|
* Color for the icon and label in the active tab.
|
|
532
454
|
*/
|
|
533
|
-
tabBarActiveTintColor?: ColorValue;
|
|
455
|
+
tabBarActiveTintColor?: ColorValue | undefined;
|
|
534
456
|
|
|
535
457
|
/**
|
|
536
458
|
* Color for the icon and label in the inactive tabs.
|
|
@@ -590,8 +512,22 @@ export type BottomTabNavigationOptions = {
|
|
|
590
512
|
* Only supported on iOS 18 and below.
|
|
591
513
|
*/
|
|
592
514
|
shadowColor?: ColorValue;
|
|
515
|
+
/**
|
|
516
|
+
* Whether the tab bar is visible.
|
|
517
|
+
* Setting this to `'none'` hides the tab bar.
|
|
518
|
+
*/
|
|
519
|
+
display?: 'flex' | 'none';
|
|
593
520
|
};
|
|
594
521
|
|
|
522
|
+
/**
|
|
523
|
+
* Whether this tab can be selected.
|
|
524
|
+
* When `false`, tapping on the tab in tab bar won't select the tab.
|
|
525
|
+
* Custom behavior can be implemented by listening to `tabPress` event.
|
|
526
|
+
*
|
|
527
|
+
* Defaults to `true`.
|
|
528
|
+
*/
|
|
529
|
+
tabBarSelectionEnabled?: boolean;
|
|
530
|
+
|
|
595
531
|
/**
|
|
596
532
|
* Whether this screens should render the first time it's accessed. Defaults to `true`.
|
|
597
533
|
* Set it to `false` if you want to render the screen on initial render.
|
|
@@ -607,7 +543,7 @@ export type BottomTabNavigationOptions = {
|
|
|
607
543
|
/**
|
|
608
544
|
* Style object for the component wrapping the screen content.
|
|
609
545
|
*/
|
|
610
|
-
sceneStyle?:
|
|
546
|
+
sceneStyle?: React.ComponentProps<typeof Screen>['style'];
|
|
611
547
|
|
|
612
548
|
/**
|
|
613
549
|
* Function that returns a React Element to display as a header.
|
|
@@ -620,6 +556,19 @@ export type BottomTabNavigationOptions = {
|
|
|
620
556
|
* Defaults to `false` unless a header is provided.
|
|
621
557
|
*/
|
|
622
558
|
headerShown?: boolean;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* What should happen when screens become inactive.
|
|
562
|
+
* - `pause`: Effects are cleaned up.
|
|
563
|
+
* - `none`: Screen renders normally
|
|
564
|
+
*
|
|
565
|
+
* Defaults to `pause`.
|
|
566
|
+
*
|
|
567
|
+
* If you set `lazy: false` or preload a screen,
|
|
568
|
+
* It won't be paused until after the first time it becomes focused.
|
|
569
|
+
* This makes sure that effects are run to initialize the screen.
|
|
570
|
+
*/
|
|
571
|
+
inactiveBehavior?: 'pause' | 'none';
|
|
623
572
|
} & HeaderOptions &
|
|
624
573
|
BottomTabNativeOptions &
|
|
625
574
|
BottomTabCustomOptions;
|
|
@@ -710,15 +659,6 @@ export type BottomTabNavigationConfig = {
|
|
|
710
659
|
* Function that returns a React element to display as the tab bar.
|
|
711
660
|
*/
|
|
712
661
|
tabBar?: (props: BottomTabBarProps) => React.ReactNode;
|
|
713
|
-
|
|
714
|
-
/**
|
|
715
|
-
* Whether inactive screens should be detached from the view hierarchy to save memory.
|
|
716
|
-
*
|
|
717
|
-
* Defaults to `true`.
|
|
718
|
-
*
|
|
719
|
-
* Only supported with `custom` implementation.
|
|
720
|
-
*/
|
|
721
|
-
detachInactiveScreens?: boolean;
|
|
722
662
|
};
|
|
723
663
|
|
|
724
664
|
export type BottomTabHeaderProps = {
|
|
@@ -746,7 +686,7 @@ export type BottomTabBarButtonProps = Omit<
|
|
|
746
686
|
React.ComponentProps<typeof PlatformPressable>,
|
|
747
687
|
'style'
|
|
748
688
|
> & {
|
|
749
|
-
href?: string;
|
|
689
|
+
href?: string | undefined;
|
|
750
690
|
children: React.ReactNode;
|
|
751
691
|
style?: StyleProp<ViewStyle>;
|
|
752
692
|
onPress?: (
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { BottomTabAnimationContext } from './BottomTabAnimationContext';
|
|
4
4
|
|
|
5
5
|
export function useBottomTabAnimation() {
|
|
6
|
-
const animation = React.
|
|
6
|
+
const animation = React.use(BottomTabAnimationContext);
|
|
7
7
|
|
|
8
8
|
if (animation === undefined) {
|
|
9
9
|
throw new Error(
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { BottomTabBarHeightContext } from './BottomTabBarHeightContext';
|
|
4
4
|
|
|
5
5
|
export function useBottomTabBarHeight() {
|
|
6
|
-
const height = React.
|
|
6
|
+
const height = React.use(BottomTabBarHeightContext);
|
|
7
7
|
|
|
8
8
|
if (height === undefined) {
|
|
9
9
|
throw new Error(
|
|
@@ -207,7 +207,7 @@ export function BottomTabBar({ state, navigation, descriptors, style }: Props) {
|
|
|
207
207
|
const insets = useSafeAreaInsets();
|
|
208
208
|
const isKeyboardShown = useIsKeyboardShown();
|
|
209
209
|
|
|
210
|
-
const onHeightChange = React.
|
|
210
|
+
const onHeightChange = React.use(BottomTabBarHeightCallbackContext);
|
|
211
211
|
|
|
212
212
|
const shouldShowTabBar = !(tabBarHideOnKeyboard && isKeyboardShown);
|
|
213
213
|
|
|
@@ -228,18 +228,22 @@ export function BottomTabBar({ state, navigation, descriptors, style }: Props) {
|
|
|
228
228
|
React.useEffect(() => {
|
|
229
229
|
const visibilityAnimationConfig = visibilityAnimationConfigRef.current;
|
|
230
230
|
|
|
231
|
+
let animation;
|
|
232
|
+
|
|
231
233
|
if (shouldShowTabBar) {
|
|
232
|
-
const
|
|
234
|
+
const animate =
|
|
233
235
|
visibilityAnimationConfig?.show?.animation === 'spring'
|
|
234
236
|
? Animated.spring
|
|
235
237
|
: Animated.timing;
|
|
236
238
|
|
|
237
|
-
animation(visible, {
|
|
239
|
+
animation = animate(visible, {
|
|
238
240
|
toValue: 1,
|
|
239
241
|
useNativeDriver,
|
|
240
242
|
duration: 250,
|
|
241
243
|
...visibilityAnimationConfig?.show?.config,
|
|
242
|
-
})
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
animation.start(({ finished }) => {
|
|
243
247
|
if (finished) {
|
|
244
248
|
setIsTabBarHidden(false);
|
|
245
249
|
}
|
|
@@ -248,20 +252,22 @@ export function BottomTabBar({ state, navigation, descriptors, style }: Props) {
|
|
|
248
252
|
// eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
|
|
249
253
|
setIsTabBarHidden(true);
|
|
250
254
|
|
|
251
|
-
const
|
|
255
|
+
const animate =
|
|
252
256
|
visibilityAnimationConfig?.hide?.animation === 'spring'
|
|
253
257
|
? Animated.spring
|
|
254
258
|
: Animated.timing;
|
|
255
259
|
|
|
256
|
-
animation(visible, {
|
|
260
|
+
animation = animate(visible, {
|
|
257
261
|
toValue: 0,
|
|
258
262
|
useNativeDriver,
|
|
259
263
|
duration: 200,
|
|
260
264
|
...visibilityAnimationConfig?.hide?.config,
|
|
261
|
-
})
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
animation.start();
|
|
262
268
|
}
|
|
263
269
|
|
|
264
|
-
return () =>
|
|
270
|
+
return () => animation.stop();
|
|
265
271
|
}, [visible, shouldShowTabBar]);
|
|
266
272
|
|
|
267
273
|
const [layout, setLayout] = React.useState({
|
|
@@ -343,7 +349,7 @@ export function BottomTabBar({ state, navigation, descriptors, style }: Props) {
|
|
|
343
349
|
: { borderTopWidth: StyleSheet.hairlineWidth },
|
|
344
350
|
{
|
|
345
351
|
backgroundColor:
|
|
346
|
-
tabBarBackgroundElement != null ? 'transparent' : colors.
|
|
352
|
+
tabBarBackgroundElement != null ? 'transparent' : colors.background,
|
|
347
353
|
borderColor: colors.border,
|
|
348
354
|
},
|
|
349
355
|
sidebar
|
|
@@ -409,7 +415,11 @@ export function BottomTabBar({ state, navigation, descriptors, style }: Props) {
|
|
|
409
415
|
canPreventDefault: true,
|
|
410
416
|
});
|
|
411
417
|
|
|
412
|
-
if (
|
|
418
|
+
if (
|
|
419
|
+
!focused &&
|
|
420
|
+
!event.defaultPrevented &&
|
|
421
|
+
options.tabBarSelectionEnabled !== false
|
|
422
|
+
) {
|
|
413
423
|
navigation.dispatch({
|
|
414
424
|
...CommonActions.navigate(route),
|
|
415
425
|
target: state.key,
|
|
@@ -435,8 +445,10 @@ export function BottomTabBar({ state, navigation, descriptors, style }: Props) {
|
|
|
435
445
|
const accessibilityLabel =
|
|
436
446
|
options.tabBarAccessibilityLabel !== undefined
|
|
437
447
|
? options.tabBarAccessibilityLabel
|
|
438
|
-
: typeof label === 'string'
|
|
439
|
-
?
|
|
448
|
+
: typeof label === 'string'
|
|
449
|
+
? Platform.OS === 'android'
|
|
450
|
+
? `${label}, ${index + 1} of ${routes.length}`
|
|
451
|
+
: `${label}, ${focused ? 'selected' : 'unselected'}`
|
|
440
452
|
: undefined;
|
|
441
453
|
|
|
442
454
|
return (
|
|
@@ -29,7 +29,7 @@ type Props = {
|
|
|
29
29
|
/**
|
|
30
30
|
* The `href` to use for the anchor tag on web
|
|
31
31
|
*/
|
|
32
|
-
href?: string;
|
|
32
|
+
href?: string | undefined;
|
|
33
33
|
/**
|
|
34
34
|
* Whether the tab is focused.
|
|
35
35
|
*/
|
|
@@ -56,23 +56,23 @@ type Props = {
|
|
|
56
56
|
/**
|
|
57
57
|
* Text to show in a badge on the tab icon.
|
|
58
58
|
*/
|
|
59
|
-
badge?: number | string;
|
|
59
|
+
badge?: number | string | undefined;
|
|
60
60
|
/**
|
|
61
61
|
* Custom style for the badge.
|
|
62
62
|
*/
|
|
63
|
-
badgeStyle?: StyleProp<TextStyle
|
|
63
|
+
badgeStyle?: StyleProp<TextStyle> | undefined;
|
|
64
64
|
/**
|
|
65
65
|
* The button for the tab. Uses a `Pressable` by default.
|
|
66
66
|
*/
|
|
67
|
-
button?: (props: BottomTabBarButtonProps) => React.ReactNode;
|
|
67
|
+
button?: ((props: BottomTabBarButtonProps) => React.ReactNode) | undefined;
|
|
68
68
|
/**
|
|
69
69
|
* The accessibility label for the tab.
|
|
70
70
|
*/
|
|
71
|
-
accessibilityLabel?: string;
|
|
71
|
+
accessibilityLabel?: string | undefined;
|
|
72
72
|
/**
|
|
73
73
|
* An unique ID for testing for the tab.
|
|
74
74
|
*/
|
|
75
|
-
testID?: string;
|
|
75
|
+
testID?: string | undefined;
|
|
76
76
|
/**
|
|
77
77
|
* Function to execute on press in React Native.
|
|
78
78
|
* On the web, this will use onClick.
|
|
@@ -105,44 +105,44 @@ type Props = {
|
|
|
105
105
|
/**
|
|
106
106
|
* Color for the icon and label when the item is active.
|
|
107
107
|
*/
|
|
108
|
-
activeTintColor?: ColorValue;
|
|
108
|
+
activeTintColor?: ColorValue | undefined;
|
|
109
109
|
/**
|
|
110
110
|
* Color for the icon and label when the item is inactive.
|
|
111
111
|
*/
|
|
112
|
-
inactiveTintColor?: ColorValue;
|
|
112
|
+
inactiveTintColor?: ColorValue | undefined;
|
|
113
113
|
/**
|
|
114
114
|
* Background color for item when its active.
|
|
115
115
|
*/
|
|
116
|
-
activeBackgroundColor?: ColorValue;
|
|
116
|
+
activeBackgroundColor?: ColorValue | undefined;
|
|
117
117
|
/**
|
|
118
118
|
* Background color for item when its inactive.
|
|
119
119
|
*/
|
|
120
|
-
inactiveBackgroundColor?: ColorValue;
|
|
120
|
+
inactiveBackgroundColor?: ColorValue | undefined;
|
|
121
121
|
/**
|
|
122
122
|
* Color of tab bar item's ripple effect.
|
|
123
123
|
*/
|
|
124
|
-
rippleColor?: ColorValue;
|
|
124
|
+
rippleColor?: ColorValue | undefined;
|
|
125
125
|
/**
|
|
126
126
|
* Label visibility mode for the tab bar item.
|
|
127
127
|
*/
|
|
128
|
-
labelVisibilityMode?: TabBarItemLabelVisibilityMode;
|
|
128
|
+
labelVisibilityMode?: TabBarItemLabelVisibilityMode | undefined;
|
|
129
129
|
/**
|
|
130
130
|
* Whether to allow scaling the font for the label for accessibility purposes.
|
|
131
131
|
* Defaults to `false` on iOS 13+ where it uses `largeContentTitle`.
|
|
132
132
|
*/
|
|
133
|
-
allowFontScaling?: boolean;
|
|
133
|
+
allowFontScaling?: boolean | undefined;
|
|
134
134
|
/**
|
|
135
135
|
* Style object for the label element.
|
|
136
136
|
*/
|
|
137
|
-
labelStyle?: StyleProp<TextStyle
|
|
137
|
+
labelStyle?: StyleProp<TextStyle> | undefined;
|
|
138
138
|
/**
|
|
139
139
|
* Style object for the icon element.
|
|
140
140
|
*/
|
|
141
|
-
iconStyle?: StyleProp<ViewStyle
|
|
141
|
+
iconStyle?: StyleProp<ViewStyle> | undefined;
|
|
142
142
|
/**
|
|
143
143
|
* Style object for the wrapper element.
|
|
144
144
|
*/
|
|
145
|
-
style?: StyleProp<ViewStyle
|
|
145
|
+
style?: StyleProp<ViewStyle> | undefined;
|
|
146
146
|
};
|
|
147
147
|
|
|
148
148
|
const renderButtonDefault = (props: BottomTabBarButtonProps) => (
|
|
@@ -189,9 +189,7 @@ export function BottomTabItem({
|
|
|
189
189
|
const activeTintColor: ColorValue =
|
|
190
190
|
customActiveTintColor ??
|
|
191
191
|
(variant === 'uikit' && sidebar && horizontal
|
|
192
|
-
? Color(colors.primary)
|
|
193
|
-
? 'white'
|
|
194
|
-
: (Color(colors.primary)?.darken(0.71).string() ?? 'white')
|
|
192
|
+
? Color.foreground(colors.primary)
|
|
195
193
|
: colors.primary);
|
|
196
194
|
|
|
197
195
|
const inactiveTintColor: ColorValue =
|