@react-navigation/bottom-tabs 7.0.0-alpha.4 → 7.0.0-alpha.6

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.
Files changed (82) hide show
  1. package/lib/commonjs/TransitionConfigs/SceneStyleInterpolators.js +1 -1
  2. package/lib/commonjs/TransitionConfigs/SceneStyleInterpolators.js.map +1 -1
  3. package/lib/commonjs/TransitionConfigs/TransitionPresets.js +2 -4
  4. package/lib/commonjs/TransitionConfigs/TransitionPresets.js.map +1 -1
  5. package/lib/commonjs/TransitionConfigs/TransitionSpecs.js +2 -4
  6. package/lib/commonjs/TransitionConfigs/TransitionSpecs.js.map +1 -1
  7. package/lib/commonjs/index.js +2 -2
  8. package/lib/commonjs/index.js.map +1 -1
  9. package/lib/commonjs/navigators/createBottomTabNavigator.js +5 -4
  10. package/lib/commonjs/navigators/createBottomTabNavigator.js.map +1 -1
  11. package/lib/commonjs/types.js.map +1 -1
  12. package/lib/commonjs/utils/BottomTabBarHeightCallbackContext.js +3 -4
  13. package/lib/commonjs/utils/BottomTabBarHeightCallbackContext.js.map +1 -1
  14. package/lib/commonjs/utils/BottomTabBarHeightContext.js +3 -4
  15. package/lib/commonjs/utils/BottomTabBarHeightContext.js.map +1 -1
  16. package/lib/commonjs/utils/useAnimatedHashMap.js +2 -2
  17. package/lib/commonjs/utils/useAnimatedHashMap.js.map +1 -1
  18. package/lib/commonjs/utils/useBottomTabBarHeight.js +2 -2
  19. package/lib/commonjs/utils/useBottomTabBarHeight.js.map +1 -1
  20. package/lib/commonjs/utils/useIsKeyboardShown.js +2 -2
  21. package/lib/commonjs/utils/useIsKeyboardShown.js.map +1 -1
  22. package/lib/commonjs/views/Badge.js +2 -2
  23. package/lib/commonjs/views/Badge.js.map +1 -1
  24. package/lib/commonjs/views/BottomTabBar.js +8 -11
  25. package/lib/commonjs/views/BottomTabBar.js.map +1 -1
  26. package/lib/commonjs/views/BottomTabItem.js +12 -28
  27. package/lib/commonjs/views/BottomTabItem.js.map +1 -1
  28. package/lib/commonjs/views/BottomTabView.js +8 -9
  29. package/lib/commonjs/views/BottomTabView.js.map +1 -1
  30. package/lib/commonjs/views/ScreenFallback.js +4 -6
  31. package/lib/commonjs/views/ScreenFallback.js.map +1 -1
  32. package/lib/commonjs/views/TabBarIcon.js.map +1 -1
  33. package/lib/module/TransitionConfigs/SceneStyleInterpolators.js +1 -1
  34. package/lib/module/TransitionConfigs/SceneStyleInterpolators.js.map +1 -1
  35. package/lib/module/TransitionConfigs/TransitionPresets.js.map +1 -1
  36. package/lib/module/TransitionConfigs/TransitionSpecs.js.map +1 -1
  37. package/lib/module/index.js.map +1 -1
  38. package/lib/module/navigators/createBottomTabNavigator.js +2 -0
  39. package/lib/module/navigators/createBottomTabNavigator.js.map +1 -1
  40. package/lib/module/types.js.map +1 -1
  41. package/lib/module/utils/BottomTabBarHeightCallbackContext.js.map +1 -1
  42. package/lib/module/utils/BottomTabBarHeightContext.js.map +1 -1
  43. package/lib/module/utils/useAnimatedHashMap.js.map +1 -1
  44. package/lib/module/utils/useBottomTabBarHeight.js.map +1 -1
  45. package/lib/module/utils/useIsKeyboardShown.js.map +1 -1
  46. package/lib/module/views/Badge.js.map +1 -1
  47. package/lib/module/views/BottomTabBar.js +8 -11
  48. package/lib/module/views/BottomTabBar.js.map +1 -1
  49. package/lib/module/views/BottomTabItem.js +15 -31
  50. package/lib/module/views/BottomTabItem.js.map +1 -1
  51. package/lib/module/views/BottomTabView.js +6 -7
  52. package/lib/module/views/BottomTabView.js.map +1 -1
  53. package/lib/module/views/ScreenFallback.js +2 -4
  54. package/lib/module/views/ScreenFallback.js.map +1 -1
  55. package/lib/module/views/TabBarIcon.js.map +1 -1
  56. package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts +4 -3
  57. package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts.map +1 -1
  58. package/lib/typescript/src/types.d.ts +3 -3
  59. package/lib/typescript/src/types.d.ts.map +1 -1
  60. package/lib/typescript/src/views/Badge.d.ts +3 -2
  61. package/lib/typescript/src/views/Badge.d.ts.map +1 -1
  62. package/lib/typescript/src/views/BottomTabBar.d.ts +4 -3
  63. package/lib/typescript/src/views/BottomTabBar.d.ts.map +1 -1
  64. package/lib/typescript/src/views/BottomTabItem.d.ts +3 -3
  65. package/lib/typescript/src/views/BottomTabItem.d.ts.map +1 -1
  66. package/lib/typescript/src/views/BottomTabView.d.ts +2 -1
  67. package/lib/typescript/src/views/BottomTabView.d.ts.map +1 -1
  68. package/lib/typescript/src/views/ScreenFallback.d.ts +3 -3
  69. package/lib/typescript/src/views/ScreenFallback.d.ts.map +1 -1
  70. package/lib/typescript/src/views/TabBarIcon.d.ts +2 -2
  71. package/lib/typescript/src/views/TabBarIcon.d.ts.map +1 -1
  72. package/package.json +16 -17
  73. package/src/TransitionConfigs/SceneStyleInterpolators.tsx +1 -1
  74. package/src/navigators/createBottomTabNavigator.tsx +7 -5
  75. package/src/types.tsx +7 -5
  76. package/src/utils/useIsKeyboardShown.tsx +1 -1
  77. package/src/views/Badge.tsx +6 -1
  78. package/src/views/BottomTabBar.tsx +10 -7
  79. package/src/views/BottomTabItem.tsx +21 -45
  80. package/src/views/BottomTabView.tsx +1 -2
  81. package/src/views/ScreenFallback.tsx +7 -1
  82. package/src/views/TabBarIcon.tsx +3 -3
