@react-navigation/bottom-tabs 7.6.0 → 7.7.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.
Files changed (56) hide show
  1. package/lib/module/unstable/NativeBottomTabView.js +6 -0
  2. package/lib/module/unstable/NativeBottomTabView.js.map +1 -0
  3. package/lib/module/unstable/NativeBottomTabView.native.js +229 -0
  4. package/lib/module/unstable/NativeBottomTabView.native.js.map +1 -0
  5. package/lib/module/unstable/NativeScreen/NativeScreen.js +166 -0
  6. package/lib/module/unstable/NativeScreen/NativeScreen.js.map +1 -0
  7. package/lib/module/unstable/NativeScreen/debounce.js +12 -0
  8. package/lib/module/unstable/NativeScreen/debounce.js.map +1 -0
  9. package/lib/module/unstable/NativeScreen/types.js +4 -0
  10. package/lib/module/unstable/NativeScreen/types.js.map +1 -0
  11. package/lib/module/unstable/NativeScreen/useAnimatedHeaderHeight.js +12 -0
  12. package/lib/module/unstable/NativeScreen/useAnimatedHeaderHeight.js.map +1 -0
  13. package/lib/module/unstable/NativeScreen/useHeaderConfig.js +283 -0
  14. package/lib/module/unstable/NativeScreen/useHeaderConfig.js.map +1 -0
  15. package/lib/module/unstable/createNativeBottomTabNavigator.js +6 -0
  16. package/lib/module/unstable/createNativeBottomTabNavigator.js.map +1 -0
  17. package/lib/module/unstable/createNativeBottomTabNavigator.native.js +65 -0
  18. package/lib/module/unstable/createNativeBottomTabNavigator.native.js.map +1 -0
  19. package/lib/module/unstable/index.js +16 -0
  20. package/lib/module/unstable/index.js.map +1 -0
  21. package/lib/module/unstable/types.js +4 -0
  22. package/lib/module/unstable/types.js.map +1 -0
  23. package/lib/typescript/src/unstable/NativeBottomTabView.d.ts +10 -0
  24. package/lib/typescript/src/unstable/NativeBottomTabView.d.ts.map +1 -0
  25. package/lib/typescript/src/unstable/NativeBottomTabView.native.d.ts +10 -0
  26. package/lib/typescript/src/unstable/NativeBottomTabView.native.d.ts.map +1 -0
  27. package/lib/typescript/src/unstable/NativeScreen/NativeScreen.d.ts +8 -0
  28. package/lib/typescript/src/unstable/NativeScreen/NativeScreen.d.ts.map +1 -0
  29. package/lib/typescript/src/unstable/NativeScreen/debounce.d.ts +2 -0
  30. package/lib/typescript/src/unstable/NativeScreen/debounce.d.ts.map +1 -0
  31. package/lib/typescript/src/unstable/NativeScreen/types.d.ts +467 -0
  32. package/lib/typescript/src/unstable/NativeScreen/types.d.ts.map +1 -0
  33. package/lib/typescript/src/unstable/NativeScreen/useAnimatedHeaderHeight.d.ts +5 -0
  34. package/lib/typescript/src/unstable/NativeScreen/useAnimatedHeaderHeight.d.ts.map +1 -0
  35. package/lib/typescript/src/unstable/NativeScreen/useHeaderConfig.d.ts +11 -0
  36. package/lib/typescript/src/unstable/NativeScreen/useHeaderConfig.d.ts.map +1 -0
  37. package/lib/typescript/src/unstable/createNativeBottomTabNavigator.d.ts +2 -0
  38. package/lib/typescript/src/unstable/createNativeBottomTabNavigator.d.ts.map +1 -0
  39. package/lib/typescript/src/unstable/createNativeBottomTabNavigator.native.d.ts +16 -0
  40. package/lib/typescript/src/unstable/createNativeBottomTabNavigator.native.d.ts.map +1 -0
  41. package/lib/typescript/src/unstable/index.d.ts +13 -0
  42. package/lib/typescript/src/unstable/index.d.ts.map +1 -0
  43. package/lib/typescript/src/unstable/types.d.ts +302 -0
  44. package/lib/typescript/src/unstable/types.d.ts.map +1 -0
  45. package/package.json +10 -4
  46. package/src/unstable/NativeBottomTabView.native.tsx +307 -0
  47. package/src/unstable/NativeBottomTabView.tsx +20 -0
  48. package/src/unstable/NativeScreen/NativeScreen.tsx +242 -0
  49. package/src/unstable/NativeScreen/debounce.tsx +14 -0
  50. package/src/unstable/NativeScreen/types.ts +517 -0
  51. package/src/unstable/NativeScreen/useAnimatedHeaderHeight.tsx +18 -0
  52. package/src/unstable/NativeScreen/useHeaderConfig.tsx +423 -0
  53. package/src/unstable/createNativeBottomTabNavigator.native.tsx +116 -0
  54. package/src/unstable/createNativeBottomTabNavigator.tsx +4 -0
  55. package/src/unstable/index.tsx +22 -0
  56. package/src/unstable/types.tsx +385 -0
