@react-navigation/bottom-tabs 6.5.7 → 7.0.0-alpha.1
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/index.js +12 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/navigators/createBottomTabNavigator.js +7 -47
- package/lib/commonjs/navigators/createBottomTabNavigator.js.map +1 -1
- package/lib/commonjs/utils/BottomTabBarHeightCallbackContext.js +3 -3
- package/lib/commonjs/utils/BottomTabBarHeightCallbackContext.js.map +1 -1
- package/lib/commonjs/utils/BottomTabBarHeightContext.js +3 -3
- package/lib/commonjs/utils/BottomTabBarHeightContext.js.map +1 -1
- package/lib/commonjs/utils/useBottomTabBarHeight.js +3 -4
- package/lib/commonjs/utils/useBottomTabBarHeight.js.map +1 -1
- package/lib/commonjs/utils/useIsKeyboardShown.js +1 -1
- package/lib/commonjs/utils/useIsKeyboardShown.js.map +1 -1
- package/lib/commonjs/views/Badge.js +7 -4
- package/lib/commonjs/views/Badge.js.map +1 -1
- package/lib/commonjs/views/BottomTabBar.js +13 -14
- package/lib/commonjs/views/BottomTabBar.js.map +1 -1
- package/lib/commonjs/views/BottomTabItem.js +15 -13
- package/lib/commonjs/views/BottomTabItem.js.map +1 -1
- package/lib/commonjs/views/BottomTabView.js +7 -8
- package/lib/commonjs/views/BottomTabView.js.map +1 -1
- package/lib/commonjs/views/TabBarIcon.js +3 -3
- package/lib/commonjs/views/TabBarIcon.js.map +1 -1
- package/lib/module/index.js +6 -6
- package/lib/module/index.js.map +1 -1
- package/lib/module/navigators/createBottomTabNavigator.js +4 -43
- package/lib/module/navigators/createBottomTabNavigator.js.map +1 -1
- package/lib/module/utils/BottomTabBarHeightCallbackContext.js +1 -1
- package/lib/module/utils/BottomTabBarHeightCallbackContext.js.map +1 -1
- package/lib/module/utils/BottomTabBarHeightContext.js +1 -1
- package/lib/module/utils/BottomTabBarHeightContext.js.map +1 -1
- package/lib/module/utils/useBottomTabBarHeight.js +2 -2
- package/lib/module/utils/useBottomTabBarHeight.js.map +1 -1
- package/lib/module/utils/useIsKeyboardShown.js +1 -1
- package/lib/module/utils/useIsKeyboardShown.js.map +1 -1
- package/lib/module/views/Badge.js +7 -4
- package/lib/module/views/Badge.js.map +1 -1
- package/lib/module/views/BottomTabBar.js +11 -12
- package/lib/module/views/BottomTabBar.js.map +1 -1
- package/lib/module/views/BottomTabItem.js +14 -12
- package/lib/module/views/BottomTabItem.js.map +1 -1
- package/lib/module/views/BottomTabView.js +4 -4
- package/lib/module/views/BottomTabView.js.map +1 -1
- package/lib/module/views/TabBarIcon.js +2 -2
- package/lib/module/views/TabBarIcon.js.map +1 -1
- package/lib/typescript/src/index.d.ts +6 -6
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts +9 -4
- package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +18 -18
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/BottomTabBarHeightCallbackContext.d.ts +1 -2
- package/lib/typescript/src/utils/BottomTabBarHeightCallbackContext.d.ts.map +1 -1
- package/lib/typescript/src/utils/BottomTabBarHeightContext.d.ts +1 -2
- package/lib/typescript/src/utils/BottomTabBarHeightContext.d.ts.map +1 -1
- package/lib/typescript/src/utils/useBottomTabBarHeight.d.ts +1 -1
- package/lib/typescript/src/utils/useBottomTabBarHeight.d.ts.map +1 -1
- package/lib/typescript/src/utils/useIsKeyboardShown.d.ts +1 -1
- package/lib/typescript/src/utils/useIsKeyboardShown.d.ts.map +1 -1
- package/lib/typescript/src/views/Badge.d.ts +2 -2
- package/lib/typescript/src/views/Badge.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabBar.d.ts +3 -3
- package/lib/typescript/src/views/BottomTabBar.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabItem.d.ts +10 -10
- package/lib/typescript/src/views/BottomTabItem.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabView.d.ts +2 -2
- package/lib/typescript/src/views/BottomTabView.d.ts.map +1 -1
- package/lib/typescript/src/views/ScreenFallback.d.ts +1 -1
- 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 +14 -15
- package/src/index.tsx +6 -6
- package/src/navigators/createBottomTabNavigator.tsx +3 -64
- package/src/types.tsx +2 -2
- package/src/utils/BottomTabBarHeightCallbackContext.tsx +3 -3
- package/src/utils/BottomTabBarHeightContext.tsx +3 -1
- package/src/utils/useBottomTabBarHeight.tsx +2 -2
- package/src/utils/useIsKeyboardShown.tsx +1 -1
- package/src/views/Badge.tsx +4 -3
- package/src/views/BottomTabBar.tsx +9 -9
- package/src/views/BottomTabItem.tsx +21 -19
- package/src/views/BottomTabView.tsx +4 -4
- package/src/views/TabBarIcon.tsx +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import BottomTabBarHeightContext from './BottomTabBarHeightContext';
|
|
3
|
+
import { BottomTabBarHeightContext } from './BottomTabBarHeightContext';
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export function useBottomTabBarHeight() {
|
|
6
6
|
const height = React.useContext(BottomTabBarHeightContext);
|
|
7
7
|
|
|
8
8
|
if (height === undefined) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { EmitterSubscription, Keyboard, Platform } from 'react-native';
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export function useIsKeyboardShown() {
|
|
5
5
|
const [isKeyboardShown, setIsKeyboardShown] = React.useState(false);
|
|
6
6
|
|
|
7
7
|
React.useEffect(() => {
|
package/src/views/Badge.tsx
CHANGED
|
@@ -22,7 +22,7 @@ type Props = {
|
|
|
22
22
|
style?: Animated.WithAnimatedValue<StyleProp<TextStyle>>;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
export
|
|
25
|
+
export function Badge({
|
|
26
26
|
children,
|
|
27
27
|
style,
|
|
28
28
|
visible = true,
|
|
@@ -32,7 +32,7 @@ export default function Badge({
|
|
|
32
32
|
const [opacity] = React.useState(() => new Animated.Value(visible ? 1 : 0));
|
|
33
33
|
const [rendered, setRendered] = React.useState(visible);
|
|
34
34
|
|
|
35
|
-
const
|
|
35
|
+
const { colors, fonts } = useTheme();
|
|
36
36
|
|
|
37
37
|
React.useEffect(() => {
|
|
38
38
|
if (!rendered) {
|
|
@@ -61,7 +61,7 @@ export default function Badge({
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
// @ts-expect-error: backgroundColor definitely exists
|
|
64
|
-
const { backgroundColor =
|
|
64
|
+
const { backgroundColor = colors.notification, ...restStyle } =
|
|
65
65
|
StyleSheet.flatten(style) || {};
|
|
66
66
|
const textColor = color(backgroundColor).isLight() ? 'black' : 'white';
|
|
67
67
|
|
|
@@ -90,6 +90,7 @@ export default function Badge({
|
|
|
90
90
|
fontSize,
|
|
91
91
|
borderRadius,
|
|
92
92
|
},
|
|
93
|
+
fonts.regular,
|
|
93
94
|
styles.container,
|
|
94
95
|
restStyle,
|
|
95
96
|
]}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
NavigationRouteContext,
|
|
6
6
|
ParamListBase,
|
|
7
7
|
TabNavigationState,
|
|
8
|
-
|
|
8
|
+
useLinkTools,
|
|
9
9
|
useTheme,
|
|
10
10
|
} from '@react-navigation/native';
|
|
11
11
|
import React from 'react';
|
|
@@ -21,9 +21,9 @@ import {
|
|
|
21
21
|
import { EdgeInsets, useSafeAreaFrame } from 'react-native-safe-area-context';
|
|
22
22
|
|
|
23
23
|
import type { BottomTabBarProps, BottomTabDescriptorMap } from '../types';
|
|
24
|
-
import BottomTabBarHeightCallbackContext from '../utils/BottomTabBarHeightCallbackContext';
|
|
25
|
-
import useIsKeyboardShown from '../utils/useIsKeyboardShown';
|
|
26
|
-
import BottomTabItem from './BottomTabItem';
|
|
24
|
+
import { BottomTabBarHeightCallbackContext } from '../utils/BottomTabBarHeightCallbackContext';
|
|
25
|
+
import { useIsKeyboardShown } from '../utils/useIsKeyboardShown';
|
|
26
|
+
import { BottomTabItem } from './BottomTabItem';
|
|
27
27
|
|
|
28
28
|
type Props = BottomTabBarProps & {
|
|
29
29
|
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
@@ -125,7 +125,7 @@ export const getTabBarHeight = ({
|
|
|
125
125
|
return DEFAULT_TABBAR_HEIGHT + paddingBottom;
|
|
126
126
|
};
|
|
127
127
|
|
|
128
|
-
export
|
|
128
|
+
export function BottomTabBar({
|
|
129
129
|
state,
|
|
130
130
|
navigation,
|
|
131
131
|
descriptors,
|
|
@@ -133,7 +133,7 @@ export default function BottomTabBar({
|
|
|
133
133
|
style,
|
|
134
134
|
}: Props) {
|
|
135
135
|
const { colors } = useTheme();
|
|
136
|
-
const
|
|
136
|
+
const { buildHref } = useLinkTools();
|
|
137
137
|
|
|
138
138
|
const focusedRoute = state.routes[state.index];
|
|
139
139
|
const focusedDescriptor = descriptors[focusedRoute.key];
|
|
@@ -305,7 +305,7 @@ export default function BottomTabBar({
|
|
|
305
305
|
|
|
306
306
|
if (!focused && !event.defaultPrevented) {
|
|
307
307
|
navigation.dispatch({
|
|
308
|
-
...CommonActions.navigate(
|
|
308
|
+
...CommonActions.navigate(route),
|
|
309
309
|
target: state.key,
|
|
310
310
|
});
|
|
311
311
|
}
|
|
@@ -339,6 +339,7 @@ export default function BottomTabBar({
|
|
|
339
339
|
>
|
|
340
340
|
<NavigationRouteContext.Provider value={route}>
|
|
341
341
|
<BottomTabItem
|
|
342
|
+
href={buildHref(route.name, route.params)}
|
|
342
343
|
route={route}
|
|
343
344
|
descriptor={descriptors[route.key]}
|
|
344
345
|
focused={focused}
|
|
@@ -346,8 +347,7 @@ export default function BottomTabBar({
|
|
|
346
347
|
onPress={onPress}
|
|
347
348
|
onLongPress={onLongPress}
|
|
348
349
|
accessibilityLabel={accessibilityLabel}
|
|
349
|
-
|
|
350
|
-
testID={options.tabBarTestID}
|
|
350
|
+
testID={options.tabBarButtonTestID}
|
|
351
351
|
allowFontScaling={options.tabBarAllowFontScaling}
|
|
352
352
|
activeTintColor={tabBarActiveTintColor}
|
|
353
353
|
inactiveTintColor={tabBarInactiveTintColor}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Link, Route, useTheme } from '@react-navigation/native';
|
|
1
|
+
import { CommonActions, Link, Route, useTheme } from '@react-navigation/native';
|
|
2
2
|
import Color from 'color';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import {
|
|
@@ -17,17 +17,21 @@ import type {
|
|
|
17
17
|
BottomTabDescriptor,
|
|
18
18
|
LabelPosition,
|
|
19
19
|
} from '../types';
|
|
20
|
-
import TabBarIcon from './TabBarIcon';
|
|
20
|
+
import { TabBarIcon } from './TabBarIcon';
|
|
21
21
|
|
|
22
22
|
type Props = {
|
|
23
|
-
/**
|
|
24
|
-
* Whether the tab is focused.
|
|
25
|
-
*/
|
|
26
|
-
focused: boolean;
|
|
27
23
|
/**
|
|
28
24
|
* The route object which should be specified by the tab.
|
|
29
25
|
*/
|
|
30
26
|
route: Route<string>;
|
|
27
|
+
/**
|
|
28
|
+
* The `href` to use for the anchor tag on web
|
|
29
|
+
*/
|
|
30
|
+
href?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the tab is focused.
|
|
33
|
+
*/
|
|
34
|
+
focused: boolean;
|
|
31
35
|
/**
|
|
32
36
|
* The descriptor object for the route.
|
|
33
37
|
*/
|
|
@@ -59,10 +63,6 @@ type Props = {
|
|
|
59
63
|
* Custom style for the badge.
|
|
60
64
|
*/
|
|
61
65
|
badgeStyle?: StyleProp<TextStyle>;
|
|
62
|
-
/**
|
|
63
|
-
* URL to use for the link to the tab.
|
|
64
|
-
*/
|
|
65
|
-
to?: string;
|
|
66
66
|
/**
|
|
67
67
|
* The button for the tab. Uses a `TouchableWithoutFeedback` by default.
|
|
68
68
|
*/
|
|
@@ -128,30 +128,31 @@ type Props = {
|
|
|
128
128
|
style?: StyleProp<ViewStyle>;
|
|
129
129
|
};
|
|
130
130
|
|
|
131
|
-
export
|
|
132
|
-
focused,
|
|
131
|
+
export function BottomTabItem({
|
|
133
132
|
route,
|
|
133
|
+
href,
|
|
134
|
+
focused,
|
|
134
135
|
descriptor,
|
|
135
136
|
label,
|
|
136
137
|
icon,
|
|
137
138
|
badge,
|
|
138
139
|
badgeStyle,
|
|
139
|
-
to,
|
|
140
140
|
button = ({
|
|
141
|
+
href,
|
|
141
142
|
children,
|
|
142
143
|
style,
|
|
143
144
|
onPress,
|
|
144
|
-
to,
|
|
145
145
|
accessibilityRole,
|
|
146
146
|
...rest
|
|
147
147
|
}: BottomTabBarButtonProps) => {
|
|
148
|
-
if (Platform.OS === 'web'
|
|
148
|
+
if (Platform.OS === 'web') {
|
|
149
149
|
// React Native Web doesn't forward `onClick` if we use `TouchableWithoutFeedback`.
|
|
150
150
|
// We need to use `onClick` to be able to prevent default browser handling of links.
|
|
151
151
|
return (
|
|
152
152
|
<Link
|
|
153
153
|
{...rest}
|
|
154
|
-
|
|
154
|
+
href={href}
|
|
155
|
+
action={CommonActions.navigate(route.name, route.params)}
|
|
155
156
|
style={[styles.button, style]}
|
|
156
157
|
onPress={(e: any) => {
|
|
157
158
|
if (
|
|
@@ -194,7 +195,7 @@ export default function BottomTabBarItem({
|
|
|
194
195
|
iconStyle,
|
|
195
196
|
style,
|
|
196
197
|
}: Props) {
|
|
197
|
-
const { colors } = useTheme();
|
|
198
|
+
const { colors, fonts } = useTheme();
|
|
198
199
|
|
|
199
200
|
const activeTintColor =
|
|
200
201
|
customActiveTintColor === undefined
|
|
@@ -218,8 +219,9 @@ export default function BottomTabBarItem({
|
|
|
218
219
|
<Text
|
|
219
220
|
numberOfLines={1}
|
|
220
221
|
style={[
|
|
221
|
-
styles.label,
|
|
222
222
|
{ color },
|
|
223
|
+
fonts.regular,
|
|
224
|
+
styles.label,
|
|
223
225
|
horizontal ? styles.labelBeside : styles.labelBeneath,
|
|
224
226
|
labelStyle,
|
|
225
227
|
]}
|
|
@@ -277,7 +279,7 @@ export default function BottomTabBarItem({
|
|
|
277
279
|
: inactiveBackgroundColor;
|
|
278
280
|
|
|
279
281
|
return button({
|
|
280
|
-
|
|
282
|
+
href,
|
|
281
283
|
onPress,
|
|
282
284
|
onLongPress,
|
|
283
285
|
testID,
|
|
@@ -20,9 +20,9 @@ import type {
|
|
|
20
20
|
BottomTabNavigationHelpers,
|
|
21
21
|
BottomTabNavigationProp,
|
|
22
22
|
} from '../types';
|
|
23
|
-
import BottomTabBarHeightCallbackContext from '../utils/BottomTabBarHeightCallbackContext';
|
|
24
|
-
import BottomTabBarHeightContext from '../utils/BottomTabBarHeightContext';
|
|
25
|
-
import BottomTabBar,
|
|
23
|
+
import { BottomTabBarHeightCallbackContext } from '../utils/BottomTabBarHeightCallbackContext';
|
|
24
|
+
import { BottomTabBarHeightContext } from '../utils/BottomTabBarHeightContext';
|
|
25
|
+
import { BottomTabBar, getTabBarHeight } from './BottomTabBar';
|
|
26
26
|
import { MaybeScreen, MaybeScreenContainer } from './ScreenFallback';
|
|
27
27
|
|
|
28
28
|
type Props = BottomTabNavigationConfig & {
|
|
@@ -31,7 +31,7 @@ type Props = BottomTabNavigationConfig & {
|
|
|
31
31
|
descriptors: BottomTabDescriptorMap;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
export
|
|
34
|
+
export function BottomTabView(props: Props) {
|
|
35
35
|
const {
|
|
36
36
|
tabBar = (props: BottomTabBarProps) => <BottomTabBar {...props} />,
|
|
37
37
|
state,
|
package/src/views/TabBarIcon.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
ViewStyle,
|
|
9
9
|
} from 'react-native';
|
|
10
10
|
|
|
11
|
-
import Badge from './Badge';
|
|
11
|
+
import { Badge } from './Badge';
|
|
12
12
|
|
|
13
13
|
type Props = {
|
|
14
14
|
route: Route<string>;
|
|
@@ -27,7 +27,7 @@ type Props = {
|
|
|
27
27
|
style: StyleProp<ViewStyle>;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
export
|
|
30
|
+
export function TabBarIcon({
|
|
31
31
|
route: _,
|
|
32
32
|
horizontal,
|
|
33
33
|
badge,
|