@@ -7,8 +7,8 @@ import {
7
7
  CommonActions,
8
8
  NavigationContext,
9
9
  NavigationRouteContext,
10
- ParamListBase,
11
- TabNavigationState,
10
+ type ParamListBase,
11
+ type TabNavigationState,
12
12
  useLinkTools,
13
13
  useTheme,
14
14
  } from '@react-navigation/native';
@@ -16,13 +16,13 @@ import Color from 'color';
16
16
  import React from 'react';
17
17
  import {
18
18
  Animated,
19
- LayoutChangeEvent,
19
+ type LayoutChangeEvent,
20
20
  Platform,
21
- StyleProp,
21
+ type StyleProp,
22
22
  StyleSheet,
23
23
  useWindowDimensions,
24
24
  View,
25
- ViewStyle,
25
+ type ViewStyle,
26
26
  } from 'react-native';
27
27
  import type { EdgeInsets } from 'react-native-safe-area-context';
28
28
 
@@ -104,8 +104,11 @@ export const getTabBarHeight = ({
104
104
  insets: EdgeInsets;
105
105
  style: Animated.WithAnimatedValue<StyleProp<ViewStyle>> | undefined;
106
106
  }) => {
107
- // @ts-ignore
108
- const customHeight = StyleSheet.flatten(style)?.height;
107
+ const flattenedStyle = StyleSheet.flatten(style);
108
+ const customHeight =
109
+ flattenedStyle && 'height' in flattenedStyle
110
+ ? flattenedStyle.height
111
+ : undefined;
109
112
 
110
113
  if (typeof customHeight === 'number') {
111
114
  return customHeight;
@@ -1,15 +1,14 @@
1
- import { getLabel, Label } from '@react-navigation/elements';
2
- import { CommonActions, Link, Route, useTheme } from '@react-navigation/native';
1
+ import { getLabel, Label, PlatformPressable } from '@react-navigation/elements';
2
+ import { type Route, useTheme } from '@react-navigation/native';
3
3
  import Color from 'color';
4
4
  import React from 'react';
5
5
  import {
6
- GestureResponderEvent,
6
+ type GestureResponderEvent,
7
7
  Platform,
8
- Pressable,
9
- StyleProp,
8
+ type StyleProp,
10
9
  StyleSheet,
11
- TextStyle,
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 `TouchableWithoutFeedback` by default.
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
- if (Platform.OS === 'web') {
149
- // React Native Web doesn't forward `onClick` if we use `TouchableWithoutFeedback`.
150
- // We need to use `onClick` to be able to prevent default browser handling of links.
151
- return (
152
- <Link
153
- {...rest}
154
- href={href}
155
- action={CommonActions.navigate(route.name, route.params)}
156
- style={[styles.button, style]}
157
- onPress={(e: any) => {
158
- if (
159
- !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && // ignore clicks with modifier keys
160
- (e.button == null || e.button === 0) // ignore everything but left clicks
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,
@@ -242,6 +220,7 @@ export function BottomTabItem({
242
220
  labelStyle,
243
221
  ]}
244
222
  allowFontScaling={allowFontScaling}
223
+ tintColor={color}
245
224
  >
246
225
  {label}
247
226
  </Label>
@@ -323,7 +302,4 @@ const styles = StyleSheet.create({
323
302
  fontSize: 13,
324
303
  marginLeft: 20,
325
304
  },
326
- button: {
327
- display: 'flex',
328
- },
329
305
  });
@@ -26,7 +26,6 @@ import { BottomTabBarHeightContext } from '../utils/BottomTabBarHeightContext';
26
26
  import { useAnimatedHashMap } from '../utils/useAnimatedHashMap';
27
27
  import { BottomTabBar, getTabBarHeight } from './BottomTabBar';
28
28
  import { MaybeScreen, MaybeScreenContainer } from './ScreenFallback';
29
- import CompositeAnimation = Animated.CompositeAnimation;
30
29
 
31
30
  type Props = BottomTabNavigationConfig & {
32
31
  state: TabNavigationState<ParamListBase>;
@@ -102,7 +101,7 @@ export function BottomTabView(props: Props) {
102
101
  useNativeDriver: true,
103
102
  });
104
103
  })
105
- .filter(Boolean) as CompositeAnimation[]
104
+ .filter(Boolean) as Animated.CompositeAnimation[]
106
105
  ).start();
107
106
  };
108
107
 
@@ -1,5 +1,11 @@
1
1
  import * as React from 'react';
2
- import { Animated, StyleProp, View, ViewProps, ViewStyle } from 'react-native';
2
+ import {
3
+ Animated,
4
+ type StyleProp,
5
+ View,
6
+ type ViewProps,
7
+ type ViewStyle,
8
+ } from 'react-native';
3
9
 
4
10
  type Props = {
5
11
  enabled: boolean;
@@ -1,11 +1,11 @@
1
1
  import type { Route } from '@react-navigation/native';
2
2
  import React from 'react';
3
3
  import {
4
- StyleProp,
4
+ type StyleProp,
5
5
  StyleSheet,
6
- TextStyle,
6
+ type TextStyle,
7
7
  View,
8
- ViewStyle,
8
+ type ViewStyle,
9
9
  } from 'react-native';
10
10
 
11
11
  import { Badge } from './Badge';