@@ -0,0 +1,302 @@
1
+ import type { DefaultNavigatorOptions, Descriptor, NavigationHelpers, NavigationProp, ParamListBase, RouteProp, TabActionHelpers, TabNavigationState, TabRouterOptions, Theme } from '@react-navigation/native';
2
+ import type { ColorValue, ImageSourcePropType, TextStyle } from 'react-native';
3
+ import type { EdgeInsets } from 'react-native-safe-area-context';
4
+ import type { BottomTabsScreenBlurEffect, BottomTabsSystemItem, TabBarControllerMode, TabBarItemLabelVisibilityMode, TabBarMinimizeBehavior } from 'react-native-screens';
5
+ import type { SFSymbol } from 'sf-symbols-typescript';
6
+ import type { NativeHeaderOptions } from './NativeScreen/types';
7
+ export type Layout = {
8
+ width: number;
9
+ height: number;
10
+ };
11
+ export type NativeBottomTabNavigationEventMap = {
12
+ /**
13
+ * Event which fires on tapping on the tab in the tab bar.
14
+ */
15
+ tabPress: {
16
+ data: undefined;
17
+ canPreventDefault: true;
18
+ };
19
+ /**
20
+ * Event which fires when a transition animation starts.
21
+ */
22
+ transitionStart: {
23
+ data: {
24
+ closing: boolean;
25
+ };
26
+ };
27
+ /**
28
+ * Event which fires when a transition animation ends.
29
+ */
30
+ transitionEnd: {
31
+ data: {
32
+ closing: boolean;
33
+ };
34
+ };
35
+ };
36
+ export type NativeBottomTabNavigationProp<ParamList extends ParamListBase, RouteName extends keyof ParamList = keyof ParamList, NavigatorID extends string | undefined = undefined> = NavigationProp<ParamList, RouteName, NavigatorID, TabNavigationState<ParamList>, NativeBottomTabNavigationOptions, NativeBottomTabNavigationEventMap> & TabActionHelpers<ParamList>;
37
+ export type NativeBottomTabScreenProps<ParamList extends ParamListBase, RouteName extends keyof ParamList = keyof ParamList, NavigatorID extends string | undefined = undefined> = {
38
+ navigation: NativeBottomTabNavigationProp<ParamList, RouteName, NavigatorID>;
39
+ route: RouteProp<ParamList, RouteName>;
40
+ };
41
+ export type NativeBottomTabOptionsArgs<ParamList extends ParamListBase, RouteName extends keyof ParamList = keyof ParamList, NavigatorID extends string | undefined = undefined> = NativeBottomTabScreenProps<ParamList, RouteName, NavigatorID> & {
42
+ theme: Theme;
43
+ };
44
+ type IconImage = {
45
+ /**
46
+ * - `image` - Use a local image as the icon.
47
+ */
48
+ type: 'image';
49
+ /**
50
+ * Image source to use as the icon.
51
+ * e.g., `require('./path/to/image.png')`
52
+ */
53
+ source: ImageSourcePropType;
54
+ /**
55
+ * Whether to apply tint color to the icon.
56
+ * Defaults to `true`.
57
+ *
58
+ * @platform ios
59
+ */
60
+ tinted?: boolean;
61
+ };
62
+ type IconIOSSfSymbol = {
63
+ /**
64
+ * - `sfSymbol` - Use an SF Symbol as the icon on iOS.
65
+ */
66
+ type: 'sfSymbol';
67
+ /**
68
+ * Name of the SF Symbol to use as the icon.
69
+ *
70
+ * @platform ios
71
+ */
72
+ name: SFSymbol;
73
+ };
74
+ type IconAndroidDrawable = {
75
+ /**
76
+ * - `drawableResource` - Use a drawable resource as the icon on Android.
77
+ */
78
+ type: 'drawableResource';
79
+ /**
80
+ * Name of the drawable resource to use as the icon.
81
+ *
82
+ * @platform android
83
+ */
84
+ name: string;
85
+ };
86
+ type IconIOS = IconIOSSfSymbol | IconImage;
87
+ type IconAndroid = IconAndroidDrawable | IconImage;
88
+ export type Icon = IconIOS | IconAndroid;
89
+ export type NativeBottomTabNavigationOptions = NativeHeaderOptions & {
90
+ /**
91
+ * Title text for the screen.
92
+ */
93
+ title?: string;
94
+ /**
95
+ * Uses iOS built-in tab bar items with standard iOS styling and localized titles.
96
+ * If set to `search`, it's positioned next to the tab bar on iOS 26 and above.
97
+ *
98
+ * The `tabBarIcon` and `tabBarLabel` options will override the icon and label from the system item.
99
+ * If you want to keep the system behavior on iOS, but need to provide icon and label for other platforms,
100
+ * Use `Platform.OS` or `Platform.select` to conditionally set `undefined` for `tabBarIcon` and `tabBarLabel` on iOS.
101
+ *
102
+ * @platform ios
103
+ */
104
+ tabBarSystemItem?: BottomTabsSystemItem;
105
+ /**
106
+ * Title string of the tab displayed in the tab bar
107
+ *
108
+ * Overrides the label provided by `tabBarSystemItem` on iOS.
109
+ *
110
+ * If not provided, or set to `undefined`:
111
+ * - The system values are used if `tabBarSystemItem` is set on iOS.
112
+ * - Otherwise, it falls back to the `title` or route name.
113
+ */
114
+ tabBarLabel?: string;
115
+ /**
116
+ * Label visibility mode for the tab bar items.
117
+ *
118
+ * The following values are currently supported:
119
+ *
120
+ * - `auto` - the system decides when to show or hide labels
121
+ * - `selected` - labels are shown only for the selected tab
122
+ * - `labeled` - labels are always shown
123
+ * - `unlabeled` - labels are never shown
124
+ *
125
+ * Defaults to `auto`.
126
+ *
127
+ * @platform android
128
+ */
129
+ tabBarLabelVisibilityMode?: TabBarItemLabelVisibilityMode;
130
+ /**
131
+ * Style object for the tab label.
132
+ */
133
+ tabBarLabelStyle?: Pick<TextStyle, 'fontFamily' | 'fontSize' | 'fontWeight' | 'fontStyle'>;
134
+ /**
135
+ * Icon to display for the tab.
136
+ *
137
+ * Showing a different icon for focused tab is only supported on iOS.
138
+ *
139
+ * Overrides the icon provided by `tabBarSystemItem` on iOS.
140
+ */
141
+ tabBarIcon?: Icon | ((props: {
142
+ focused: boolean;
143
+ }) => Icon);
144
+ /**
145
+ * Text to show in a badge on the tab icon.
146
+ */
147
+ tabBarBadge?: number | string;
148
+ /**
149
+ * Custom style for the tab bar badge.
150
+ * You can specify a background color or text color here.
151
+ *
152
+ * @platform android
153
+ */
154
+ tabBarBadgeStyle?: {
155
+ backgroundColor?: ColorValue;
156
+ color?: ColorValue;
157
+ };
158
+ /**
159
+ * Color for the icon and label in the active tab.
160
+ */
161
+ tabBarActiveTintColor?: ColorValue;
162
+ /**
163
+ * Color for the icon and label in the inactive tabs.
164
+ *
165
+ * @platform android
166
+ */
167
+ tabBarInactiveTintColor?: ColorValue;
168
+ /**
169
+ * Background color of the active indicator.
170
+ *
171
+ * @platform android
172
+ */
173
+ tabBarActiveIndicatorColor?: ColorValue;
174
+ /**
175
+ * Specifies if the active indicator should be used. Defaults to `true`.
176
+ *
177
+ * @platform android
178
+ */
179
+ tabBarActiveIndicatorEnabled?: boolean;
180
+ /**
181
+ * Color of tab bar item's ripple effect.
182
+ *
183
+ * @platform android
184
+ */
185
+ tabBarRippleColor?: ColorValue;
186
+ /**
187
+ * Style object for the tab bar container.
188
+ */
189
+ tabBarStyle?: {
190
+ /**
191
+ * Background color of the tab bar.
192
+ *
193
+ * Only supported on Android and iOS 18 and below.
194
+ */
195
+ backgroundColor?: ColorValue;
196
+ /**
197
+ * Shadow color of the tab bar.
198
+ *
199
+ * Only supported on iOS 18 and below.
200
+ */
201
+ shadowColor?: ColorValue;
202
+ };
203
+ /**
204
+ * Blur effect applied to the tab bar when tab screen is selected.
205
+ *
206
+ * Works with backgroundColor's alpha < 1.
207
+ *
208
+ * Only supported on iOS 18 and lower.
209
+ *
210
+ * The following values are currently supported:
211
+ *
212
+ * - `none` - disables blur effect
213
+ * - `systemDefault` - uses UIKit's default tab bar blur effect
214
+ * - one of styles mapped from UIKit's UIBlurEffectStyle, e.g. `systemUltraThinMaterial`
215
+ *
216
+ * Defaults to `systemDefault`.
217
+ *
218
+ * Complete list of possible blur effect styles is available in the official UIKit documentation:
219
+ * @see {@link https://developer.apple.com/documentation/uikit/uiblureffect/style|UIBlurEffect.Style}
220
+ *
221
+ * @platform ios
222
+ */
223
+ tabBarBlurEffect?: BottomTabsScreenBlurEffect;
224
+ /**
225
+ * Display mode for the tab bar.
226
+ *
227
+ * Available starting from iOS 18.
228
+ * Not supported on tvOS.
229
+ *
230
+ * The following values are currently supported:
231
+ *
232
+ * - `auto` - the system sets the display mode based on the tab’s content
233
+ * - `tabBar` - the system displays the content only as a tab bar
234
+ * - `tabSidebar` - the tab bar is displayed as a sidebar
235
+ *
236
+ * Defaults to `auto`.
237
+ *
238
+ * @see {@link https://developer.apple.com/documentation/uikit/uitabbarcontroller/mode|UITabBarController.Mode}
239
+ *
240
+ * @platform ios
241
+ */
242
+ tabBarControllerMode?: TabBarControllerMode;
243
+ /**
244
+ * Minimize behavior for the tab bar.
245
+ *
246
+ * Available starting from iOS 26.
247
+ *
248
+ * The following values are currently supported:
249
+ *
250
+ * - `auto` - resolves to the system default minimize behavior
251
+ * - `never` - the tab bar does not minimize
252
+ * - `onScrollDown` - the tab bar minimizes when scrolling down and
253
+ * expands when scrolling back up
254
+ * - `onScrollUp` - the tab bar minimizes when scrolling up and expands
255
+ * when scrolling back down
256
+ *
257
+ * Defaults to `auto`.
258
+ *
259
+ * The supported values correspond to the official UIKit documentation:
260
+ * @see {@link https://developer.apple.com/documentation/uikit/uitabbarcontroller/minimizebehavior|UITabBarController.MinimizeBehavior}
261
+ *
262
+ * @platform ios
263
+ */
264
+ tabBarMinimizeBehavior?: TabBarMinimizeBehavior;
265
+ /**
266
+ * Whether this screens should render the first time it's accessed. Defaults to `true`.
267
+ * Set it to `false` if you want to render the screen on initial render.
268
+ */
269
+ lazy?: boolean;
270
+ /**
271
+ * Whether any nested stack should be popped to top when navigating away from the tab.
272
+ * Defaults to `false`.
273
+ */
274
+ popToTopOnBlur?: boolean;
275
+ };
276
+ export type NativeBottomTabDescriptor = Descriptor<NativeBottomTabNavigationOptions, NativeBottomTabNavigationProp<ParamListBase>, RouteProp<ParamListBase>>;
277
+ export type NativeBottomTabDescriptorMap = Record<string, NativeBottomTabDescriptor>;
278
+ export type NativeBottomTabNavigationConfig = {};
279
+ export type NativeBottomTabBarProps = {
280
+ state: TabNavigationState<ParamListBase>;
281
+ descriptors: NativeBottomTabDescriptorMap;
282
+ navigation: NavigationHelpers<ParamListBase, NativeBottomTabNavigationEventMap>;
283
+ insets: EdgeInsets;
284
+ };
285
+ export type NativeBottomTabNavigatorProps = DefaultNavigatorOptions<ParamListBase, string | undefined, TabNavigationState<ParamListBase>, NativeBottomTabNavigationOptions, NativeBottomTabNavigationEventMap, NativeBottomTabNavigationProp<ParamListBase>> & TabRouterOptions & NativeBottomTabNavigationConfig;
286
+ export type NativeBottomTabNavigationHelpers = NavigationHelpers<ParamListBase, NativeBottomTabNavigationEventMap> & TabActionHelpers<ParamListBase>;
287
+ export type NativeBottomTabHeaderProps = {
288
+ /**
289
+ * Options for the current screen.
290
+ */
291
+ options: NativeBottomTabNavigationOptions;
292
+ /**
293
+ * Route object for the current screen.
294
+ */
295
+ route: RouteProp<ParamListBase>;
296
+ /**
297
+ * Navigation prop for the header.
298
+ */
299
+ navigation: NativeBottomTabNavigationProp<ParamListBase>;
300
+ };
301
+ export {};
302
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/unstable/types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,EACN,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,6BAA6B,EAC7B,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,MAAM,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,MAAM,MAAM,iCAAiC,GAAG;IAC9C;;OAEG;IACH,QAAQ,EAAE;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,iBAAiB,EAAE,IAAI,CAAA;KAAE,CAAC;IACvD;;OA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AAC,EACjC,gCAAgC,EAChC,iCAAiC,EACjC,6BAA6B,CAAC,aAAa,CAAC,CAC7C,GACC,gBAAgB,GAChB,+BAA+B,CAAC;AAElC,MAAM,MAAM,gCAAgC,GAAG,iBAAiB,CAC9D,aAAa,EACb,iCAAiC,CAClC,GACC,gBAAgB,CAAC,aAAa,CAAC,CAAC;AAElC,MAAM,MAAM,0BAA0B,GAAG;IACvC;;OAEG;IACH,OAAO,EAAE,gCAAgC,CAAC;IAC1C;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;IAChC;;OAEG;IACH,UAAU,EAAE,6BAA6B,CAAC,aAAa,CAAC,CAAC;CAC1D,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/bottom-tabs",
3
3
  "description": "Bottom tab navigator following iOS design guidelines",
