@react-navigation/bottom-tabs 7.0.0-rc.2 → 7.0.0-rc.21
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/commonjs/TransitionConfigs/TransitionPresets.js +2 -2
- package/lib/commonjs/index.js +9 -9
- package/lib/commonjs/navigators/createBottomTabNavigator.js +11 -11
- package/lib/commonjs/navigators/createBottomTabNavigator.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/utils/useBottomTabBarHeight.js +1 -1
- package/lib/commonjs/views/Badge.js +6 -4
- package/lib/commonjs/views/Badge.js.map +1 -1
- package/lib/commonjs/views/BottomTabBar.js +148 -118
- package/lib/commonjs/views/BottomTabBar.js.map +1 -1
- package/lib/commonjs/views/BottomTabItem.js +109 -63
- package/lib/commonjs/views/BottomTabItem.js.map +1 -1
- package/lib/commonjs/views/BottomTabView.js +108 -97
- package/lib/commonjs/views/BottomTabView.js.map +1 -1
- package/lib/commonjs/views/ScreenFallback.js +15 -9
- package/lib/commonjs/views/ScreenFallback.js.map +1 -1
- package/lib/commonjs/views/TabBarIcon.js +59 -37
- package/lib/commonjs/views/TabBarIcon.js.map +1 -1
- package/lib/module/TransitionConfigs/TransitionPresets.js +2 -2
- package/lib/module/TransitionConfigs/TransitionPresets.js.map +1 -1
- package/lib/module/index.js +9 -9
- package/lib/module/index.js.map +1 -1
- package/lib/module/navigators/createBottomTabNavigator.js +11 -9
- package/lib/module/navigators/createBottomTabNavigator.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/utils/useBottomTabBarHeight.js +1 -1
- package/lib/module/utils/useBottomTabBarHeight.js.map +1 -1
- package/lib/module/views/Badge.js +6 -4
- package/lib/module/views/Badge.js.map +1 -1
- package/lib/module/views/BottomTabBar.js +148 -118
- package/lib/module/views/BottomTabBar.js.map +1 -1
- package/lib/module/views/BottomTabItem.js +110 -64
- package/lib/module/views/BottomTabItem.js.map +1 -1
- package/lib/module/views/BottomTabView.js +108 -97
- package/lib/module/views/BottomTabView.js.map +1 -1
- package/lib/module/views/ScreenFallback.js +15 -9
- package/lib/module/views/ScreenFallback.js.map +1 -1
- package/lib/module/views/TabBarIcon.js +59 -37
- package/lib/module/views/TabBarIcon.js.map +1 -1
- package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts +2 -3
- package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +5 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/views/Badge.d.ts +1 -2
- package/lib/typescript/src/views/Badge.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabBar.d.ts +2 -3
- package/lib/typescript/src/views/BottomTabBar.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabItem.d.ts +9 -1
- package/lib/typescript/src/views/BottomTabItem.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabView.d.ts +1 -2
- package/lib/typescript/src/views/BottomTabView.d.ts.map +1 -1
- package/lib/typescript/src/views/ScreenFallback.d.ts +2 -2
- package/lib/typescript/src/views/ScreenFallback.d.ts.map +1 -1
- package/lib/typescript/src/views/TabBarIcon.d.ts +3 -2
- package/lib/typescript/src/views/TabBarIcon.d.ts.map +1 -1
- package/package.json +30 -14
- package/src/navigators/createBottomTabNavigator.tsx +1 -4
- package/src/types.tsx +7 -0
- package/src/views/BottomTabBar.tsx +90 -60
- package/src/views/BottomTabItem.tsx +156 -63
- package/src/views/TabBarIcon.tsx +55 -18
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
useLocale,
|
|
14
14
|
useTheme,
|
|
15
15
|
} from '@react-navigation/native';
|
|
16
|
-
import Color from 'color';
|
|
17
16
|
import React from 'react';
|
|
18
17
|
import {
|
|
19
18
|
Animated,
|
|
@@ -38,10 +37,11 @@ type Props = BottomTabBarProps & {
|
|
|
38
37
|
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
39
38
|
};
|
|
40
39
|
|
|
41
|
-
const
|
|
42
|
-
const
|
|
40
|
+
const TABBAR_HEIGHT_UIKIT = 49;
|
|
41
|
+
const TABBAR_HEIGHT_UIKIT_COMPACT = 32;
|
|
42
|
+
const SPACING_UIKIT = 15;
|
|
43
|
+
const SPACING_MATERIAL = 12;
|
|
43
44
|
const DEFAULT_MAX_TAB_ITEM_WIDTH = 125;
|
|
44
|
-
const SPACING = 5;
|
|
45
45
|
|
|
46
46
|
const useNativeDriver = Platform.OS !== 'web';
|
|
47
47
|
|
|
@@ -91,8 +91,36 @@ const shouldUseHorizontalLabels = ({
|
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
const
|
|
95
|
-
|
|
94
|
+
const isCompact = ({ state, descriptors, dimensions }: Options): boolean => {
|
|
95
|
+
const { tabBarPosition, tabBarVariant } =
|
|
96
|
+
descriptors[state.routes[state.index].key].options;
|
|
97
|
+
|
|
98
|
+
if (
|
|
99
|
+
tabBarPosition === 'left' ||
|
|
100
|
+
tabBarPosition === 'right' ||
|
|
101
|
+
tabBarVariant === 'material'
|
|
102
|
+
) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const isLandscape = dimensions.width > dimensions.height;
|
|
107
|
+
const horizontalLabels = shouldUseHorizontalLabels({
|
|
108
|
+
state,
|
|
109
|
+
descriptors,
|
|
110
|
+
dimensions,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
if (
|
|
114
|
+
Platform.OS === 'ios' &&
|
|
115
|
+
!Platform.isPad &&
|
|
116
|
+
isLandscape &&
|
|
117
|
+
horizontalLabels
|
|
118
|
+
) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return false;
|
|
123
|
+
};
|
|
96
124
|
|
|
97
125
|
export const getTabBarHeight = ({
|
|
98
126
|
state,
|
|
@@ -100,11 +128,12 @@ export const getTabBarHeight = ({
|
|
|
100
128
|
dimensions,
|
|
101
129
|
insets,
|
|
102
130
|
style,
|
|
103
|
-
...rest
|
|
104
131
|
}: Options & {
|
|
105
132
|
insets: EdgeInsets;
|
|
106
133
|
style: Animated.WithAnimatedValue<StyleProp<ViewStyle>> | undefined;
|
|
107
134
|
}) => {
|
|
135
|
+
const { tabBarPosition } = descriptors[state.routes[state.index].key].options;
|
|
136
|
+
|
|
108
137
|
const flattenedStyle = StyleSheet.flatten(style);
|
|
109
138
|
const customHeight =
|
|
110
139
|
flattenedStyle && 'height' in flattenedStyle
|
|
@@ -115,25 +144,13 @@ export const getTabBarHeight = ({
|
|
|
115
144
|
return customHeight;
|
|
116
145
|
}
|
|
117
146
|
|
|
118
|
-
const
|
|
119
|
-
const horizontalLabels = shouldUseHorizontalLabels({
|
|
120
|
-
state,
|
|
121
|
-
descriptors,
|
|
122
|
-
dimensions,
|
|
123
|
-
...rest,
|
|
124
|
-
});
|
|
125
|
-
const paddingBottom = getPaddingBottom(insets);
|
|
147
|
+
const inset = insets[tabBarPosition === 'top' ? 'top' : 'bottom'];
|
|
126
148
|
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
!Platform.isPad &&
|
|
130
|
-
isLandscape &&
|
|
131
|
-
horizontalLabels
|
|
132
|
-
) {
|
|
133
|
-
return COMPACT_TABBAR_HEIGHT + paddingBottom;
|
|
149
|
+
if (isCompact({ state, descriptors, dimensions })) {
|
|
150
|
+
return TABBAR_HEIGHT_UIKIT_COMPACT + inset;
|
|
134
151
|
}
|
|
135
152
|
|
|
136
|
-
return
|
|
153
|
+
return TABBAR_HEIGHT_UIKIT + inset;
|
|
137
154
|
};
|
|
138
155
|
|
|
139
156
|
export function BottomTabBar({
|
|
@@ -154,22 +171,38 @@ export function BottomTabBar({
|
|
|
154
171
|
const {
|
|
155
172
|
tabBarPosition = 'bottom',
|
|
156
173
|
tabBarShowLabel,
|
|
174
|
+
tabBarLabelPosition,
|
|
157
175
|
tabBarHideOnKeyboard = false,
|
|
158
176
|
tabBarVisibilityAnimationConfig,
|
|
177
|
+
tabBarVariant = 'uikit',
|
|
159
178
|
tabBarStyle,
|
|
160
179
|
tabBarBackground,
|
|
161
180
|
tabBarActiveTintColor,
|
|
162
181
|
tabBarInactiveTintColor,
|
|
163
|
-
tabBarActiveBackgroundColor
|
|
164
|
-
tabBarPosition !== 'top'
|
|
165
|
-
? Color(tabBarActiveTintColor ?? colors.primary)
|
|
166
|
-
.alpha(0.12)
|
|
167
|
-
.rgb()
|
|
168
|
-
.string()
|
|
169
|
-
: undefined,
|
|
182
|
+
tabBarActiveBackgroundColor,
|
|
170
183
|
tabBarInactiveBackgroundColor,
|
|
171
184
|
} = focusedOptions;
|
|
172
185
|
|
|
186
|
+
if (
|
|
187
|
+
tabBarVariant === 'material' &&
|
|
188
|
+
tabBarPosition !== 'left' &&
|
|
189
|
+
tabBarPosition !== 'right'
|
|
190
|
+
) {
|
|
191
|
+
throw new Error(
|
|
192
|
+
"The 'material' variant for tab bar is only supported when 'tabBarPosition' is set to 'left' or 'right'."
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (
|
|
197
|
+
tabBarLabelPosition === 'below-icon' &&
|
|
198
|
+
tabBarVariant === 'uikit' &&
|
|
199
|
+
(tabBarPosition === 'left' || tabBarPosition === 'right')
|
|
200
|
+
) {
|
|
201
|
+
throw new Error(
|
|
202
|
+
"The 'below-icon' label position for tab bar is only supported when 'tabBarPosition' is set to 'top' or 'bottom' when using the 'uikit' variant."
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
173
206
|
const dimensions = useSafeAreaFrame();
|
|
174
207
|
const isKeyboardShown = useIsKeyboardShown();
|
|
175
208
|
|
|
@@ -249,7 +282,6 @@ export function BottomTabBar({
|
|
|
249
282
|
|
|
250
283
|
const { routes } = state;
|
|
251
284
|
|
|
252
|
-
const paddingBottom = getPaddingBottom(insets);
|
|
253
285
|
const tabBarHeight = getTabBarHeight({
|
|
254
286
|
state,
|
|
255
287
|
descriptors,
|
|
@@ -264,7 +296,10 @@ export function BottomTabBar({
|
|
|
264
296
|
dimensions,
|
|
265
297
|
});
|
|
266
298
|
|
|
267
|
-
const
|
|
299
|
+
const compact = isCompact({ state, descriptors, dimensions });
|
|
300
|
+
const sidebar = tabBarPosition === 'left' || tabBarPosition === 'right';
|
|
301
|
+
const spacing =
|
|
302
|
+
tabBarVariant === 'material' ? SPACING_MATERIAL : SPACING_UIKIT;
|
|
268
303
|
|
|
269
304
|
const tabBarBackgroundElement = tabBarBackground?.();
|
|
270
305
|
|
|
@@ -298,14 +333,16 @@ export function BottomTabBar({
|
|
|
298
333
|
tabBarBackgroundElement != null ? 'transparent' : colors.card,
|
|
299
334
|
borderColor: colors.border,
|
|
300
335
|
},
|
|
301
|
-
|
|
336
|
+
sidebar
|
|
302
337
|
? {
|
|
303
|
-
paddingTop:
|
|
304
|
-
|
|
338
|
+
paddingTop:
|
|
339
|
+
(hasHorizontalLabels ? spacing : spacing / 2) + insets.top,
|
|
340
|
+
paddingBottom:
|
|
341
|
+
(hasHorizontalLabels ? spacing : spacing / 2) + insets.bottom,
|
|
305
342
|
paddingStart:
|
|
306
|
-
|
|
343
|
+
spacing + (tabBarPosition === 'left' ? insets.left : 0),
|
|
307
344
|
paddingEnd:
|
|
308
|
-
|
|
345
|
+
spacing + (tabBarPosition === 'right' ? insets.right : 0),
|
|
309
346
|
minWidth: hasHorizontalLabels
|
|
310
347
|
? getDefaultSidebarWidth(dimensions)
|
|
311
348
|
: 0,
|
|
@@ -318,7 +355,7 @@ export function BottomTabBar({
|
|
|
318
355
|
inputRange: [0, 1],
|
|
319
356
|
outputRange: [
|
|
320
357
|
layout.height +
|
|
321
|
-
|
|
358
|
+
insets[tabBarPosition === 'top' ? 'top' : 'bottom'] +
|
|
322
359
|
StyleSheet.hairlineWidth,
|
|
323
360
|
0,
|
|
324
361
|
],
|
|
@@ -331,21 +368,22 @@ export function BottomTabBar({
|
|
|
331
368
|
},
|
|
332
369
|
{
|
|
333
370
|
height: tabBarHeight,
|
|
334
|
-
paddingBottom,
|
|
371
|
+
paddingBottom: tabBarPosition === 'bottom' ? insets.bottom : 0,
|
|
372
|
+
paddingTop: tabBarPosition === 'top' ? insets.top : 0,
|
|
335
373
|
paddingHorizontal: Math.max(insets.left, insets.right),
|
|
336
374
|
},
|
|
337
375
|
],
|
|
338
376
|
tabBarStyle,
|
|
339
377
|
]}
|
|
340
378
|
pointerEvents={isTabBarHidden ? 'none' : 'auto'}
|
|
341
|
-
onLayout={
|
|
379
|
+
onLayout={sidebar ? undefined : handleLayout}
|
|
342
380
|
>
|
|
343
381
|
<View pointerEvents="none" style={StyleSheet.absoluteFill}>
|
|
344
382
|
{tabBarBackgroundElement}
|
|
345
383
|
</View>
|
|
346
384
|
<View
|
|
347
385
|
accessibilityRole="tablist"
|
|
348
|
-
style={
|
|
386
|
+
style={sidebar ? styles.sideContent : styles.bottomContent}
|
|
349
387
|
>
|
|
350
388
|
{routes.map((route, index) => {
|
|
351
389
|
const focused = index === state.index;
|
|
@@ -400,7 +438,9 @@ export function BottomTabBar({
|
|
|
400
438
|
descriptor={descriptors[route.key]}
|
|
401
439
|
focused={focused}
|
|
402
440
|
horizontal={hasHorizontalLabels}
|
|
403
|
-
|
|
441
|
+
compact={compact}
|
|
442
|
+
sidebar={sidebar}
|
|
443
|
+
variant={tabBarVariant}
|
|
404
444
|
onPress={onPress}
|
|
405
445
|
onLongPress={onLongPress}
|
|
406
446
|
accessibilityLabel={accessibilityLabel}
|
|
@@ -424,13 +464,14 @@ export function BottomTabBar({
|
|
|
424
464
|
labelStyle={options.tabBarLabelStyle}
|
|
425
465
|
iconStyle={options.tabBarIconStyle}
|
|
426
466
|
style={[
|
|
427
|
-
|
|
428
|
-
?
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
467
|
+
sidebar
|
|
468
|
+
? {
|
|
469
|
+
marginVertical: hasHorizontalLabels
|
|
470
|
+
? tabBarVariant === 'material'
|
|
471
|
+
? 0
|
|
472
|
+
: 1
|
|
473
|
+
: spacing / 2,
|
|
474
|
+
}
|
|
434
475
|
: styles.bottomItem,
|
|
435
476
|
options.tabBarItemStyle,
|
|
436
477
|
]}
|
|
@@ -472,15 +513,4 @@ const styles = StyleSheet.create({
|
|
|
472
513
|
bottomItem: {
|
|
473
514
|
flex: 1,
|
|
474
515
|
},
|
|
475
|
-
sideItem: {
|
|
476
|
-
margin: SPACING,
|
|
477
|
-
padding: SPACING * 2,
|
|
478
|
-
},
|
|
479
|
-
sideItemHorizontal: {
|
|
480
|
-
borderRadius: 56,
|
|
481
|
-
justifyContent: 'flex-start',
|
|
482
|
-
},
|
|
483
|
-
sideItemVertical: {
|
|
484
|
-
borderRadius: 16,
|
|
485
|
-
},
|
|
486
516
|
});
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type StyleProp,
|
|
9
9
|
StyleSheet,
|
|
10
10
|
type TextStyle,
|
|
11
|
+
View,
|
|
11
12
|
type ViewStyle,
|
|
12
13
|
} from 'react-native';
|
|
13
14
|
|
|
@@ -89,6 +90,14 @@ type Props = {
|
|
|
89
90
|
* Whether the label should be aligned with the icon horizontally.
|
|
90
91
|
*/
|
|
91
92
|
horizontal: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Whether to render the icon and label in compact mode.
|
|
95
|
+
*/
|
|
96
|
+
compact: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Whether the tab is an item in a side bar.
|
|
99
|
+
*/
|
|
100
|
+
sidebar: boolean;
|
|
92
101
|
/**
|
|
93
102
|
* Variant of navigation bar styling
|
|
94
103
|
* - `uikit`: iOS UIKit style
|
|
@@ -142,37 +151,18 @@ export function BottomTabItem({
|
|
|
142
151
|
icon,
|
|
143
152
|
badge,
|
|
144
153
|
badgeStyle,
|
|
145
|
-
button = ({
|
|
146
|
-
href,
|
|
147
|
-
children,
|
|
148
|
-
style,
|
|
149
|
-
onPress,
|
|
150
|
-
accessibilityRole,
|
|
151
|
-
...rest
|
|
152
|
-
}: BottomTabBarButtonProps) => {
|
|
153
|
-
return (
|
|
154
|
-
<PlatformPressable
|
|
155
|
-
{...rest}
|
|
156
|
-
android_ripple={{ borderless: true }}
|
|
157
|
-
pressOpacity={1}
|
|
158
|
-
href={href}
|
|
159
|
-
accessibilityRole={accessibilityRole}
|
|
160
|
-
onPress={onPress}
|
|
161
|
-
style={style}
|
|
162
|
-
>
|
|
163
|
-
{children}
|
|
164
|
-
</PlatformPressable>
|
|
165
|
-
);
|
|
166
|
-
},
|
|
154
|
+
button = (props: BottomTabBarButtonProps) => <PlatformPressable {...props} />,
|
|
167
155
|
accessibilityLabel,
|
|
168
156
|
testID,
|
|
169
157
|
onPress,
|
|
170
158
|
onLongPress,
|
|
171
159
|
horizontal,
|
|
160
|
+
compact,
|
|
161
|
+
sidebar,
|
|
172
162
|
variant,
|
|
173
163
|
activeTintColor: customActiveTintColor,
|
|
174
164
|
inactiveTintColor: customInactiveTintColor,
|
|
175
|
-
activeBackgroundColor
|
|
165
|
+
activeBackgroundColor: customActiveBackgroundColor,
|
|
176
166
|
inactiveBackgroundColor = 'transparent',
|
|
177
167
|
showLabel = true,
|
|
178
168
|
allowFontScaling,
|
|
@@ -183,21 +173,47 @@ export function BottomTabItem({
|
|
|
183
173
|
const { colors, fonts } = useTheme();
|
|
184
174
|
|
|
185
175
|
const activeTintColor =
|
|
186
|
-
customActiveTintColor
|
|
187
|
-
|
|
188
|
-
|
|
176
|
+
customActiveTintColor ??
|
|
177
|
+
(variant === 'uikit' && sidebar && horizontal
|
|
178
|
+
? Color(colors.primary).isDark()
|
|
179
|
+
? 'white'
|
|
180
|
+
: Color(colors.primary).darken(0.71).string()
|
|
181
|
+
: colors.primary);
|
|
189
182
|
|
|
190
183
|
const inactiveTintColor =
|
|
191
184
|
customInactiveTintColor === undefined
|
|
192
|
-
?
|
|
185
|
+
? variant === 'material'
|
|
186
|
+
? Color(colors.text).alpha(0.68).rgb().string()
|
|
187
|
+
: Color(colors.text).mix(Color(colors.card), 0.5).hex()
|
|
193
188
|
: customInactiveTintColor;
|
|
194
189
|
|
|
190
|
+
const activeBackgroundColor =
|
|
191
|
+
customActiveBackgroundColor ??
|
|
192
|
+
(variant === 'material'
|
|
193
|
+
? Color(activeTintColor).alpha(0.12).rgb().string()
|
|
194
|
+
: sidebar && horizontal
|
|
195
|
+
? colors.primary
|
|
196
|
+
: 'transparent');
|
|
197
|
+
|
|
198
|
+
let labelInactiveTintColor = inactiveTintColor;
|
|
199
|
+
let iconInactiveTintColor = inactiveTintColor;
|
|
200
|
+
|
|
201
|
+
if (
|
|
202
|
+
variant === 'uikit' &&
|
|
203
|
+
sidebar &&
|
|
204
|
+
horizontal &&
|
|
205
|
+
customInactiveTintColor === undefined
|
|
206
|
+
) {
|
|
207
|
+
iconInactiveTintColor = colors.primary;
|
|
208
|
+
labelInactiveTintColor = colors.text;
|
|
209
|
+
}
|
|
210
|
+
|
|
195
211
|
const renderLabel = ({ focused }: { focused: boolean }) => {
|
|
196
212
|
if (showLabel === false) {
|
|
197
213
|
return null;
|
|
198
214
|
}
|
|
199
215
|
|
|
200
|
-
const color = focused ? activeTintColor :
|
|
216
|
+
const color = focused ? activeTintColor : labelInactiveTintColor;
|
|
201
217
|
|
|
202
218
|
if (typeof label !== 'string') {
|
|
203
219
|
const { options } = descriptor;
|
|
@@ -226,11 +242,19 @@ export function BottomTabItem({
|
|
|
226
242
|
horizontal
|
|
227
243
|
? [
|
|
228
244
|
styles.labelBeside,
|
|
229
|
-
|
|
230
|
-
|
|
245
|
+
variant === 'material'
|
|
246
|
+
? styles.labelSidebarMaterial
|
|
247
|
+
: sidebar
|
|
248
|
+
? styles.labelSidebarUiKit
|
|
249
|
+
: compact
|
|
250
|
+
? styles.labelBesideUikitCompact
|
|
251
|
+
: styles.labelBesideUikit,
|
|
252
|
+
icon == null && { marginStart: 0 },
|
|
231
253
|
]
|
|
232
254
|
: styles.labelBeneath,
|
|
233
|
-
variant === '
|
|
255
|
+
compact || (variant === 'uikit' && sidebar && horizontal)
|
|
256
|
+
? fonts.regular
|
|
257
|
+
: fonts.medium,
|
|
234
258
|
labelStyle,
|
|
235
259
|
]}
|
|
236
260
|
allowFontScaling={allowFontScaling}
|
|
@@ -252,13 +276,14 @@ export function BottomTabItem({
|
|
|
252
276
|
return (
|
|
253
277
|
<TabBarIcon
|
|
254
278
|
route={route}
|
|
255
|
-
|
|
279
|
+
variant={variant}
|
|
280
|
+
size={compact ? 'compact' : 'regular'}
|
|
256
281
|
badge={badge}
|
|
257
282
|
badgeStyle={badgeStyle}
|
|
258
283
|
activeOpacity={activeOpacity}
|
|
259
284
|
inactiveOpacity={inactiveOpacity}
|
|
260
285
|
activeTintColor={activeTintColor}
|
|
261
|
-
inactiveTintColor={
|
|
286
|
+
inactiveTintColor={iconInactiveTintColor}
|
|
262
287
|
renderIcon={icon}
|
|
263
288
|
style={iconStyle}
|
|
264
289
|
/>
|
|
@@ -271,30 +296,70 @@ export function BottomTabItem({
|
|
|
271
296
|
? activeBackgroundColor
|
|
272
297
|
: inactiveBackgroundColor;
|
|
273
298
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
299
|
+
const { flex } = StyleSheet.flatten(style || {});
|
|
300
|
+
const borderRadius =
|
|
301
|
+
variant === 'material'
|
|
302
|
+
? horizontal
|
|
303
|
+
? 56
|
|
304
|
+
: 16
|
|
305
|
+
: sidebar && horizontal
|
|
306
|
+
? 10
|
|
307
|
+
: 0;
|
|
308
|
+
|
|
309
|
+
return (
|
|
310
|
+
<View
|
|
311
|
+
style={[
|
|
312
|
+
// Clip ripple effect on Android
|
|
313
|
+
{
|
|
314
|
+
borderRadius,
|
|
315
|
+
overflow: variant === 'material' ? 'hidden' : 'visible',
|
|
316
|
+
},
|
|
317
|
+
style,
|
|
318
|
+
]}
|
|
319
|
+
>
|
|
320
|
+
{button({
|
|
321
|
+
href,
|
|
322
|
+
onPress,
|
|
323
|
+
onLongPress,
|
|
324
|
+
testID,
|
|
325
|
+
accessibilityLabel,
|
|
326
|
+
// FIXME: accessibilityRole: 'tab' doesn't seem to work as expected on iOS
|
|
327
|
+
accessibilityRole: Platform.select({ ios: 'button', default: 'tab' }),
|
|
328
|
+
accessibilityState: { selected: focused },
|
|
329
|
+
// @ts-expect-error: keep for compatibility with older React Native versions
|
|
330
|
+
accessibilityStates: focused ? ['selected'] : [],
|
|
331
|
+
android_ripple: { borderless: true },
|
|
332
|
+
hoverEffect:
|
|
333
|
+
variant === 'material' || (sidebar && horizontal)
|
|
334
|
+
? { color: colors.text }
|
|
335
|
+
: undefined,
|
|
336
|
+
pressOpacity: 1,
|
|
337
|
+
style: [
|
|
338
|
+
styles.tab,
|
|
339
|
+
{ flex, backgroundColor, borderRadius },
|
|
340
|
+
sidebar
|
|
341
|
+
? variant === 'material'
|
|
342
|
+
? horizontal
|
|
343
|
+
? styles.tabBarSidebarMaterial
|
|
344
|
+
: styles.tabVerticalMaterial
|
|
345
|
+
: horizontal
|
|
346
|
+
? styles.tabBarSidebarUiKit
|
|
347
|
+
: styles.tabVerticalUiKit
|
|
348
|
+
: variant === 'material'
|
|
349
|
+
? styles.tabVerticalMaterial
|
|
350
|
+
: horizontal
|
|
351
|
+
? styles.tabHorizontalUiKit
|
|
352
|
+
: styles.tabVerticalUiKit,
|
|
353
|
+
],
|
|
354
|
+
children: (
|
|
355
|
+
<React.Fragment>
|
|
356
|
+
{renderIcon(scene)}
|
|
357
|
+
{renderLabel(scene)}
|
|
358
|
+
</React.Fragment>
|
|
359
|
+
),
|
|
360
|
+
})}
|
|
361
|
+
</View>
|
|
362
|
+
);
|
|
298
363
|
}
|
|
299
364
|
|
|
300
365
|
const styles = StyleSheet.create({
|
|
@@ -303,27 +368,55 @@ const styles = StyleSheet.create({
|
|
|
303
368
|
// Roundness for iPad hover effect
|
|
304
369
|
borderRadius: 10,
|
|
305
370
|
},
|
|
306
|
-
|
|
307
|
-
justifyContent: 'flex-
|
|
371
|
+
tabVerticalUiKit: {
|
|
372
|
+
justifyContent: 'flex-start',
|
|
308
373
|
flexDirection: 'column',
|
|
374
|
+
padding: 5,
|
|
309
375
|
},
|
|
310
|
-
|
|
376
|
+
tabVerticalMaterial: {
|
|
377
|
+
padding: 10,
|
|
378
|
+
},
|
|
379
|
+
tabHorizontalUiKit: {
|
|
311
380
|
justifyContent: 'center',
|
|
381
|
+
alignItems: 'center',
|
|
382
|
+
flexDirection: 'row',
|
|
383
|
+
padding: 5,
|
|
384
|
+
},
|
|
385
|
+
tabBarSidebarUiKit: {
|
|
386
|
+
justifyContent: 'flex-start',
|
|
387
|
+
alignItems: 'center',
|
|
312
388
|
flexDirection: 'row',
|
|
313
|
-
paddingVertical:
|
|
389
|
+
paddingVertical: 7,
|
|
390
|
+
paddingHorizontal: 5,
|
|
391
|
+
},
|
|
392
|
+
tabBarSidebarMaterial: {
|
|
393
|
+
justifyContent: 'flex-start',
|
|
394
|
+
alignItems: 'center',
|
|
395
|
+
flexDirection: 'row',
|
|
396
|
+
paddingVertical: 15,
|
|
314
397
|
paddingStart: 16,
|
|
315
398
|
paddingEnd: 24,
|
|
316
399
|
},
|
|
400
|
+
labelSidebarMaterial: {
|
|
401
|
+
marginStart: 12,
|
|
402
|
+
},
|
|
403
|
+
labelSidebarUiKit: {
|
|
404
|
+
fontSize: 17,
|
|
405
|
+
marginStart: 10,
|
|
406
|
+
},
|
|
317
407
|
labelBeneath: {
|
|
318
408
|
fontSize: 10,
|
|
319
409
|
},
|
|
320
410
|
labelBeside: {
|
|
321
411
|
marginEnd: 12,
|
|
322
|
-
marginVertical: 4,
|
|
323
412
|
lineHeight: 24,
|
|
324
|
-
marginStart: 20,
|
|
325
413
|
},
|
|
326
414
|
labelBesideUikit: {
|
|
327
415
|
fontSize: 13,
|
|
416
|
+
marginStart: 5,
|
|
417
|
+
},
|
|
418
|
+
labelBesideUikitCompact: {
|
|
419
|
+
fontSize: 12,
|
|
420
|
+
marginStart: 5,
|
|
328
421
|
},
|
|
329
422
|
});
|