@react-navigation/bottom-tabs 8.0.0-alpha.5 → 8.0.0-alpha.50
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/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/navigators/createBottomTabNavigator.js +4 -25
- package/lib/module/navigators/createBottomTabNavigator.js.map +1 -1
- package/lib/module/utils/useBottomTabAnimation.js +1 -1
- package/lib/module/utils/useBottomTabAnimation.js.map +1 -1
- package/lib/module/utils/useBottomTabBarHeight.js +1 -1
- package/lib/module/utils/useBottomTabBarHeight.js.map +1 -1
- package/lib/module/utils/useIsKeyboardShown.js.map +1 -1
- package/lib/module/views/BottomTabBar.js +40 -29
- package/lib/module/views/BottomTabBar.js.map +1 -1
- package/lib/module/views/BottomTabItem.js +3 -5
- package/lib/module/views/BottomTabItem.js.map +1 -1
- package/lib/module/views/{BottomTabViewCommon.js → BottomTabView.js} +1 -1
- package/lib/module/views/BottomTabView.js.map +1 -0
- package/lib/module/views/BottomTabViewCustom.js +97 -81
- package/lib/module/views/BottomTabViewCustom.js.map +1 -1
- package/lib/module/views/BottomTabViewNativeImpl.js +339 -121
- package/lib/module/views/BottomTabViewNativeImpl.js.map +1 -1
- package/lib/module/views/Deferred.js +41 -0
- package/lib/module/views/Deferred.js.map +1 -0
- package/lib/module/views/ScreenContent.js.map +1 -1
- package/lib/module/views/TabBarIcon.js +11 -48
- package/lib/module/views/TabBarIcon.js.map +1 -1
- package/lib/typescript/src/TransitionConfigs/SceneStyleInterpolators.d.ts +1 -1
- package/lib/typescript/src/TransitionConfigs/SceneStyleInterpolators.d.ts.map +1 -1
- package/lib/typescript/src/TransitionConfigs/TransitionPresets.d.ts +1 -1
- package/lib/typescript/src/TransitionConfigs/TransitionPresets.d.ts.map +1 -1
- package/lib/typescript/src/TransitionConfigs/TransitionSpecs.d.ts +1 -1
- package/lib/typescript/src/TransitionConfigs/TransitionSpecs.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +11 -11
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts +9 -15
- package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +66 -104
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/BottomTabAnimationContext.d.ts +1 -1
- package/lib/typescript/src/utils/BottomTabAnimationContext.d.ts.map +1 -1
- package/lib/typescript/src/utils/useAnimatedHashMap.d.ts +1 -1
- package/lib/typescript/src/utils/useAnimatedHashMap.d.ts.map +1 -1
- package/lib/typescript/src/utils/useBottomTabAnimation.d.ts +1 -1
- package/lib/typescript/src/utils/useBottomTabAnimation.d.ts.map +1 -1
- package/lib/typescript/src/utils/useTabBarPosition.d.ts +1 -1
- package/lib/typescript/src/utils/useTabBarPosition.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabBar.d.ts +3 -2
- package/lib/typescript/src/views/BottomTabBar.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabItem.d.ts +20 -20
- package/lib/typescript/src/views/BottomTabItem.d.ts.map +1 -1
- package/lib/typescript/src/views/{BottomTabViewCommon.d.ts → BottomTabView.d.ts} +3 -3
- package/lib/typescript/src/views/BottomTabView.d.ts.map +1 -0
- package/lib/typescript/src/views/BottomTabViewCustom.d.ts +3 -2
- package/lib/typescript/src/views/BottomTabViewCustom.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabViewNative.android.d.ts +1 -1
- package/lib/typescript/src/views/BottomTabViewNative.android.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabViewNative.d.ts +1 -1
- package/lib/typescript/src/views/BottomTabViewNative.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabViewNative.ios.d.ts +1 -1
- package/lib/typescript/src/views/BottomTabViewNative.ios.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabViewNativeImpl.d.ts +3 -2
- package/lib/typescript/src/views/BottomTabViewNativeImpl.d.ts.map +1 -1
- package/lib/typescript/src/views/Deferred.d.ts +31 -0
- package/lib/typescript/src/views/Deferred.d.ts.map +1 -0
- package/lib/typescript/src/views/ScreenContent.d.ts +4 -4
- package/lib/typescript/src/views/ScreenContent.d.ts.map +1 -1
- package/lib/typescript/src/views/TabBarIcon.d.ts +8 -8
- package/lib/typescript/src/views/TabBarIcon.d.ts.map +1 -1
- package/package.json +22 -22
- package/src/index.tsx +2 -2
- package/src/navigators/createBottomTabNavigator.tsx +10 -75
- package/src/types.tsx +66 -112
- package/src/utils/useAnimatedHashMap.tsx +1 -1
- package/src/utils/useBottomTabAnimation.tsx +1 -1
- package/src/utils/useBottomTabBarHeight.tsx +1 -1
- package/src/utils/useIsKeyboardShown.tsx +2 -2
- package/src/views/BottomTabBar.tsx +68 -25
- package/src/views/BottomTabItem.tsx +19 -21
- package/src/views/BottomTabViewCustom.tsx +172 -143
- package/src/views/BottomTabViewNativeImpl.tsx +480 -161
- package/src/views/Deferred.tsx +57 -0
- package/src/views/ScreenContent.tsx +1 -2
- package/src/views/TabBarIcon.tsx +13 -56
- package/lib/module/views/BottomTabViewCommon.js.map +0 -1
- package/lib/typescript/src/views/BottomTabViewCommon.d.ts.map +0 -1
- /package/src/views/{BottomTabViewCommon.tsx → BottomTabView.tsx} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
/**
|
|
4
|
+
* Whether lazy rendering is enabled.
|
|
5
|
+
*/
|
|
6
|
+
lazy: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Whether the component is visible.
|
|
9
|
+
*/
|
|
10
|
+
visible: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Content to render.
|
|
13
|
+
*/
|
|
14
|
+
children: React.ReactElement;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Render content lazily based on visibility.
|
|
18
|
+
*
|
|
19
|
+
* When lazy is enabled:
|
|
20
|
+
* - If content is visible, it will render immediately
|
|
21
|
+
* - If content is not visible, it won't render until it becomes visible
|
|
22
|
+
*
|
|
23
|
+
* Otherwise:
|
|
24
|
+
* - If content is visible, it will render immediately
|
|
25
|
+
* - If content is not visible, it will defer rendering
|
|
26
|
+
*
|
|
27
|
+
* Once rendered, the content remains rendered.
|
|
28
|
+
*/
|
|
29
|
+
export declare function Deferred({ lazy, visible, children }: Props): React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | null;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=Deferred.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Deferred.d.ts","sourceRoot":"","sources":["../../../../src/views/Deferred.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,KAAK,KAAK,GAAG;IACX;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC;CAC9B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,KAAK,iFA0B1D"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { Screen } from '@react-navigation/elements/internal';
|
|
1
2
|
import type { ParamListBase, Route } from '@react-navigation/native';
|
|
2
3
|
import * as React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import type { BottomTabNavigationOptions, BottomTabNavigationProp } from '../types';
|
|
4
|
+
import type { BottomTabNavigationOptions, BottomTabNavigationProp } from '../types.js';
|
|
5
5
|
export declare function ScreenContent({ isFocused, route, navigation, options, style, children, }: {
|
|
6
6
|
isFocused: boolean;
|
|
7
7
|
route: Route<string>;
|
|
8
8
|
navigation: BottomTabNavigationProp<ParamListBase>;
|
|
9
9
|
options: BottomTabNavigationOptions;
|
|
10
|
-
style?:
|
|
10
|
+
style?: React.ComponentProps<typeof Screen>['style'];
|
|
11
11
|
children: React.ReactNode;
|
|
12
|
-
}):
|
|
12
|
+
}): React.JSX.Element;
|
|
13
13
|
//# sourceMappingURL=ScreenContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScreenContent.d.ts","sourceRoot":"","sources":["../../../../src/views/ScreenContent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScreenContent.d.ts","sourceRoot":"","sources":["../../../../src/views/ScreenContent.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EACV,0BAA0B,EAC1B,uBAAuB,EACxB,MAAM,aAAU,CAAC;AAElB,wBAAgB,aAAa,CAAC,EAC5B,SAAS,EACT,KAAK,EACL,UAAU,EACV,OAAO,EACP,KAAK,EACL,QAAQ,GACT,EAAE;IACD,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB,UAAU,EAAE,uBAAuB,CAAC,aAAa,CAAC,CAAC;IACnD,OAAO,EAAE,0BAA0B,CAAC;IACpC,KAAK,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;IACrD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,qBAgCA"}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
+
import { type Icon } from '@react-navigation/elements';
|
|
1
2
|
import { type Route } from '@react-navigation/native';
|
|
2
|
-
import React from 'react';
|
|
3
|
+
import * as React from 'react';
|
|
3
4
|
import { type ColorValue, type StyleProp, type TextStyle, type ViewStyle } from 'react-native';
|
|
4
|
-
import type { BottomTabIcon } from '../types';
|
|
5
5
|
export type TabBarIconProps = {
|
|
6
6
|
route: Route<string>;
|
|
7
7
|
variant: 'uikit' | 'material';
|
|
8
8
|
size: 'compact' | 'regular';
|
|
9
|
-
badge?: string | number;
|
|
10
|
-
badgeStyle?: StyleProp<TextStyle
|
|
9
|
+
badge?: string | number | undefined;
|
|
10
|
+
badgeStyle?: StyleProp<TextStyle> | undefined;
|
|
11
11
|
activeOpacity: number;
|
|
12
12
|
inactiveOpacity: number;
|
|
13
13
|
activeTintColor: ColorValue;
|
|
14
14
|
inactiveTintColor: ColorValue;
|
|
15
|
-
icon:
|
|
15
|
+
icon: Icon | ((props: {
|
|
16
16
|
focused: boolean;
|
|
17
17
|
color: ColorValue;
|
|
18
18
|
size: number;
|
|
19
|
-
}) =>
|
|
20
|
-
allowFontScaling?: boolean;
|
|
19
|
+
}) => Icon | React.ReactNode);
|
|
20
|
+
allowFontScaling?: boolean | undefined;
|
|
21
21
|
style: StyleProp<ViewStyle>;
|
|
22
22
|
};
|
|
23
|
-
export declare function TabBarIcon({ route: _, variant, size, badge, badgeStyle, activeOpacity, inactiveOpacity, activeTintColor, inactiveTintColor, icon, allowFontScaling, style, }: TabBarIconProps):
|
|
23
|
+
export declare function TabBarIcon({ route: _, variant, size, badge, badgeStyle, activeOpacity, inactiveOpacity, activeTintColor, inactiveTintColor, icon, allowFontScaling, style, }: TabBarIconProps): React.JSX.Element;
|
|
24
24
|
//# sourceMappingURL=TabBarIcon.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabBarIcon.d.ts","sourceRoot":"","sources":["../../../../src/views/TabBarIcon.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TabBarIcon.d.ts","sourceRoot":"","sources":["../../../../src/views/TabBarIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,IAAI,EAAgB,MAAM,4BAA4B,CAAC;AAE5E,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EAEd,KAAK,SAAS,EAEd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB,OAAO,EAAE,OAAO,GAAG,UAAU,CAAC;IAC9B,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACpC,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;IAC9C,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,UAAU,CAAC;IAC5B,iBAAiB,EAAE,UAAU,CAAC;IAC9B,IAAI,EACA,IAAI,GACJ,CAAC,CAAC,KAAK,EAAE;QACP,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,EAAE,UAAU,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;KACd,KAAK,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IAClC,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC7B,CAAC;AAcF,wBAAgB,UAAU,CAAC,EACzB,KAAK,EAAE,CAAC,EACR,OAAO,EACP,IAAI,EACJ,KAAK,EACL,UAAU,EACV,aAAa,EACb,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,IAAI,EACJ,gBAAgB,EAChB,KAAK,GACN,EAAE,eAAe,qBAwDjB"}
|
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": "8.0.0-alpha.
|
|
4
|
+
"version": "8.0.0-alpha.50",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native-component",
|
|
7
7
|
"react-component",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"types": "./lib/typescript/src/index.d.ts",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
|
-
"source": "./src/index.tsx",
|
|
24
|
+
"@react-navigation/source": "./src/index.tsx",
|
|
25
25
|
"types": "./lib/typescript/src/index.d.ts",
|
|
26
26
|
"default": "./lib/module/index.js"
|
|
27
27
|
},
|
|
@@ -41,31 +41,31 @@
|
|
|
41
41
|
"clean": "del lib"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@react-navigation/elements": "^3.0.0-alpha.
|
|
45
|
-
"color": "^4.2.3",
|
|
46
|
-
"sf-symbols-typescript": "^2.2.0"
|
|
44
|
+
"@react-navigation/elements": "^3.0.0-alpha.48"
|
|
47
45
|
},
|
|
48
46
|
"devDependencies": {
|
|
49
|
-
"@jest/globals": "^30.
|
|
50
|
-
"@react-navigation/native": "^8.0.0-alpha.
|
|
51
|
-
"@testing-library/
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"react
|
|
57
|
-
"react-native
|
|
58
|
-
"react-native-
|
|
59
|
-
"react-native-
|
|
60
|
-
"react-
|
|
61
|
-
"
|
|
47
|
+
"@jest/globals": "^30.4.1",
|
|
48
|
+
"@react-navigation/native": "^8.0.0-alpha.44",
|
|
49
|
+
"@testing-library/jest-dom": "^7.0.0",
|
|
50
|
+
"@testing-library/react": "^16.3.2",
|
|
51
|
+
"@testing-library/react-native": "^14.0.0",
|
|
52
|
+
"@types/react": "~19.2.17",
|
|
53
|
+
"del-cli": "^7.0.0",
|
|
54
|
+
"react": "19.2.3",
|
|
55
|
+
"react-native": "0.85.3",
|
|
56
|
+
"react-native-builder-bob": "^0.43.0",
|
|
57
|
+
"react-native-safe-area-context": "~5.7.0",
|
|
58
|
+
"react-native-screens": "^4.26.2",
|
|
59
|
+
"react-native-web": "~0.21.2",
|
|
60
|
+
"test-renderer": "1.2.0",
|
|
61
|
+
"typescript": "^6.0.3"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@react-navigation/native": "^8.0.0-alpha.
|
|
65
|
-
"react": ">= 19.
|
|
64
|
+
"@react-navigation/native": "^8.0.0-alpha.44",
|
|
65
|
+
"react": ">= 19.2.0",
|
|
66
66
|
"react-native": "*",
|
|
67
67
|
"react-native-safe-area-context": ">= 5.5.0",
|
|
68
|
-
"react-native-screens": ">= 4.
|
|
68
|
+
"react-native-screens": ">= 4.25.0"
|
|
69
69
|
},
|
|
70
70
|
"react-native-builder-bob": {
|
|
71
71
|
"source": "src",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
]
|
|
86
86
|
]
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "ab1319d6bbf05eae8dc25e33cbf4dc56494e0f0c"
|
|
89
89
|
}
|
package/src/index.tsx
CHANGED
|
@@ -11,6 +11,7 @@ export { SceneStyleInterpolators, TransitionPresets, TransitionSpecs };
|
|
|
11
11
|
* Navigators
|
|
12
12
|
*/
|
|
13
13
|
export {
|
|
14
|
+
type BottomTabTypeBag,
|
|
14
15
|
createBottomTabNavigator,
|
|
15
16
|
createBottomTabScreen,
|
|
16
17
|
} from './navigators/createBottomTabNavigator';
|
|
@@ -19,7 +20,7 @@ export {
|
|
|
19
20
|
* Views
|
|
20
21
|
*/
|
|
21
22
|
export { BottomTabBar } from './views/BottomTabBar';
|
|
22
|
-
export { BottomTabView } from './views/
|
|
23
|
+
export { BottomTabView } from './views/BottomTabView';
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Utilities
|
|
@@ -36,7 +37,6 @@ export type {
|
|
|
36
37
|
BottomTabBarButtonProps,
|
|
37
38
|
BottomTabBarProps,
|
|
38
39
|
BottomTabHeaderProps,
|
|
39
|
-
BottomTabIcon,
|
|
40
40
|
BottomTabNavigationEventMap,
|
|
41
41
|
BottomTabNavigationOptions,
|
|
42
42
|
BottomTabNavigationProp,
|
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createNavigatorFactory,
|
|
3
|
+
createScreenFactory,
|
|
4
|
+
type NavigatorTypeBagBase,
|
|
3
5
|
type ParamListBase,
|
|
4
|
-
StackActions,
|
|
5
|
-
type StaticConfig,
|
|
6
|
-
type StaticParamList,
|
|
7
|
-
type StaticScreenConfig,
|
|
8
|
-
type StaticScreenConfigLinking,
|
|
9
|
-
type StaticScreenConfigScreen,
|
|
10
6
|
type TabActionHelpers,
|
|
11
7
|
type TabNavigationState,
|
|
12
8
|
TabRouter,
|
|
13
9
|
type TabRouterOptions,
|
|
14
|
-
type TypedNavigator,
|
|
15
10
|
useNavigationBuilder,
|
|
16
11
|
} from '@react-navigation/native';
|
|
17
|
-
import * as React from 'react';
|
|
18
12
|
|
|
19
13
|
import type {
|
|
20
14
|
BottomTabNavigationEventMap,
|
|
21
15
|
BottomTabNavigationOptions,
|
|
22
|
-
BottomTabNavigationProp,
|
|
23
16
|
BottomTabNavigatorProps,
|
|
24
17
|
} from '../types';
|
|
25
|
-
import { BottomTabView } from '../views/
|
|
18
|
+
import { BottomTabView } from '../views/BottomTabView';
|
|
26
19
|
|
|
27
20
|
function BottomTabNavigator({
|
|
28
21
|
initialRouteName,
|
|
@@ -55,32 +48,6 @@ function BottomTabNavigator({
|
|
|
55
48
|
router,
|
|
56
49
|
});
|
|
57
50
|
|
|
58
|
-
const focusedRouteKey = state.routes[state.index].key;
|
|
59
|
-
const previousRouteKeyRef = React.useRef(focusedRouteKey);
|
|
60
|
-
|
|
61
|
-
React.useEffect(() => {
|
|
62
|
-
const previousRouteKey = previousRouteKeyRef.current;
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
previousRouteKey !== focusedRouteKey &&
|
|
66
|
-
descriptors[previousRouteKey]?.options.popToTopOnBlur
|
|
67
|
-
) {
|
|
68
|
-
const prevRoute = state.routes.find(
|
|
69
|
-
(route) => route.key === previousRouteKey
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
if (prevRoute?.state?.type === 'stack' && prevRoute.state.key) {
|
|
73
|
-
const popToTopAction = {
|
|
74
|
-
...StackActions.popToTop(),
|
|
75
|
-
target: prevRoute.state.key,
|
|
76
|
-
};
|
|
77
|
-
navigation.dispatch(popToTopAction);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
previousRouteKeyRef.current = focusedRouteKey;
|
|
82
|
-
}, [descriptors, focusedRouteKey, navigation, state.index, state.routes]);
|
|
83
|
-
|
|
84
51
|
return (
|
|
85
52
|
<NavigationContent>
|
|
86
53
|
<BottomTabView
|
|
@@ -93,47 +60,15 @@ function BottomTabNavigator({
|
|
|
93
60
|
);
|
|
94
61
|
}
|
|
95
62
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
State: TabNavigationState<ParamList>;
|
|
63
|
+
export interface BottomTabTypeBag extends NavigatorTypeBagBase {
|
|
64
|
+
State: TabNavigationState<this['ParamList']>;
|
|
99
65
|
ScreenOptions: BottomTabNavigationOptions;
|
|
100
66
|
EventMap: BottomTabNavigationEventMap;
|
|
101
|
-
|
|
102
|
-
[RouteName in keyof ParamList]: BottomTabNavigationProp<
|
|
103
|
-
ParamList,
|
|
104
|
-
RouteName
|
|
105
|
-
>;
|
|
106
|
-
};
|
|
67
|
+
ActionHelpers: TabActionHelpers<this['ParamList']>;
|
|
107
68
|
Navigator: typeof BottomTabNavigator;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
export function createBottomTabNavigator<
|
|
111
|
-
const ParamList extends ParamListBase,
|
|
112
|
-
>(): TypedNavigator<BottomTabTypeBag<ParamList>, undefined>;
|
|
113
|
-
export function createBottomTabNavigator<
|
|
114
|
-
const Config extends StaticConfig<BottomTabTypeBag<ParamListBase>>,
|
|
115
|
-
>(
|
|
116
|
-
config: Config
|
|
117
|
-
): TypedNavigator<
|
|
118
|
-
BottomTabTypeBag<StaticParamList<{ config: Config }>>,
|
|
119
|
-
Config
|
|
120
|
-
>;
|
|
121
|
-
export function createBottomTabNavigator(config?: unknown) {
|
|
122
|
-
return createNavigatorFactory(BottomTabNavigator)(config);
|
|
123
69
|
}
|
|
124
70
|
|
|
125
|
-
export
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
>(
|
|
129
|
-
config: StaticScreenConfig<
|
|
130
|
-
Linking,
|
|
131
|
-
Screen,
|
|
132
|
-
TabNavigationState<ParamListBase>,
|
|
133
|
-
BottomTabNavigationOptions,
|
|
134
|
-
BottomTabNavigationEventMap,
|
|
135
|
-
BottomTabNavigationProp<ParamListBase>
|
|
136
|
-
>
|
|
137
|
-
) {
|
|
138
|
-
return config;
|
|
139
|
-
}
|
|
71
|
+
export const createBottomTabNavigator =
|
|
72
|
+
createNavigatorFactory<BottomTabTypeBag>(BottomTabNavigator);
|
|
73
|
+
|
|
74
|
+
export const createBottomTabScreen = createScreenFactory<BottomTabTypeBag>();
|
package/src/types.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
HeaderOptions,
|
|
3
|
+
Icon,
|
|
3
4
|
PlatformPressable,
|
|
4
5
|
} from '@react-navigation/elements';
|
|
6
|
+
import type { Screen } from '@react-navigation/elements/internal';
|
|
5
7
|
import type {
|
|
6
8
|
DefaultNavigatorOptions,
|
|
7
9
|
Descriptor,
|
|
8
|
-
MaterialSymbolProps,
|
|
9
10
|
NavigationHelpers,
|
|
10
11
|
NavigationProp,
|
|
11
12
|
ParamListBase,
|
|
@@ -20,7 +21,6 @@ import type {
|
|
|
20
21
|
Animated,
|
|
21
22
|
ColorValue,
|
|
22
23
|
GestureResponderEvent,
|
|
23
|
-
ImageSourcePropType,
|
|
24
24
|
StyleProp,
|
|
25
25
|
TextStyle,
|
|
26
26
|
ViewStyle,
|
|
@@ -28,9 +28,8 @@ import type {
|
|
|
28
28
|
import type {
|
|
29
29
|
TabBarItemLabelVisibilityMode,
|
|
30
30
|
TabsScreenBlurEffect,
|
|
31
|
-
|
|
31
|
+
TabsScreenSystemItem,
|
|
32
32
|
} from 'react-native-screens';
|
|
33
|
-
import type { SFSymbol } from 'sf-symbols-typescript';
|
|
34
33
|
|
|
35
34
|
export type Variant = 'uikit' | 'material';
|
|
36
35
|
|
|
@@ -39,6 +38,7 @@ export type BottomTabNavigationEventMap = {
|
|
|
39
38
|
* Event which fires on tapping on the tab in the tab bar.
|
|
40
39
|
*
|
|
41
40
|
* Preventing default is only supported with `custom` implementation.
|
|
41
|
+
* Use `tabBarSelectionEnabled: false` option with `native` implementation.
|
|
42
42
|
*/
|
|
43
43
|
tabPress: { data: undefined; canPreventDefault: true };
|
|
44
44
|
/**
|
|
@@ -114,67 +114,6 @@ export type TabBarVisibilityAnimationConfig =
|
|
|
114
114
|
|
|
115
115
|
export type TabAnimationName = 'none' | 'fade' | 'shift';
|
|
116
116
|
|
|
117
|
-
type IconImage = {
|
|
118
|
-
/**
|
|
119
|
-
* - `image` - Use a local image as the icon.
|
|
120
|
-
*/
|
|
121
|
-
type: 'image';
|
|
122
|
-
/**
|
|
123
|
-
* Image source to use as the icon.
|
|
124
|
-
* e.g., `require('./path/to/image.png')`
|
|
125
|
-
*/
|
|
126
|
-
source: ImageSourcePropType;
|
|
127
|
-
/**
|
|
128
|
-
* Whether to apply tint color to the icon.
|
|
129
|
-
* Defaults to `true`.
|
|
130
|
-
*
|
|
131
|
-
* @platform ios
|
|
132
|
-
*/
|
|
133
|
-
tinted?: boolean;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
type IconSfSymbol = {
|
|
137
|
-
/**
|
|
138
|
-
* - `sfSymbol` - Use an SF Symbol as the icon on iOS.
|
|
139
|
-
*/
|
|
140
|
-
type: 'sfSymbol';
|
|
141
|
-
/**
|
|
142
|
-
* Name of the SF Symbol to use as the icon.
|
|
143
|
-
*/
|
|
144
|
-
name: SFSymbol;
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
type IconMaterialSymbol = {
|
|
148
|
-
/**
|
|
149
|
-
* - `materialSymbol` - Use a Material Symbol as the icon on Android.
|
|
150
|
-
*/
|
|
151
|
-
type: 'materialSymbol';
|
|
152
|
-
} & Pick<MaterialSymbolProps, 'name' | 'variant' | 'weight'>;
|
|
153
|
-
|
|
154
|
-
type IconResource = {
|
|
155
|
-
/**
|
|
156
|
-
* - `resource` - Use a resource from drawables on Android and xcassets asset catalog on iOS as the icon.
|
|
157
|
-
*/
|
|
158
|
-
type: 'resource';
|
|
159
|
-
/**
|
|
160
|
-
* Name of the drawable resource or xcasset to use as the icon.
|
|
161
|
-
*/
|
|
162
|
-
name: string;
|
|
163
|
-
/**
|
|
164
|
-
* Whether to apply tint color to the icon.
|
|
165
|
-
* Only supported with custom implementation.
|
|
166
|
-
*
|
|
167
|
-
* Defaults to `true`.
|
|
168
|
-
*/
|
|
169
|
-
tinted?: boolean;
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
type IconIOS = IconSfSymbol | IconImage;
|
|
173
|
-
|
|
174
|
-
type IconAndroid = IconMaterialSymbol | IconResource | IconImage;
|
|
175
|
-
|
|
176
|
-
export type BottomTabIcon = IconIOS | IconAndroid;
|
|
177
|
-
|
|
178
117
|
type BottomTabCustomOptions = {
|
|
179
118
|
/**
|
|
180
119
|
* How the screen should animate when switching tabs.
|
|
@@ -212,7 +151,7 @@ type BottomTabCustomOptions = {
|
|
|
212
151
|
*
|
|
213
152
|
* Only supported with `custom` implementation.
|
|
214
153
|
*/
|
|
215
|
-
tabBarLabelPosition?: LabelPosition;
|
|
154
|
+
tabBarLabelPosition?: LabelPosition | undefined;
|
|
216
155
|
|
|
217
156
|
/**
|
|
218
157
|
* Whether label font should scale to respect Text Size accessibility settings.
|
|
@@ -311,8 +250,6 @@ type BottomTabCustomOptions = {
|
|
|
311
250
|
tabBarButton?: (props: BottomTabBarButtonProps) => React.ReactNode;
|
|
312
251
|
};
|
|
313
252
|
|
|
314
|
-
type ScrollEdgeEffect = 'auto' | 'hard' | 'soft' | 'hidden';
|
|
315
|
-
|
|
316
253
|
type BottomTabNativeOptions = {
|
|
317
254
|
/**
|
|
318
255
|
* Uses iOS built-in tab bar items with standard iOS styling and localized titles.
|
|
@@ -324,7 +261,7 @@ type BottomTabNativeOptions = {
|
|
|
324
261
|
*
|
|
325
262
|
* @platform ios
|
|
326
263
|
*/
|
|
327
|
-
tabBarSystemItem?:
|
|
264
|
+
tabBarSystemItem?: TabsScreenSystemItem;
|
|
328
265
|
|
|
329
266
|
/**
|
|
330
267
|
* Blur effect applied to the tab bar when tab screen is selected.
|
|
@@ -410,36 +347,25 @@ type BottomTabNativeOptions = {
|
|
|
410
347
|
}) => React.ReactNode;
|
|
411
348
|
|
|
412
349
|
/**
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
* for the specified edge of the ScrollView.
|
|
416
|
-
*
|
|
417
|
-
* When set in nested containers, i.e. Native Stack inside Native Bottom Tabs, or the other way around,
|
|
418
|
-
* the ScrollView will use only the innermost one's config.
|
|
419
|
-
*
|
|
420
|
-
* **Note:** Using both `headerBlurEffect` and `scrollEdgeEffects` (>= iOS 26) simultaneously may cause overlapping effects.
|
|
350
|
+
* Specifies whether `contentInsetAdjustmentBehavior` of the `ScrollView`
|
|
351
|
+
* in the screen is automatically adjusted.
|
|
421
352
|
*
|
|
422
|
-
*
|
|
353
|
+
* `react-native`'s `ScrollView`s has `contentInsetAdjustmentBehavior` set to `never` by default.
|
|
354
|
+
* To provide a better UX, it is overridden to `automatic` - so it respects the tab bar.
|
|
355
|
+
* Otherwise, content can get hidden behind the tab bar as it's translucent on iOS 26+.
|
|
423
356
|
*
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
* - `soft` - a soft-edged scroll edge effect,
|
|
427
|
-
* - `hidden` - no scroll edge effect.
|
|
357
|
+
* Note that this only affects the `ScrollView` in first descendant chain of the screen,
|
|
358
|
+
* i.e., first view of each nested view is checked until a `ScrollView` is found.
|
|
428
359
|
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
* Available starting from iOS 26.
|
|
360
|
+
* To disable this behavior for specific screens, set this option to `false`.
|
|
432
361
|
*
|
|
433
362
|
* Only supported with `native` implementation.
|
|
434
363
|
*
|
|
364
|
+
* Defaults to `true`.
|
|
365
|
+
*
|
|
435
366
|
* @platform ios
|
|
436
367
|
*/
|
|
437
|
-
|
|
438
|
-
bottom?: ScrollEdgeEffect;
|
|
439
|
-
left?: ScrollEdgeEffect;
|
|
440
|
-
right?: ScrollEdgeEffect;
|
|
441
|
-
top?: ScrollEdgeEffect;
|
|
442
|
-
};
|
|
368
|
+
overrideScrollViewContentInsetAdjustmentBehavior?: boolean;
|
|
443
369
|
};
|
|
444
370
|
|
|
445
371
|
export type BottomTabNavigationOptions = {
|
|
@@ -481,7 +407,7 @@ export type BottomTabNavigationOptions = {
|
|
|
481
407
|
*/
|
|
482
408
|
tabBarLabelStyle?: Pick<
|
|
483
409
|
TextStyle,
|
|
484
|
-
'fontFamily' | 'fontSize' | 'fontWeight' | 'fontStyle'
|
|
410
|
+
'fontFamily' | 'fontSize' | 'fontWeight' | 'fontStyle' | 'color'
|
|
485
411
|
>;
|
|
486
412
|
|
|
487
413
|
/**
|
|
@@ -493,26 +419,30 @@ export type BottomTabNavigationOptions = {
|
|
|
493
419
|
* - on all platforms with `custom` implementation
|
|
494
420
|
* - on iOS with `native` implementation
|
|
495
421
|
*
|
|
422
|
+
* With `native` implementation, `tinted` for `image` can only be disabled on iOS.
|
|
423
|
+
*
|
|
496
424
|
* A React element is only supported with `custom` implementation.
|
|
497
425
|
*/
|
|
498
426
|
tabBarIcon?:
|
|
499
|
-
|
|
|
427
|
+
| Icon
|
|
500
428
|
| ((props: {
|
|
501
429
|
focused: boolean;
|
|
502
430
|
color: ColorValue;
|
|
503
431
|
size: number;
|
|
504
|
-
}) =>
|
|
432
|
+
}) => Icon | React.ReactNode);
|
|
505
433
|
|
|
506
434
|
/**
|
|
507
435
|
* Text to show in a badge on the tab icon.
|
|
508
436
|
*/
|
|
509
|
-
tabBarBadge?: number | string;
|
|
437
|
+
tabBarBadge?: number | string | undefined;
|
|
510
438
|
|
|
511
439
|
/**
|
|
512
440
|
* Custom style for the tab bar badge.
|
|
513
441
|
* You can specify a background color or text color here.
|
|
514
442
|
*
|
|
515
|
-
*
|
|
443
|
+
* With `native` implementation, limited customization is supported:
|
|
444
|
+
* - on iOS, you can only set the background color.
|
|
445
|
+
* - on Android, you can set both background and text colors.
|
|
516
446
|
*/
|
|
517
447
|
tabBarBadgeStyle?: {
|
|
518
448
|
backgroundColor?: ColorValue;
|
|
@@ -522,7 +452,7 @@ export type BottomTabNavigationOptions = {
|
|
|
522
452
|
/**
|
|
523
453
|
* Color for the icon and label in the active tab.
|
|
524
454
|
*/
|
|
525
|
-
tabBarActiveTintColor?: ColorValue;
|
|
455
|
+
tabBarActiveTintColor?: ColorValue | undefined;
|
|
526
456
|
|
|
527
457
|
/**
|
|
528
458
|
* Color for the icon and label in the inactive tabs.
|
|
@@ -582,11 +512,31 @@ export type BottomTabNavigationOptions = {
|
|
|
582
512
|
* Only supported on iOS 18 and below.
|
|
583
513
|
*/
|
|
584
514
|
shadowColor?: ColorValue;
|
|
515
|
+
/**
|
|
516
|
+
* Whether the tab bar is visible.
|
|
517
|
+
* Setting this to `'none'` hides the tab bar.
|
|
518
|
+
*/
|
|
519
|
+
display?: 'flex' | 'none';
|
|
585
520
|
};
|
|
586
521
|
|
|
587
522
|
/**
|
|
588
|
-
* Whether this
|
|
589
|
-
*
|
|
523
|
+
* Whether this tab can be selected.
|
|
524
|
+
* When `false`, tapping on the tab in tab bar won't select the tab.
|
|
525
|
+
* Custom behavior can be implemented by listening to `tabPress` event.
|
|
526
|
+
*
|
|
527
|
+
* Defaults to `true`.
|
|
528
|
+
*/
|
|
529
|
+
tabBarSelectionEnabled?: boolean;
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Whether this screen should render only when first accessed.
|
|
533
|
+
*
|
|
534
|
+
* Defaults to:
|
|
535
|
+
* - `true` with custom implementation.
|
|
536
|
+
* - `false` with native implementation.
|
|
537
|
+
*
|
|
538
|
+
* Enabling in native implementation may result in flicker
|
|
539
|
+
* as React renders after native transition is already finished.
|
|
590
540
|
*/
|
|
591
541
|
lazy?: boolean;
|
|
592
542
|
|
|
@@ -599,7 +549,7 @@ export type BottomTabNavigationOptions = {
|
|
|
599
549
|
/**
|
|
600
550
|
* Style object for the component wrapping the screen content.
|
|
601
551
|
*/
|
|
602
|
-
sceneStyle?:
|
|
552
|
+
sceneStyle?: React.ComponentProps<typeof Screen>['style'];
|
|
603
553
|
|
|
604
554
|
/**
|
|
605
555
|
* Function that returns a React Element to display as a header.
|
|
@@ -612,6 +562,19 @@ export type BottomTabNavigationOptions = {
|
|
|
612
562
|
* Defaults to `false` unless a header is provided.
|
|
613
563
|
*/
|
|
614
564
|
headerShown?: boolean;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* What should happen when screens become inactive.
|
|
568
|
+
* - `pause`: Effects are cleaned up.
|
|
569
|
+
* - `none`: Screen renders normally
|
|
570
|
+
*
|
|
571
|
+
* Defaults to `pause`.
|
|
572
|
+
*
|
|
573
|
+
* If you set `lazy: false` or preload a screen,
|
|
574
|
+
* It won't be paused until after the first time it becomes focused.
|
|
575
|
+
* This makes sure that effects are run to initialize the screen.
|
|
576
|
+
*/
|
|
577
|
+
inactiveBehavior?: 'pause' | 'none';
|
|
615
578
|
} & HeaderOptions &
|
|
616
579
|
BottomTabNativeOptions &
|
|
617
580
|
BottomTabCustomOptions;
|
|
@@ -655,14 +618,14 @@ export type TransitionSpec =
|
|
|
655
618
|
animation: 'timing';
|
|
656
619
|
config: Omit<
|
|
657
620
|
Animated.TimingAnimationConfig,
|
|
658
|
-
'toValue' |
|
|
621
|
+
'toValue' | 'useNativeDriver'
|
|
659
622
|
>;
|
|
660
623
|
}
|
|
661
624
|
| {
|
|
662
625
|
animation: 'spring';
|
|
663
626
|
config: Omit<
|
|
664
627
|
Animated.SpringAnimationConfig,
|
|
665
|
-
'toValue' |
|
|
628
|
+
'toValue' | 'useNativeDriver'
|
|
666
629
|
>;
|
|
667
630
|
};
|
|
668
631
|
|
|
@@ -702,15 +665,6 @@ export type BottomTabNavigationConfig = {
|
|
|
702
665
|
* Function that returns a React element to display as the tab bar.
|
|
703
666
|
*/
|
|
704
667
|
tabBar?: (props: BottomTabBarProps) => React.ReactNode;
|
|
705
|
-
|
|
706
|
-
/**
|
|
707
|
-
* Whether inactive screens should be detached from the view hierarchy to save memory.
|
|
708
|
-
*
|
|
709
|
-
* Defaults to `true`.
|
|
710
|
-
*
|
|
711
|
-
* Only supported with `custom` implementation.
|
|
712
|
-
*/
|
|
713
|
-
detachInactiveScreens?: boolean;
|
|
714
668
|
};
|
|
715
669
|
|
|
716
670
|
export type BottomTabHeaderProps = {
|
|
@@ -738,7 +692,7 @@ export type BottomTabBarButtonProps = Omit<
|
|
|
738
692
|
React.ComponentProps<typeof PlatformPressable>,
|
|
739
693
|
'style'
|
|
740
694
|
> & {
|
|
741
|
-
href?: string;
|
|
695
|
+
href?: string | undefined;
|
|
742
696
|
children: React.ReactNode;
|
|
743
697
|
style?: StyleProp<ViewStyle>;
|
|
744
698
|
onPress?: (
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { BottomTabAnimationContext } from './BottomTabAnimationContext';
|
|
4
4
|
|
|
5
5
|
export function useBottomTabAnimation() {
|
|
6
|
-
const animation = React.
|
|
6
|
+
const animation = React.use(BottomTabAnimationContext);
|
|
7
7
|
|
|
8
8
|
if (animation === undefined) {
|
|
9
9
|
throw new Error(
|