4
- "version": "7.6.0",
4
+ "version": "7.7.1",
5
5
  "keywords": [
6
6
  "react-native-component",
7
7
  "react-component",
@@ -25,6 +25,11 @@
25
25
  "types": "./lib/typescript/src/index.d.ts",
26
26
  "default": "./lib/module/index.js"
27
27
  },
28
+ "./unstable": {
29
+ "source": "./src/unstable/index.tsx",
30
+ "types": "./lib/typescript/src/unstable/index.d.ts",
31
+ "default": "./lib/module/unstable/index.js"
32
+ },
28
33
  "./package.json": "./package.json"
29
34
  },
30
35
  "files": [
@@ -41,8 +46,9 @@
41
46
  "clean": "del lib"
42
47
  },
43
48
  "dependencies": {
44
- "@react-navigation/elements": "^2.7.1",
45
- "color": "^4.2.3"
49
+ "@react-navigation/elements": "^2.8.0",
50
+ "color": "^4.2.3",
51
+ "sf-symbols-typescript": "^2.1.0"
46
52
  },
47
53
  "devDependencies": {
48
54
  "@jest/globals": "^30.0.0",
@@ -84,5 +90,5 @@
84
90
  ]
85
91
  ]
86
92
  },
87
- "gitHead": "25c616e84c388f8f27f1be8e2981bb0780b5206d"
93
+ "gitHead": "b24d0210c3131ef3e0eac80098202e994e0e6a99"
88
94
  }
