@react-navigation/bottom-tabs 7.0.0-alpha.2 → 7.0.0-alpha.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/SceneStyleInterpolators.js +47 -0
- package/lib/commonjs/TransitionConfigs/SceneStyleInterpolators.js.map +1 -0
- package/lib/commonjs/TransitionConfigs/TransitionPresets.js +17 -0
- package/lib/commonjs/TransitionConfigs/TransitionPresets.js.map +1 -0
- package/lib/commonjs/TransitionConfigs/TransitionSpecs.js +22 -0
- package/lib/commonjs/TransitionConfigs/TransitionSpecs.js.map +1 -0
- package/lib/commonjs/index.js +9 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/navigators/createBottomTabNavigator.js +11 -6
- package/lib/commonjs/navigators/createBottomTabNavigator.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/BottomTabBarHeightCallbackContext.js +3 -4
- package/lib/commonjs/utils/BottomTabBarHeightCallbackContext.js.map +1 -1
- package/lib/commonjs/utils/BottomTabBarHeightContext.js +3 -4
- package/lib/commonjs/utils/BottomTabBarHeightContext.js.map +1 -1
- package/lib/commonjs/utils/useAnimatedHashMap.js +31 -0
- package/lib/commonjs/utils/useAnimatedHashMap.js.map +1 -0
- package/lib/commonjs/utils/useBottomTabBarHeight.js +2 -2
- package/lib/commonjs/utils/useBottomTabBarHeight.js.map +1 -1
- package/lib/commonjs/utils/useIsKeyboardShown.js +2 -2
- package/lib/commonjs/utils/useIsKeyboardShown.js.map +1 -1
- package/lib/commonjs/views/Badge.js +2 -2
- package/lib/commonjs/views/Badge.js.map +1 -1
- package/lib/commonjs/views/BottomTabBar.js +65 -27
- package/lib/commonjs/views/BottomTabBar.js.map +1 -1
- package/lib/commonjs/views/BottomTabItem.js +32 -54
- package/lib/commonjs/views/BottomTabItem.js.map +1 -1
- package/lib/commonjs/views/BottomTabView.js +120 -18
- package/lib/commonjs/views/BottomTabView.js.map +1 -1
- package/lib/commonjs/views/ScreenFallback.js +10 -14
- package/lib/commonjs/views/ScreenFallback.js.map +1 -1
- package/lib/commonjs/views/TabBarIcon.js +12 -17
- package/lib/commonjs/views/TabBarIcon.js.map +1 -1
- package/lib/module/TransitionConfigs/SceneStyleInterpolators.js +40 -0
- package/lib/module/TransitionConfigs/SceneStyleInterpolators.js.map +1 -0
- package/lib/module/TransitionConfigs/TransitionPresets.js +11 -0
- package/lib/module/TransitionConfigs/TransitionPresets.js.map +1 -0
- package/lib/module/TransitionConfigs/TransitionSpecs.js +16 -0
- package/lib/module/TransitionConfigs/TransitionSpecs.js.map +1 -0
- package/lib/module/index.js +9 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/navigators/createBottomTabNavigator.js +8 -2
- package/lib/module/navigators/createBottomTabNavigator.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/BottomTabBarHeightCallbackContext.js.map +1 -1
- package/lib/module/utils/BottomTabBarHeightContext.js.map +1 -1
- package/lib/module/utils/useAnimatedHashMap.js +23 -0
- package/lib/module/utils/useAnimatedHashMap.js.map +1 -0
- package/lib/module/utils/useBottomTabBarHeight.js.map +1 -1
- package/lib/module/utils/useIsKeyboardShown.js.map +1 -1
- package/lib/module/views/Badge.js.map +1 -1
- package/lib/module/views/BottomTabBar.js +68 -30
- package/lib/module/views/BottomTabBar.js.map +1 -1
- package/lib/module/views/BottomTabItem.js +34 -56
- package/lib/module/views/BottomTabItem.js.map +1 -1
- package/lib/module/views/BottomTabView.js +119 -17
- package/lib/module/views/BottomTabView.js.map +1 -1
- package/lib/module/views/ScreenFallback.js +8 -12
- package/lib/module/views/ScreenFallback.js.map +1 -1
- package/lib/module/views/TabBarIcon.js +12 -17
- package/lib/module/views/TabBarIcon.js.map +1 -1
- package/lib/typescript/src/TransitionConfigs/SceneStyleInterpolators.d.ts +10 -0
- package/lib/typescript/src/TransitionConfigs/SceneStyleInterpolators.d.ts.map +1 -0
- package/lib/typescript/src/TransitionConfigs/TransitionPresets.d.ts +4 -0
- package/lib/typescript/src/TransitionConfigs/TransitionPresets.d.ts.map +1 -0
- package/lib/typescript/src/TransitionConfigs/TransitionSpecs.d.ts +4 -0
- package/lib/typescript/src/TransitionConfigs/TransitionSpecs.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +8 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts +15 -9
- package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +71 -4
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/useAnimatedHashMap.d.ts +4 -0
- package/lib/typescript/src/utils/useAnimatedHashMap.d.ts.map +1 -0
- package/lib/typescript/src/views/Badge.d.ts +3 -2
- package/lib/typescript/src/views/Badge.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabBar.d.ts +5 -4
- package/lib/typescript/src/views/BottomTabBar.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabItem.d.ts +3 -3
- package/lib/typescript/src/views/BottomTabItem.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabView.d.ts +2 -1
- package/lib/typescript/src/views/BottomTabView.d.ts.map +1 -1
- package/lib/typescript/src/views/ScreenFallback.d.ts +5 -5
- package/lib/typescript/src/views/ScreenFallback.d.ts.map +1 -1
- package/lib/typescript/src/views/TabBarIcon.d.ts +2 -2
- package/lib/typescript/src/views/TabBarIcon.d.ts.map +1 -1
- package/package.json +17 -18
- package/src/TransitionConfigs/SceneStyleInterpolators.tsx +44 -0
- package/src/TransitionConfigs/TransitionPresets.tsx +13 -0
- package/src/TransitionConfigs/TransitionSpecs.tsx +19 -0
- package/src/index.tsx +10 -0
- package/src/navigators/createBottomTabNavigator.tsx +40 -12
- package/src/types.tsx +102 -5
- package/src/utils/useAnimatedHashMap.tsx +25 -0
- package/src/utils/useIsKeyboardShown.tsx +1 -1
- package/src/views/Badge.tsx +6 -1
- package/src/views/BottomTabBar.tsx +125 -47
- package/src/views/BottomTabItem.tsx +52 -82
- package/src/views/BottomTabView.tsx +163 -14
- package/src/views/ScreenFallback.tsx +12 -13
- package/src/views/TabBarIcon.tsx +16 -24
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { EmitterSubscription, Keyboard, Platform } from 'react-native';
|
|
2
|
+
import { type EmitterSubscription, Keyboard, Platform } from 'react-native';
|
|
3
3
|
|
|
4
4
|
export function useIsKeyboardShown() {
|
|
5
5
|
const [isKeyboardShown, setIsKeyboardShown] = React.useState(false);
|
package/src/views/Badge.tsx
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { useTheme } from '@react-navigation/native';
|
|
2
2
|
import color from 'color';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Animated,
|
|
6
|
+
type StyleProp,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
type TextStyle,
|
|
9
|
+
} from 'react-native';
|
|
5
10
|
|
|
6
11
|
type Props = {
|
|
7
12
|
/**
|
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getDefaultSidebarWidth,
|
|
3
|
+
getLabel,
|
|
4
|
+
MissingIcon,
|
|
5
|
+
} from '@react-navigation/elements';
|
|
2
6
|
import {
|
|
3
7
|
CommonActions,
|
|
4
8
|
NavigationContext,
|
|
5
9
|
NavigationRouteContext,
|
|
6
|
-
ParamListBase,
|
|
7
|
-
TabNavigationState,
|
|
8
|
-
|
|
10
|
+
type ParamListBase,
|
|
11
|
+
type TabNavigationState,
|
|
12
|
+
useLinkBuilder,
|
|
9
13
|
useTheme,
|
|
10
14
|
} from '@react-navigation/native';
|
|
15
|
+
import Color from 'color';
|
|
11
16
|
import React from 'react';
|
|
12
17
|
import {
|
|
13
18
|
Animated,
|
|
14
|
-
LayoutChangeEvent,
|
|
19
|
+
type LayoutChangeEvent,
|
|
15
20
|
Platform,
|
|
16
|
-
StyleProp,
|
|
21
|
+
type StyleProp,
|
|
17
22
|
StyleSheet,
|
|
23
|
+
useWindowDimensions,
|
|
18
24
|
View,
|
|
19
|
-
ViewStyle,
|
|
25
|
+
type ViewStyle,
|
|
20
26
|
} from 'react-native';
|
|
21
|
-
import { EdgeInsets
|
|
27
|
+
import type { EdgeInsets } from 'react-native-safe-area-context';
|
|
22
28
|
|
|
23
29
|
import type { BottomTabBarProps, BottomTabDescriptorMap } from '../types';
|
|
24
30
|
import { BottomTabBarHeightCallbackContext } from '../utils/BottomTabBarHeightCallbackContext';
|
|
@@ -32,6 +38,7 @@ type Props = BottomTabBarProps & {
|
|
|
32
38
|
const DEFAULT_TABBAR_HEIGHT = 49;
|
|
33
39
|
const COMPACT_TABBAR_HEIGHT = 32;
|
|
34
40
|
const DEFAULT_MAX_TAB_ITEM_WIDTH = 125;
|
|
41
|
+
const SPACING = 5;
|
|
35
42
|
|
|
36
43
|
const useNativeDriver = Platform.OS !== 'web';
|
|
37
44
|
|
|
@@ -97,8 +104,11 @@ export const getTabBarHeight = ({
|
|
|
97
104
|
insets: EdgeInsets;
|
|
98
105
|
style: Animated.WithAnimatedValue<StyleProp<ViewStyle>> | undefined;
|
|
99
106
|
}) => {
|
|
100
|
-
|
|
101
|
-
const customHeight =
|
|
107
|
+
const flattenedStyle = StyleSheet.flatten(style);
|
|
108
|
+
const customHeight =
|
|
109
|
+
flattenedStyle && 'height' in flattenedStyle
|
|
110
|
+
? flattenedStyle.height
|
|
111
|
+
: undefined;
|
|
102
112
|
|
|
103
113
|
if (typeof customHeight === 'number') {
|
|
104
114
|
return customHeight;
|
|
@@ -133,13 +143,14 @@ export function BottomTabBar({
|
|
|
133
143
|
style,
|
|
134
144
|
}: Props) {
|
|
135
145
|
const { colors } = useTheme();
|
|
136
|
-
const { buildHref } =
|
|
146
|
+
const { buildHref } = useLinkBuilder();
|
|
137
147
|
|
|
138
148
|
const focusedRoute = state.routes[state.index];
|
|
139
149
|
const focusedDescriptor = descriptors[focusedRoute.key];
|
|
140
150
|
const focusedOptions = focusedDescriptor.options;
|
|
141
151
|
|
|
142
152
|
const {
|
|
153
|
+
tabBarPosition = 'bottom',
|
|
143
154
|
tabBarShowLabel,
|
|
144
155
|
tabBarHideOnKeyboard = false,
|
|
145
156
|
tabBarVisibilityAnimationConfig,
|
|
@@ -147,11 +158,18 @@ export function BottomTabBar({
|
|
|
147
158
|
tabBarBackground,
|
|
148
159
|
tabBarActiveTintColor,
|
|
149
160
|
tabBarInactiveTintColor,
|
|
150
|
-
tabBarActiveBackgroundColor
|
|
161
|
+
tabBarActiveBackgroundColor = tabBarPosition !== 'bottom' &&
|
|
162
|
+
tabBarPosition !== 'top'
|
|
163
|
+
? Color(tabBarActiveTintColor ?? colors.primary)
|
|
164
|
+
.alpha(0.12)
|
|
165
|
+
.rgb()
|
|
166
|
+
.string()
|
|
167
|
+
: undefined,
|
|
151
168
|
tabBarInactiveBackgroundColor,
|
|
152
169
|
} = focusedOptions;
|
|
153
170
|
|
|
154
|
-
|
|
171
|
+
// FIXME: useSafeAreaFrame doesn't update values when window is resized on Web
|
|
172
|
+
const dimensions = useWindowDimensions();
|
|
155
173
|
const isKeyboardShown = useIsKeyboardShown();
|
|
156
174
|
|
|
157
175
|
const onHeightChange = React.useContext(BottomTabBarHeightCallbackContext);
|
|
@@ -253,45 +271,69 @@ export function BottomTabBar({
|
|
|
253
271
|
|
|
254
272
|
const tabBarBackgroundElement = tabBarBackground?.();
|
|
255
273
|
|
|
274
|
+
const tabBarIsHorizontal =
|
|
275
|
+
tabBarPosition === 'bottom' || tabBarPosition === 'top';
|
|
276
|
+
|
|
256
277
|
return (
|
|
257
278
|
<Animated.View
|
|
258
279
|
style={[
|
|
259
|
-
|
|
280
|
+
tabBarPosition === 'left'
|
|
281
|
+
? styles.start
|
|
282
|
+
: tabBarPosition === 'right'
|
|
283
|
+
? styles.end
|
|
284
|
+
: styles.bottom,
|
|
260
285
|
{
|
|
261
286
|
backgroundColor:
|
|
262
287
|
tabBarBackgroundElement != null ? 'transparent' : colors.card,
|
|
263
|
-
|
|
288
|
+
borderColor: colors.border,
|
|
264
289
|
},
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
290
|
+
tabBarIsHorizontal
|
|
291
|
+
? [
|
|
292
|
+
{
|
|
293
|
+
transform: [
|
|
294
|
+
{
|
|
295
|
+
translateY: visible.interpolate({
|
|
296
|
+
inputRange: [0, 1],
|
|
297
|
+
outputRange: [
|
|
298
|
+
layout.height +
|
|
299
|
+
paddingBottom +
|
|
300
|
+
StyleSheet.hairlineWidth,
|
|
301
|
+
0,
|
|
302
|
+
],
|
|
303
|
+
}),
|
|
304
|
+
},
|
|
273
305
|
],
|
|
274
|
-
|
|
306
|
+
// Absolutely position the tab bar so that the content is below it
|
|
307
|
+
// This is needed to avoid gap at bottom when the tab bar is hidden
|
|
308
|
+
position: isTabBarHidden ? 'absolute' : undefined,
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
height: tabBarHeight,
|
|
312
|
+
paddingBottom,
|
|
313
|
+
paddingHorizontal: Math.max(insets.left, insets.right),
|
|
314
|
+
},
|
|
315
|
+
]
|
|
316
|
+
: {
|
|
317
|
+
paddingTop: insets.top,
|
|
318
|
+
paddingBottom: insets.bottom,
|
|
319
|
+
paddingStart: tabBarPosition === 'left' ? insets.left : 0,
|
|
320
|
+
paddingEnd: tabBarPosition === 'right' ? insets.right : 0,
|
|
321
|
+
minWidth: hasHorizontalLabels
|
|
322
|
+
? getDefaultSidebarWidth(dimensions)
|
|
323
|
+
: 0,
|
|
275
324
|
},
|
|
276
|
-
],
|
|
277
|
-
// Absolutely position the tab bar so that the content is below it
|
|
278
|
-
// This is needed to avoid gap at bottom when the tab bar is hidden
|
|
279
|
-
position: isTabBarHidden ? 'absolute' : (null as any),
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
height: tabBarHeight,
|
|
283
|
-
paddingBottom,
|
|
284
|
-
paddingHorizontal: Math.max(insets.left, insets.right),
|
|
285
|
-
},
|
|
286
325
|
tabBarStyle,
|
|
287
326
|
]}
|
|
288
327
|
pointerEvents={isTabBarHidden ? 'none' : 'auto'}
|
|
289
|
-
onLayout={handleLayout}
|
|
328
|
+
onLayout={tabBarIsHorizontal ? handleLayout : undefined}
|
|
290
329
|
>
|
|
291
330
|
<View pointerEvents="none" style={StyleSheet.absoluteFill}>
|
|
292
331
|
{tabBarBackgroundElement}
|
|
293
332
|
</View>
|
|
294
|
-
<View
|
|
333
|
+
<View
|
|
334
|
+
accessibilityRole="tablist"
|
|
335
|
+
style={tabBarIsHorizontal ? styles.bottomContent : styles.sideContent}
|
|
336
|
+
>
|
|
295
337
|
{routes.map((route, index) => {
|
|
296
338
|
const focused = index === state.index;
|
|
297
339
|
const { options } = descriptors[route.key];
|
|
@@ -319,18 +361,19 @@ export function BottomTabBar({
|
|
|
319
361
|
};
|
|
320
362
|
|
|
321
363
|
const label =
|
|
322
|
-
options.tabBarLabel
|
|
364
|
+
typeof options.tabBarLabel === 'function'
|
|
323
365
|
? options.tabBarLabel
|
|
324
|
-
:
|
|
325
|
-
|
|
326
|
-
|
|
366
|
+
: getLabel(
|
|
367
|
+
{ label: options.tabBarLabel, title: options.title },
|
|
368
|
+
route.name
|
|
369
|
+
);
|
|
327
370
|
|
|
328
371
|
const accessibilityLabel =
|
|
329
372
|
options.tabBarAccessibilityLabel !== undefined
|
|
330
373
|
? options.tabBarAccessibilityLabel
|
|
331
374
|
: typeof label === 'string' && Platform.OS === 'ios'
|
|
332
|
-
|
|
333
|
-
|
|
375
|
+
? `${label}, tab, ${index + 1} of ${routes.length}`
|
|
376
|
+
: undefined;
|
|
334
377
|
|
|
335
378
|
return (
|
|
336
379
|
<NavigationContext.Provider
|
|
@@ -366,7 +409,17 @@ export function BottomTabBar({
|
|
|
366
409
|
showLabel={tabBarShowLabel}
|
|
367
410
|
labelStyle={options.tabBarLabelStyle}
|
|
368
411
|
iconStyle={options.tabBarIconStyle}
|
|
369
|
-
style={
|
|
412
|
+
style={[
|
|
413
|
+
tabBarIsHorizontal
|
|
414
|
+
? styles.bottomItem
|
|
415
|
+
: [
|
|
416
|
+
styles.sideItem,
|
|
417
|
+
hasHorizontalLabels
|
|
418
|
+
? { justifyContent: 'flex-start' }
|
|
419
|
+
: null,
|
|
420
|
+
],
|
|
421
|
+
options.tabBarItemStyle,
|
|
422
|
+
]}
|
|
370
423
|
/>
|
|
371
424
|
</NavigationRouteContext.Provider>
|
|
372
425
|
</NavigationContext.Provider>
|
|
@@ -378,15 +431,40 @@ export function BottomTabBar({
|
|
|
378
431
|
}
|
|
379
432
|
|
|
380
433
|
const styles = StyleSheet.create({
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
434
|
+
start: {
|
|
435
|
+
top: 0,
|
|
436
|
+
bottom: 0,
|
|
437
|
+
start: 0,
|
|
438
|
+
borderEndWidth: StyleSheet.hairlineWidth,
|
|
439
|
+
},
|
|
440
|
+
end: {
|
|
441
|
+
top: 0,
|
|
442
|
+
bottom: 0,
|
|
443
|
+
end: 0,
|
|
444
|
+
borderStartWidth: StyleSheet.hairlineWidth,
|
|
445
|
+
},
|
|
446
|
+
bottom: {
|
|
447
|
+
start: 0,
|
|
448
|
+
end: 0,
|
|
384
449
|
bottom: 0,
|
|
385
450
|
borderTopWidth: StyleSheet.hairlineWidth,
|
|
386
451
|
elevation: 8,
|
|
387
452
|
},
|
|
388
|
-
|
|
453
|
+
bottomContent: {
|
|
389
454
|
flex: 1,
|
|
390
455
|
flexDirection: 'row',
|
|
391
456
|
},
|
|
457
|
+
sideContent: {
|
|
458
|
+
flex: 1,
|
|
459
|
+
flexDirection: 'column',
|
|
460
|
+
padding: SPACING,
|
|
461
|
+
},
|
|
462
|
+
bottomItem: {
|
|
463
|
+
flex: 1,
|
|
464
|
+
},
|
|
465
|
+
sideItem: {
|
|
466
|
+
margin: SPACING,
|
|
467
|
+
padding: SPACING * 2,
|
|
468
|
+
borderRadius: 4,
|
|
469
|
+
},
|
|
392
470
|
});
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getLabel, Label, PlatformPressable } from '@react-navigation/elements';
|
|
2
|
+
import { type Route, useTheme } from '@react-navigation/native';
|
|
2
3
|
import Color from 'color';
|
|
3
4
|
import React from 'react';
|
|
4
5
|
import {
|
|
5
|
-
GestureResponderEvent,
|
|
6
|
+
type GestureResponderEvent,
|
|
6
7
|
Platform,
|
|
7
|
-
|
|
8
|
-
StyleProp,
|
|
8
|
+
type StyleProp,
|
|
9
9
|
StyleSheet,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
ViewStyle,
|
|
10
|
+
type TextStyle,
|
|
11
|
+
type ViewStyle,
|
|
13
12
|
} from 'react-native';
|
|
14
13
|
|
|
15
14
|
import type {
|
|
@@ -64,7 +63,7 @@ type Props = {
|
|
|
64
63
|
*/
|
|
65
64
|
badgeStyle?: StyleProp<TextStyle>;
|
|
66
65
|
/**
|
|
67
|
-
* The button for the tab. Uses a `
|
|
66
|
+
* The button for the tab. Uses a `Pressable` by default.
|
|
68
67
|
*/
|
|
69
68
|
button?: (props: BottomTabBarButtonProps) => React.ReactNode;
|
|
70
69
|
/**
|
|
@@ -145,40 +144,19 @@ export function BottomTabItem({
|
|
|
145
144
|
accessibilityRole,
|
|
146
145
|
...rest
|
|
147
146
|
}: BottomTabBarButtonProps) => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
) {
|
|
162
|
-
e.preventDefault();
|
|
163
|
-
onPress?.(e);
|
|
164
|
-
}
|
|
165
|
-
}}
|
|
166
|
-
>
|
|
167
|
-
{children}
|
|
168
|
-
</Link>
|
|
169
|
-
);
|
|
170
|
-
} else {
|
|
171
|
-
return (
|
|
172
|
-
<Pressable
|
|
173
|
-
{...rest}
|
|
174
|
-
accessibilityRole={accessibilityRole}
|
|
175
|
-
onPress={onPress}
|
|
176
|
-
style={style}
|
|
177
|
-
>
|
|
178
|
-
{children}
|
|
179
|
-
</Pressable>
|
|
180
|
-
);
|
|
181
|
-
}
|
|
147
|
+
return (
|
|
148
|
+
<PlatformPressable
|
|
149
|
+
{...rest}
|
|
150
|
+
android_ripple={{ borderless: true }}
|
|
151
|
+
pressOpacity={1}
|
|
152
|
+
href={href}
|
|
153
|
+
accessibilityRole={accessibilityRole}
|
|
154
|
+
onPress={onPress}
|
|
155
|
+
style={style}
|
|
156
|
+
>
|
|
157
|
+
{children}
|
|
158
|
+
</PlatformPressable>
|
|
159
|
+
);
|
|
182
160
|
},
|
|
183
161
|
accessibilityLabel,
|
|
184
162
|
testID,
|
|
@@ -195,7 +173,7 @@ export function BottomTabItem({
|
|
|
195
173
|
iconStyle,
|
|
196
174
|
style,
|
|
197
175
|
}: Props) {
|
|
198
|
-
const { colors
|
|
176
|
+
const { colors } = useTheme();
|
|
199
177
|
|
|
200
178
|
const activeTintColor =
|
|
201
179
|
customActiveTintColor === undefined
|
|
@@ -214,38 +192,39 @@ export function BottomTabItem({
|
|
|
214
192
|
|
|
215
193
|
const color = focused ? activeTintColor : inactiveTintColor;
|
|
216
194
|
|
|
217
|
-
if (typeof label
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
allowFontScaling={allowFontScaling}
|
|
229
|
-
>
|
|
230
|
-
{label}
|
|
231
|
-
</Text>
|
|
195
|
+
if (typeof label !== 'string') {
|
|
196
|
+
const { options } = descriptor;
|
|
197
|
+
const children = getLabel(
|
|
198
|
+
{
|
|
199
|
+
label:
|
|
200
|
+
typeof options.tabBarLabel === 'string'
|
|
201
|
+
? options.tabBarLabel
|
|
202
|
+
: undefined,
|
|
203
|
+
title: options.title,
|
|
204
|
+
},
|
|
205
|
+
route.name
|
|
232
206
|
);
|
|
233
|
-
}
|
|
234
207
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
?
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
208
|
+
return label({
|
|
209
|
+
focused,
|
|
210
|
+
color,
|
|
211
|
+
position: horizontal ? 'beside-icon' : 'below-icon',
|
|
212
|
+
children,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
242
215
|
|
|
243
|
-
return
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
216
|
+
return (
|
|
217
|
+
<Label
|
|
218
|
+
style={[
|
|
219
|
+
horizontal ? styles.labelBeside : styles.labelBeneath,
|
|
220
|
+
labelStyle,
|
|
221
|
+
]}
|
|
222
|
+
allowFontScaling={allowFontScaling}
|
|
223
|
+
tintColor={color}
|
|
224
|
+
>
|
|
225
|
+
{label}
|
|
226
|
+
</Label>
|
|
227
|
+
);
|
|
249
228
|
};
|
|
250
229
|
|
|
251
230
|
const renderIcon = ({ focused }: { focused: boolean }) => {
|
|
@@ -306,7 +285,6 @@ export function BottomTabItem({
|
|
|
306
285
|
|
|
307
286
|
const styles = StyleSheet.create({
|
|
308
287
|
tab: {
|
|
309
|
-
flex: 1,
|
|
310
288
|
alignItems: 'center',
|
|
311
289
|
},
|
|
312
290
|
tabPortrait: {
|
|
@@ -317,19 +295,11 @@ const styles = StyleSheet.create({
|
|
|
317
295
|
justifyContent: 'center',
|
|
318
296
|
flexDirection: 'row',
|
|
319
297
|
},
|
|
320
|
-
label: {
|
|
321
|
-
textAlign: 'center',
|
|
322
|
-
backgroundColor: 'transparent',
|
|
323
|
-
},
|
|
324
298
|
labelBeneath: {
|
|
325
299
|
fontSize: 10,
|
|
326
300
|
},
|
|
327
301
|
labelBeside: {
|
|
328
302
|
fontSize: 13,
|
|
329
|
-
|
|
330
|
-
marginTop: 3,
|
|
331
|
-
},
|
|
332
|
-
button: {
|
|
333
|
-
display: 'flex',
|
|
303
|
+
marginStart: 20,
|
|
334
304
|
},
|
|
335
305
|
});
|