@@ -0,0 +1,307 @@
1
+ import {
2
+ getLabel,
3
+ Lazy,
4
+ SafeAreaProviderCompat,
5
+ } from '@react-navigation/elements';
6
+ import {
7
+ CommonActions,
8
+ type ParamListBase,
9
+ type Route,
10
+ StackActions,
11
+ type TabNavigationState,
12
+ useTheme,
13
+ } from '@react-navigation/native';
14
+ import Color from 'color';
15
+ import * as React from 'react';
16
+ import { type ColorValue, Platform, PlatformColor } from 'react-native';
17
+ import {
18
+ BottomTabs,
19
+ BottomTabsScreen,
20
+ type BottomTabsScreenItemStateAppearance,
21
+ type PlatformIcon,
22
+ } from 'react-native-screens';
23
+
24
+ import { NativeScreen } from './NativeScreen/NativeScreen';
25
+ import type {
26
+ Icon,
27
+ NativeBottomTabDescriptorMap,
28
+ NativeBottomTabNavigationConfig,
29
+ NativeBottomTabNavigationHelpers,
30
+ } from './types';
31
+
32
+ type Props = NativeBottomTabNavigationConfig & {
33
+ state: TabNavigationState<ParamListBase>;
34
+ navigation: NativeBottomTabNavigationHelpers;
35
+ descriptors: NativeBottomTabDescriptorMap;
36
+ };
37
+
38
+ export function NativeBottomTabView({ state, navigation, descriptors }: Props) {
39
+ const { colors, fonts } = useTheme();
40
+
41
+ const focusedRouteKey = state.routes[state.index].key;
42
+ const previousRouteKeyRef = React.useRef(focusedRouteKey);
43
+
44
+ React.useEffect(() => {
45
+ const previousRouteKey = previousRouteKeyRef.current;
46
+
47
+ if (
48
+ previousRouteKey !== focusedRouteKey &&
49
+ descriptors[previousRouteKey]?.options.popToTopOnBlur
50
+ ) {
51
+ const prevRoute = state.routes.find(
52
+ (route) => route.key === previousRouteKey
53
+ );
54
+
55
+ if (prevRoute?.state?.type === 'stack' && prevRoute.state.key) {
56
+ const popToTopAction = {
57
+ ...StackActions.popToTop(),
58
+ target: prevRoute.state.key,
59
+ };
60
+ navigation.dispatch(popToTopAction);
61
+ }
62
+ }
63
+
64
+ previousRouteKeyRef.current = focusedRouteKey;
65
+ }, [descriptors, focusedRouteKey, navigation, state.index, state.routes]);
66
+
67
+ const currentOptions = descriptors[state.routes[state.index].key]?.options;
68
+
69
+ const {
70
+ fontFamily = Platform.select({
71
+ ios: fonts.medium.fontFamily,
72
+ default: fonts.regular.fontFamily,
73
+ }),
74
+ fontWeight = Platform.select({
75
+ ios: fonts.medium.fontWeight,
76
+ default: fonts.regular.fontWeight,
77
+ }),
78
+ fontSize,
79
+ fontStyle,
80
+ } = currentOptions.tabBarLabelStyle || {};
81
+
82
+ const activeTintColor =
83
+ currentOptions.tabBarActiveTintColor ?? colors.primary;
84
+
85
+ const inactiveTintColor =
86
+ currentOptions.tabBarInactiveTintColor ??
87
+ Platform.select<ColorValue | string>({
88
+ ios: PlatformColor('label'),
89
+ default: colors.text,
90
+ });
91
+
92
+ const activeIndicatorColor =
93
+ (currentOptions?.tabBarActiveIndicatorColor ??
94
+ typeof activeTintColor === 'string')
95
+ ? Color(activeTintColor)?.alpha(0.1).string()
96
+ : undefined;
97
+
98
+ const onTransitionStart = ({
99
+ closing,
100
+ route,
101
+ }: {
102
+ closing: boolean;
103
+ route: Route<string>;
104
+ }) => {
105
+ navigation.emit({
106
+ type: 'transitionStart',
107
+ data: { closing },
108
+ target: route.key,
109
+ });
110
+ };
111
+
112
+ const onTransitionEnd = ({
113
+ closing,
114
+ route,
115
+ }: {
116
+ closing: boolean;
117
+ route: Route<string>;
118
+ }) => {
119
+ navigation.emit({
120
+ type: 'transitionEnd',
121
+ data: { closing },
122
+ target: route.key,
123
+ });
124
+ };
125
+
126
+ return (
127
+ <SafeAreaProviderCompat>
128
+ <BottomTabs
129
+ tabBarItemLabelVisibilityMode={
130
+ currentOptions?.tabBarLabelVisibilityMode
131
+ }
132
+ tabBarControllerMode={currentOptions?.tabBarControllerMode}
133
+ tabBarMinimizeBehavior={currentOptions?.tabBarMinimizeBehavior}
134
+ tabBarTintColor={activeTintColor}
135
+ tabBarItemIconColor={inactiveTintColor}
136
+ tabBarItemIconColorActive={activeTintColor}
137
+ tabBarItemTitleFontColor={inactiveTintColor}
138
+ tabBarItemTitleFontColorActive={activeTintColor}
139
+ tabBarItemTitleFontFamily={fontFamily}
140
+ tabBarItemTitleFontWeight={fontWeight}
141
+ tabBarItemTitleFontSize={fontSize}
142
+ tabBarItemTitleFontSizeActive={fontSize}
143
+ tabBarItemTitleFontStyle={fontStyle}
144
+ tabBarBackgroundColor={currentOptions.tabBarStyle?.backgroundColor}
145
+ tabBarItemActiveIndicatorColor={activeIndicatorColor}
146
+ tabBarItemActiveIndicatorEnabled={
147
+ currentOptions?.tabBarActiveIndicatorEnabled
148
+ }
149
+ tabBarItemRippleColor={currentOptions?.tabBarRippleColor}
150
+ experimentalControlNavigationStateInJS
151
+ onNativeFocusChange={(e) => {
152
+ const route = state.routes.find(
153
+ (route) => route.key === e.nativeEvent.tabKey
154
+ );
155
+
156
+ if (route) {
157
+ const isFocused =
158
+ state.index ===
159
+ state.routes.findIndex((r) => r.key === route.key);
160
+
161
+ const event = navigation.emit({
162
+ type: 'tabPress',
163
+ target: route.key,
164
+ canPreventDefault: true,
165
+ });
166
+
167
+ if (!isFocused && !event.defaultPrevented) {
168
+ React.startTransition(() => {
169
+ navigation.dispatch({
170
+ ...CommonActions.navigate(route.name, route.params),
171
+ target: state.key,
172
+ });
173
+ });
174
+ }
175
+ }
176
+ }}
177
+ >
178
+ {state.routes.map((route, index) => {
179
+ const { options, render, navigation } = descriptors[route.key];
180
+ const isFocused = state.index === index;
181
+ const isPreloaded = state.preloadedRouteKeys.includes(route.key);
182
+
183
+ const {
184
+ title,
185
+ lazy = true,
186
+ tabBarLabel,
187
+ tabBarBadgeStyle,
188
+ tabBarIcon,
189
+ tabBarBadge,
190
+ tabBarSystemItem,
191
+ tabBarBlurEffect,
192
+ tabBarStyle,
193
+ } = options;
194
+
195
+ const {
196
+ backgroundColor: tabBarBackgroundColor,
197
+ shadowColor: tabBarShadowColor,
198
+ } = tabBarStyle || {};
199
+
200
+ const tabTitle =
201
+ // On iOS, `systemItem` already provides a localized label
202
+ // So we should only use `tabBarLabel` if explicitly provided
203
+ Platform.OS === 'ios' && tabBarSystemItem != null
204
+ ? tabBarLabel
205
+ : getLabel({ label: tabBarLabel, title }, route.name);
206
+
207
+ const tabItemAppearance: BottomTabsScreenItemStateAppearance = {
208
+ tabBarItemTitleFontFamily: fontFamily,
209
+ tabBarItemTitleFontSize: fontSize,
210
+ tabBarItemTitleFontWeight: fontWeight,
211
+ tabBarItemTitleFontStyle: fontStyle,
212
+ };
213
+
214
+ const badgeBackgroundColor =
215
+ tabBarBadgeStyle?.backgroundColor ?? colors.notification;
216
+ const badgeTextColor =
217
+ typeof badgeBackgroundColor === 'string' &&
218
+ Color(badgeBackgroundColor)?.isLight()
219
+ ? 'black'
220
+ : 'white';
221
+
222
+ const icon =
223
+ typeof tabBarIcon === 'function'
224
+ ? getPlatformIcon(tabBarIcon({ focused: false }))
225
+ : tabBarIcon != null
226
+ ? getPlatformIcon(tabBarIcon)
227
+ : undefined;
228
+
229
+ const selectedIcon =
230
+ typeof tabBarIcon === 'function'
231
+ ? getPlatformIcon(tabBarIcon({ focused: true }))
232
+ : undefined;
233
+
234
+ return (
235
+ <BottomTabsScreen
236
+ onWillDisappear={() =>
237
+ onTransitionStart({ closing: true, route })
238
+ }
239
+ onWillAppear={() => onTransitionStart({ closing: false, route })}
240
+ onDidAppear={() => onTransitionEnd({ closing: false, route })}
241
+ onDidDisappear={() => onTransitionEnd({ closing: true, route })}
242
+ key={route.key}
243
+ tabKey={route.key}
244
+ icon={icon}
245
+ selectedIcon={selectedIcon?.ios ?? selectedIcon?.shared}
246
+ tabBarItemBadgeBackgroundColor={badgeBackgroundColor}
247
+ tabBarItemBadgeTextColor={badgeTextColor}
248
+ badgeValue={tabBarBadge?.toString()}
249
+ systemItem={tabBarSystemItem}
250
+ isFocused={isFocused}
251
+ title={tabTitle}
252
+ standardAppearance={{
253
+ tabBarBackgroundColor,
254
+ tabBarShadowColor,
255
+ tabBarBlurEffect,
256
+ stacked: {
257
+ normal: tabItemAppearance,
258
+ },
259
+ inline: {
260
+ normal: tabItemAppearance,
261
+ },
262
+ compactInline: {
263
+ normal: tabItemAppearance,
264
+ },
265
+ }}
266
+ >
267
+ <Lazy
268
+ enabled={lazy ? isFocused || isPreloaded : true}
269
+ render={() => (
270
+ <NativeScreen
271
+ route={route}
272
+ navigation={navigation}
273
+ options={options}
274
+ >
275
+ {render()}
276
+ </NativeScreen>
277
+ )}
278
+ />
279
+ </BottomTabsScreen>
280
+ );
281
+ })}
282
+ </BottomTabs>
283
+ </SafeAreaProviderCompat>
284
+ );
285
+ }
286
+
287
+ function getPlatformIcon(icon: Icon): PlatformIcon {
288
+ return {
289
+ ios:
290
+ icon?.type === 'sfSymbol'
291
+ ? icon
292
+ : icon?.type === 'image' && icon.tinted !== false
293
+ ? {
294
+ type: 'templateSource',
295
+ templateSource: icon.source,
296
+ }
297
+ : undefined,
298
+ android: icon?.type === 'drawableResource' ? icon : undefined,
299
+ shared:
300
+ icon?.type === 'image'
301
+ ? {
302
+ type: 'imageSource',
303
+ imageSource: icon.source,
304
+ }
305
+ : undefined,
306
+ } as const;
307
+ }
@@ -0,0 +1,20 @@
1
+ import {
2
+ type ParamListBase,
3
+ type TabNavigationState,
4
+ } from '@react-navigation/native';
5
+
6
+ import type {
7
+ NativeBottomTabDescriptorMap,
8
+ NativeBottomTabNavigationConfig,
9
+ NativeBottomTabNavigationHelpers,
10
+ } from './types';
11
+
12
+ type Props = NativeBottomTabNavigationConfig & {
13
+ state: TabNavigationState<ParamListBase>;
14
+ navigation: NativeBottomTabNavigationHelpers;
15
+ descriptors: NativeBottomTabDescriptorMap;
16
+ };
17
+
18
+ export function NativeBottomTabView(_: Props) {
19
+ throw new Error('Native Bottom Tabs are not supported on this platform.');
20
+ }