@onekeyfe/react-native-bottom-tabs 6.7.0-20 → 6.7.0-22
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/android/build.gradle +1 -1
- package/android/src/main/java/com/onekey/bottomtabs/BottomBarBlurRenderer.kt +50 -30
- package/android/src/main/java/com/onekey/bottomtabs/BottomTabsView.kt +82 -11
- package/android/src/main/java/com/onekey/bottomtabs/SharedSvgDecoder.kt +51 -0
- package/docs/SPEC.md +69 -18
- package/ios/RCTBottomAccessoryContainerView.swift +2 -0
- package/ios/RCTBottomTabsContainerView.swift +216 -12
- package/ios/SVG/SvgDecoder.mm +7 -3
- package/ios/TabBarFontSize.swift +2 -0
- package/lib/module/BottomAccessoryViewNativeComponent.ts +10 -10
- package/lib/module/BottomTabs.js +77 -53
- package/lib/module/BottomTabsDrawerNativeComponent.ts +12 -12
- package/lib/module/BottomTabsNativeComponent.ts +22 -23
- package/lib/typescript/src/BottomAccessoryView.d.ts +1 -1
- package/lib/typescript/src/BottomAccessoryViewNativeComponent.d.ts +6 -7
- package/lib/typescript/src/BottomTabs.d.ts +12 -6
- package/lib/typescript/src/BottomTabsDrawerNativeComponent.d.ts +8 -9
- package/lib/typescript/src/BottomTabsDrawerNativeComponent.web.d.ts +1 -1
- package/lib/typescript/src/BottomTabsNativeComponent.d.ts +15 -16
- package/lib/typescript/src/DelayedFreeze.d.ts +1 -1
- package/lib/typescript/src/SceneMap.d.ts +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/types.d.ts +6 -2
- package/package.json +5 -4
- package/react-native-bottom-tabs.podspec +2 -0
- package/src/BottomAccessoryViewNativeComponent.ts +10 -10
- package/src/BottomTabs.tsx +111 -54
- package/src/BottomTabsDrawerNativeComponent.ts +12 -12
- package/src/BottomTabsNativeComponent.ts +22 -23
- package/src/index.tsx +7 -1
- package/src/types.ts +10 -2
- package/ios/SVG/CoreSVG.h +0 -13
- package/ios/SVG/CoreSVG.mm +0 -177
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { DirectEventHandler, Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
1
|
+
import { type CodegenTypes, type ViewProps } from 'react-native';
|
|
3
2
|
export type OnNativeLayout = Readonly<{
|
|
4
|
-
width: Double;
|
|
5
|
-
height: Double;
|
|
3
|
+
width: CodegenTypes.Double;
|
|
4
|
+
height: CodegenTypes.Double;
|
|
6
5
|
}>;
|
|
7
6
|
export type OnPlacementChanged = Readonly<{
|
|
8
7
|
placement: string;
|
|
9
8
|
}>;
|
|
10
9
|
export interface BottomAccessoryViewNativeProps extends ViewProps {
|
|
11
|
-
onNativeLayout?: DirectEventHandler<OnNativeLayout>;
|
|
12
|
-
onPlacementChanged?: DirectEventHandler<OnPlacementChanged>;
|
|
10
|
+
onNativeLayout?: CodegenTypes.DirectEventHandler<OnNativeLayout>;
|
|
11
|
+
onPlacementChanged?: CodegenTypes.DirectEventHandler<OnPlacementChanged>;
|
|
13
12
|
}
|
|
14
|
-
declare const _default: import("react-native
|
|
13
|
+
declare const _default: import("react-native").HostComponent<BottomAccessoryViewNativeProps>;
|
|
15
14
|
export default _default;
|
|
16
15
|
//# sourceMappingURL=BottomAccessoryViewNativeComponent.d.ts.map
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { type ColorValue, type ImageSourcePropType, type StyleProp, type ViewStyle } from "react-native";
|
|
3
|
-
import type {
|
|
4
|
-
import type { AppleIcon, BaseRoute, NavigationState, TabBarPlacement, TabRole } from "./types";
|
|
3
|
+
import type { BaseRoute, BottomTabIconSource, NamedIcon, NavigationState, TabBarPlacement, TabRole } from "./types";
|
|
5
4
|
import { type RNBottomTabsAccessoryViewProps } from "./BottomAccessoryView";
|
|
5
|
+
type ResolvedTabIconSource = {
|
|
6
|
+
uri: string;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
scale: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const resolveTabIconSource: (icon: BottomTabIconSource | undefined | null) => ResolvedTabIconSource;
|
|
6
12
|
interface Props<Route extends BaseRoute> {
|
|
7
13
|
labeled?: boolean;
|
|
8
14
|
/** Optional physical-left menu; all motion and input are owned by native. */
|
|
@@ -120,10 +126,10 @@ interface Props<Route extends BaseRoute> {
|
|
|
120
126
|
/**
|
|
121
127
|
* Get icon for the tab.
|
|
122
128
|
*/
|
|
123
|
-
getIcon?: (
|
|
129
|
+
getIcon?: ({ route, focused, }: {
|
|
124
130
|
route: Route;
|
|
125
131
|
focused: boolean;
|
|
126
|
-
}) =>
|
|
132
|
+
}) => BottomTabIconSource | undefined | null;
|
|
127
133
|
/**
|
|
128
134
|
* Get hidden for the tab.
|
|
129
135
|
*/
|
|
@@ -220,7 +226,7 @@ interface Props<Route extends BaseRoute> {
|
|
|
220
226
|
* Icon of a round button shown above a vertical tab bar. The button only
|
|
221
227
|
* appears while the tab bar is vertical and visible. iOS only.
|
|
222
228
|
*/
|
|
223
|
-
sideAccessoryIcon?: ImageSourcePropType;
|
|
229
|
+
sideAccessoryIcon?: ImageSourcePropType | NamedIcon | string;
|
|
224
230
|
/**
|
|
225
231
|
* Accessibility label of the side accessory button.
|
|
226
232
|
*/
|
|
@@ -230,6 +236,6 @@ interface Props<Route extends BaseRoute> {
|
|
|
230
236
|
*/
|
|
231
237
|
onSideAccessoryPress?: () => void;
|
|
232
238
|
}
|
|
233
|
-
declare const BottomTabs: <Route extends BaseRoute>({ navigationState, renderScene, renderLazyPlaceholder, onIndexChange, onTabDoublePress, renderDrawerContent, drawerOpen, drawerSwipeEnabled, onDrawerOpenChange, rippleColor, tabBarActiveTintColor: activeTintColor, tabBarInactiveTintColor: inactiveTintColor, getBadge, getBadgeBackgroundColor, getBadgeTextColor, getLazy, getLabelText, getIcon, getHidden, getActiveTintColor, getTestID, getRole, getSceneStyle, getPreventsDefault, hapticFeedbackEnabled, labeled, getFreezeOnBlur, tabBar: renderCustomTabBar, tabBarStyle, tabLabelStyle, renderBottomAccessoryView, activeIndicatorColor, androidBottomBlurEnabled, delayedFreeze, onTabBarPlacementChange, sideAccessoryIcon, sideAccessoryLabel, onSideAccessoryPress, ...props }: Props<Route>) =>
|
|
239
|
+
declare const BottomTabs: <Route extends BaseRoute>({ navigationState, renderScene, renderLazyPlaceholder, onIndexChange, onTabDoublePress, renderDrawerContent, drawerOpen, drawerSwipeEnabled, onDrawerOpenChange, rippleColor, tabBarActiveTintColor: activeTintColor, tabBarInactiveTintColor: inactiveTintColor, getBadge, getBadgeBackgroundColor, getBadgeTextColor, getLazy, getLabelText, getIcon, getHidden, getActiveTintColor, getTestID, getRole, getSceneStyle, getPreventsDefault, hapticFeedbackEnabled, labeled, getFreezeOnBlur, tabBar: renderCustomTabBar, tabBarStyle, tabLabelStyle, renderBottomAccessoryView, activeIndicatorColor, androidBottomBlurEnabled, delayedFreeze, onTabBarPlacementChange, sideAccessoryIcon, sideAccessoryLabel, onSideAccessoryPress, ...props }: Props<Route>) => React.JSX.Element;
|
|
234
240
|
export default BottomTabs;
|
|
235
241
|
//# sourceMappingURL=BottomTabs.d.ts.map
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { type ViewProps } from "react-native";
|
|
2
|
-
import type { DirectEventHandler, Double, WithDefault } from "react-native/Libraries/Types/CodegenTypes";
|
|
1
|
+
import { type CodegenTypes, type ViewProps } from "react-native";
|
|
3
2
|
export interface BottomTabsDrawerNativeProps extends ViewProps {
|
|
4
|
-
enabled?: WithDefault<boolean, false>;
|
|
5
|
-
open?: WithDefault<boolean, false>;
|
|
6
|
-
swipeEnabled?: WithDefault<boolean, false>;
|
|
7
|
-
hapticFeedbackEnabled?: WithDefault<boolean, false>;
|
|
8
|
-
bottomBarHeight?: Double;
|
|
9
|
-
onDrawerOpenChange?: DirectEventHandler<Readonly<{
|
|
3
|
+
enabled?: CodegenTypes.WithDefault<boolean, false>;
|
|
4
|
+
open?: CodegenTypes.WithDefault<boolean, false>;
|
|
5
|
+
swipeEnabled?: CodegenTypes.WithDefault<boolean, false>;
|
|
6
|
+
hapticFeedbackEnabled?: CodegenTypes.WithDefault<boolean, false>;
|
|
7
|
+
bottomBarHeight?: CodegenTypes.Double;
|
|
8
|
+
onDrawerOpenChange?: CodegenTypes.DirectEventHandler<Readonly<{
|
|
10
9
|
open: boolean;
|
|
11
10
|
}>>;
|
|
12
11
|
}
|
|
13
|
-
declare const _default: import("react-native
|
|
12
|
+
declare const _default: import("react-native").HostComponent<BottomTabsDrawerNativeProps>;
|
|
14
13
|
export default _default;
|
|
15
14
|
//# sourceMappingURL=BottomTabsDrawerNativeComponent.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { BottomTabsDrawerNativeProps } from "./BottomTabsDrawerNativeComponent";
|
|
3
|
-
export default function BottomTabsDrawerWeb({ children, }: React.PropsWithChildren<BottomTabsDrawerNativeProps>):
|
|
3
|
+
export default function BottomTabsDrawerWeb({ children, }: React.PropsWithChildren<BottomTabsDrawerNativeProps>): React.JSX.Element;
|
|
4
4
|
//# sourceMappingURL=BottomTabsDrawerNativeComponent.web.d.ts.map
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { DirectEventHandler, Double, Int32, WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
|
|
1
|
+
import { type CodegenTypes, type ColorValue, type ProcessedColorValue, type ViewProps } from 'react-native';
|
|
3
2
|
import type { ImageSource } from 'react-native/Libraries/Image/ImageSource';
|
|
4
3
|
export type OnPageSelectedEventData = Readonly<{
|
|
5
4
|
key: string;
|
|
6
5
|
}>;
|
|
7
6
|
export type OnTabBarMeasured = Readonly<{
|
|
8
|
-
height: Int32;
|
|
7
|
+
height: CodegenTypes.Int32;
|
|
9
8
|
}>;
|
|
10
9
|
export type OnNativeLayout = Readonly<{
|
|
11
|
-
width: Double;
|
|
12
|
-
height: Double;
|
|
10
|
+
width: CodegenTypes.Double;
|
|
11
|
+
height: CodegenTypes.Double;
|
|
13
12
|
}>;
|
|
14
13
|
export type OnTabBarPlacementChange = Readonly<{
|
|
15
14
|
placement: string;
|
|
@@ -31,10 +30,10 @@ export type BottomTabsItems = ReadonlyArray<{
|
|
|
31
30
|
export interface BottomTabsNativeProps extends ViewProps {
|
|
32
31
|
items: BottomTabsItems;
|
|
33
32
|
selectedPage: string;
|
|
34
|
-
onPageSelected?: DirectEventHandler<OnPageSelectedEventData>;
|
|
35
|
-
onTabDoublePress?: DirectEventHandler<OnPageSelectedEventData>;
|
|
36
|
-
onTabBarMeasured?: DirectEventHandler<OnTabBarMeasured>;
|
|
37
|
-
onNativeLayout?: DirectEventHandler<OnNativeLayout>;
|
|
33
|
+
onPageSelected?: CodegenTypes.DirectEventHandler<OnPageSelectedEventData>;
|
|
34
|
+
onTabDoublePress?: CodegenTypes.DirectEventHandler<OnPageSelectedEventData>;
|
|
35
|
+
onTabBarMeasured?: CodegenTypes.DirectEventHandler<OnTabBarMeasured>;
|
|
36
|
+
onNativeLayout?: CodegenTypes.DirectEventHandler<OnNativeLayout>;
|
|
38
37
|
icons?: ReadonlyArray<ImageSource>;
|
|
39
38
|
selectedIcons?: ReadonlyArray<ImageSource>;
|
|
40
39
|
tabBarHidden?: boolean;
|
|
@@ -42,8 +41,8 @@ export interface BottomTabsNativeProps extends ViewProps {
|
|
|
42
41
|
sidebarAdaptable?: boolean;
|
|
43
42
|
scrollEdgeAppearance?: string;
|
|
44
43
|
barTintColor?: ColorValue;
|
|
45
|
-
translucent?: WithDefault<boolean, true>;
|
|
46
|
-
androidBottomBlurEnabled?: WithDefault<boolean, false>;
|
|
44
|
+
translucent?: CodegenTypes.WithDefault<boolean, true>;
|
|
45
|
+
androidBottomBlurEnabled?: CodegenTypes.WithDefault<boolean, false>;
|
|
47
46
|
rippleColor?: ColorValue;
|
|
48
47
|
activeTintColor?: ColorValue;
|
|
49
48
|
inactiveTintColor?: ColorValue;
|
|
@@ -53,14 +52,14 @@ export interface BottomTabsNativeProps extends ViewProps {
|
|
|
53
52
|
minimizeBehavior?: string;
|
|
54
53
|
fontFamily?: string;
|
|
55
54
|
fontWeight?: string;
|
|
56
|
-
fontSize?: Int32;
|
|
55
|
+
fontSize?: CodegenTypes.Int32;
|
|
57
56
|
ignoreBottomInsets?: boolean;
|
|
58
|
-
androidTabBarStyle?: WithDefault<'default' | 'floating', 'default'>;
|
|
59
|
-
ignoreKeyboardInsets?: WithDefault<boolean, true>;
|
|
60
|
-
onTabBarPlacementChange?: DirectEventHandler<OnTabBarPlacementChange>;
|
|
57
|
+
androidTabBarStyle?: CodegenTypes.WithDefault<'default' | 'floating', 'default'>;
|
|
58
|
+
ignoreKeyboardInsets?: CodegenTypes.WithDefault<boolean, true>;
|
|
59
|
+
onTabBarPlacementChange?: CodegenTypes.DirectEventHandler<OnTabBarPlacementChange>;
|
|
61
60
|
sideAccessoryIcon?: ImageSource;
|
|
62
61
|
sideAccessoryLabel?: string;
|
|
63
|
-
onSideAccessoryPress?: DirectEventHandler<OnSideAccessoryPress>;
|
|
62
|
+
onSideAccessoryPress?: CodegenTypes.DirectEventHandler<OnSideAccessoryPress>;
|
|
64
63
|
}
|
|
65
64
|
declare const _default: import("react-native").HostComponent<BottomTabsNativeProps>;
|
|
66
65
|
export default _default;
|
|
@@ -4,6 +4,6 @@ interface FreezeWrapperProps {
|
|
|
4
4
|
delayedFreeze?: boolean;
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
}
|
|
7
|
-
declare function DelayedFreeze({ freeze, delayedFreeze, children }: FreezeWrapperProps):
|
|
7
|
+
declare function DelayedFreeze({ freeze, delayedFreeze, children }: FreezeWrapperProps): React.JSX.Element;
|
|
8
8
|
export default DelayedFreeze;
|
|
9
9
|
//# sourceMappingURL=DelayedFreeze.d.ts.map
|
|
@@ -5,6 +5,6 @@ type SceneProps = {
|
|
|
5
5
|
};
|
|
6
6
|
export declare function SceneMap<T>(scenes: {
|
|
7
7
|
[key: string]: React.ComponentType<T>;
|
|
8
|
-
}): ({ route, jumpTo }: SceneProps) =>
|
|
8
|
+
}): ({ route, jumpTo }: SceneProps) => React.JSX.Element | null;
|
|
9
9
|
export {};
|
|
10
10
|
//# sourceMappingURL=SceneMap.d.ts.map
|
|
@@ -12,5 +12,5 @@ export { BottomTabBarHeightContext } from './utils/BottomTabBarHeightContext';
|
|
|
12
12
|
/**
|
|
13
13
|
* Types
|
|
14
14
|
*/
|
|
15
|
-
export type { AppleIcon, TabBarPlacement, TabRole } from './types';
|
|
15
|
+
export type { AppleIcon, BottomTabIconSource, NamedIcon, TabBarPlacement, TabRole, } from './types';
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -4,6 +4,10 @@ export type IconSource = string | ImageSourcePropType;
|
|
|
4
4
|
export type AppleIcon = {
|
|
5
5
|
sfSymbol: SFSymbol;
|
|
6
6
|
};
|
|
7
|
+
export type NamedIcon = {
|
|
8
|
+
iconName: string;
|
|
9
|
+
};
|
|
10
|
+
export type BottomTabIconSource = ImageSourcePropType | AppleIcon | NamedIcon | string;
|
|
7
11
|
export type TabRole = 'search';
|
|
8
12
|
export type TabBarPlacement = 'bottom' | 'leading' | 'trailing';
|
|
9
13
|
export type BaseRoute = {
|
|
@@ -13,8 +17,8 @@ export type BaseRoute = {
|
|
|
13
17
|
badgeBackgroundColor?: string;
|
|
14
18
|
badgeTextColor?: string;
|
|
15
19
|
lazy?: boolean;
|
|
16
|
-
focusedIcon?:
|
|
17
|
-
unfocusedIcon?:
|
|
20
|
+
focusedIcon?: BottomTabIconSource;
|
|
21
|
+
unfocusedIcon?: BottomTabIconSource;
|
|
18
22
|
activeTintColor?: string;
|
|
19
23
|
hidden?: boolean;
|
|
20
24
|
testID?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-bottom-tabs",
|
|
3
|
-
"version": "6.7.0-
|
|
3
|
+
"version": "6.7.0-22",
|
|
4
4
|
"description": "Native bottom tabs (tab bar + scene container) for React Native on iOS and Android",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/module/index.js",
|
|
@@ -64,13 +64,14 @@
|
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@types/react": "^19.
|
|
68
|
-
"react": "19.
|
|
69
|
-
"react-native": "patch:react-native@npm%3A0.
|
|
67
|
+
"@types/react": "^19.3.0",
|
|
68
|
+
"react": "19.3.0",
|
|
69
|
+
"react-native": "patch:react-native@npm%3A0.88.0#~/.yarn/patches/react-native-npm-0.88.0-60c6201dd2.patch",
|
|
70
70
|
"react-native-builder-bob": "^0.40.13",
|
|
71
71
|
"typescript": "^5.9.2"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
+
"@onekeyfe/react-native-image": "6.7.0-22",
|
|
74
75
|
"react": "*",
|
|
75
76
|
"react-native": "*"
|
|
76
77
|
},
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {
|
|
2
|
+
codegenNativeComponent,
|
|
3
|
+
type CodegenTypes,
|
|
4
|
+
type ViewProps,
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
|
|
7
7
|
|
|
8
8
|
export type OnNativeLayout = Readonly<{
|
|
9
|
-
width: Double;
|
|
10
|
-
height: Double;
|
|
9
|
+
width: CodegenTypes.Double;
|
|
10
|
+
height: CodegenTypes.Double;
|
|
11
11
|
}>;
|
|
12
12
|
|
|
13
13
|
export type OnPlacementChanged = Readonly<{
|
|
@@ -15,8 +15,8 @@ export type OnPlacementChanged = Readonly<{
|
|
|
15
15
|
}>;
|
|
16
16
|
|
|
17
17
|
export interface BottomAccessoryViewNativeProps extends ViewProps {
|
|
18
|
-
onNativeLayout?: DirectEventHandler<OnNativeLayout>;
|
|
19
|
-
onPlacementChanged?: DirectEventHandler<OnPlacementChanged>;
|
|
18
|
+
onNativeLayout?: CodegenTypes.DirectEventHandler<OnNativeLayout>;
|
|
19
|
+
onPlacementChanged?: CodegenTypes.DirectEventHandler<OnPlacementChanged>;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export default codegenNativeComponent<BottomAccessoryViewNativeProps>(
|
package/src/BottomTabs.tsx
CHANGED
|
@@ -13,9 +13,6 @@ import {
|
|
|
13
13
|
processColor,
|
|
14
14
|
} from "react-native";
|
|
15
15
|
import { BottomTabBarHeightContext } from "./utils/BottomTabBarHeightContext";
|
|
16
|
-
|
|
17
|
-
// eslint-disable-next-line @react-native/no-deep-imports
|
|
18
|
-
import type { ImageSource } from "react-native/Libraries/Image/ImageSource";
|
|
19
16
|
import NativeBottomTabs, {
|
|
20
17
|
type BottomTabsItems,
|
|
21
18
|
} from "./BottomTabsNativeComponent";
|
|
@@ -23,6 +20,8 @@ import useLatestCallback from "use-latest-callback";
|
|
|
23
20
|
import type {
|
|
24
21
|
AppleIcon,
|
|
25
22
|
BaseRoute,
|
|
23
|
+
BottomTabIconSource,
|
|
24
|
+
NamedIcon,
|
|
26
25
|
NavigationState,
|
|
27
26
|
TabBarPlacement,
|
|
28
27
|
TabRole,
|
|
@@ -34,8 +33,87 @@ import {
|
|
|
34
33
|
type RNBottomTabsAccessoryViewProps,
|
|
35
34
|
} from "./BottomAccessoryView";
|
|
36
35
|
|
|
37
|
-
const isAppleSymbol = (
|
|
38
|
-
icon
|
|
36
|
+
const isAppleSymbol = (
|
|
37
|
+
icon: BottomTabIconSource | undefined | null
|
|
38
|
+
): icon is AppleIcon =>
|
|
39
|
+
Boolean(
|
|
40
|
+
typeof icon === "object" &&
|
|
41
|
+
icon !== null &&
|
|
42
|
+
"sfSymbol" in icon &&
|
|
43
|
+
typeof icon.sfSymbol === "string"
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const ONEKEY_ICON_URI_PREFIX = "onekey-icon://";
|
|
47
|
+
|
|
48
|
+
type ResolvedTabIconSource = {
|
|
49
|
+
uri: string;
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
scale: number;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const resolveTabIconSource = (
|
|
56
|
+
icon: BottomTabIconSource | undefined | null
|
|
57
|
+
): ResolvedTabIconSource => {
|
|
58
|
+
if (!icon || isAppleSymbol(icon)) {
|
|
59
|
+
return { uri: "", width: 0, height: 0, scale: 1 };
|
|
60
|
+
}
|
|
61
|
+
if (typeof icon === "string") {
|
|
62
|
+
const trimmed = icon.trim();
|
|
63
|
+
if (!trimmed) {
|
|
64
|
+
return { uri: "", width: 0, height: 0, scale: 1 };
|
|
65
|
+
}
|
|
66
|
+
if (
|
|
67
|
+
trimmed.startsWith(ONEKEY_ICON_URI_PREFIX) ||
|
|
68
|
+
/^[A-Z][A-Za-z0-9]*$/.test(trimmed)
|
|
69
|
+
) {
|
|
70
|
+
const uri = trimmed.startsWith(ONEKEY_ICON_URI_PREFIX)
|
|
71
|
+
? trimmed
|
|
72
|
+
: `${ONEKEY_ICON_URI_PREFIX}${trimmed}`;
|
|
73
|
+
return { uri, width: 24, height: 24, scale: 1 };
|
|
74
|
+
}
|
|
75
|
+
icon = { uri: trimmed };
|
|
76
|
+
}
|
|
77
|
+
if (
|
|
78
|
+
typeof icon === "object" &&
|
|
79
|
+
!Array.isArray(icon) &&
|
|
80
|
+
"iconName" in icon &&
|
|
81
|
+
typeof icon.iconName === "string"
|
|
82
|
+
) {
|
|
83
|
+
const trimmed = icon.iconName.trim();
|
|
84
|
+
if (!trimmed) {
|
|
85
|
+
return { uri: "", width: 0, height: 0, scale: 1 };
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
uri: `${ONEKEY_ICON_URI_PREFIX}${trimmed}`,
|
|
89
|
+
width: 24,
|
|
90
|
+
height: 24,
|
|
91
|
+
scale: 1,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (
|
|
95
|
+
typeof icon === "object" &&
|
|
96
|
+
!Array.isArray(icon) &&
|
|
97
|
+
"uri" in icon &&
|
|
98
|
+
typeof icon.uri === "string" &&
|
|
99
|
+
icon.uri.startsWith(ONEKEY_ICON_URI_PREFIX)
|
|
100
|
+
) {
|
|
101
|
+
return {
|
|
102
|
+
uri: icon.uri,
|
|
103
|
+
width: typeof icon.width === "number" && icon.width > 0 ? icon.width : 24,
|
|
104
|
+
height:
|
|
105
|
+
typeof icon.height === "number" && icon.height > 0 ? icon.height : 24,
|
|
106
|
+
scale: typeof icon.scale === "number" && icon.scale > 0 ? icon.scale : 1,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
const resolved = Image.resolveAssetSource(icon as ImageSourcePropType);
|
|
110
|
+
return {
|
|
111
|
+
uri: resolved?.uri ?? "",
|
|
112
|
+
width: resolved?.width ?? 0,
|
|
113
|
+
height: resolved?.height ?? 0,
|
|
114
|
+
scale: resolved?.scale ?? 1,
|
|
115
|
+
};
|
|
116
|
+
};
|
|
39
117
|
|
|
40
118
|
interface Props<Route extends BaseRoute> {
|
|
41
119
|
/*
|
|
@@ -142,10 +220,13 @@ interface Props<Route extends BaseRoute> {
|
|
|
142
220
|
/**
|
|
143
221
|
* Get icon for the tab.
|
|
144
222
|
*/
|
|
145
|
-
getIcon?: (
|
|
223
|
+
getIcon?: ({
|
|
224
|
+
route,
|
|
225
|
+
focused,
|
|
226
|
+
}: {
|
|
146
227
|
route: Route;
|
|
147
228
|
focused: boolean;
|
|
148
|
-
}) =>
|
|
229
|
+
}) => BottomTabIconSource | undefined | null;
|
|
149
230
|
|
|
150
231
|
/**
|
|
151
232
|
* Get hidden for the tab.
|
|
@@ -240,7 +321,7 @@ interface Props<Route extends BaseRoute> {
|
|
|
240
321
|
* Icon of a round button shown above a vertical tab bar. The button only
|
|
241
322
|
* appears while the tab bar is vertical and visible. iOS only.
|
|
242
323
|
*/
|
|
243
|
-
sideAccessoryIcon?: ImageSourcePropType;
|
|
324
|
+
sideAccessoryIcon?: ImageSourcePropType | NamedIcon | string;
|
|
244
325
|
/**
|
|
245
326
|
* Accessibility label of the side accessory button.
|
|
246
327
|
*/
|
|
@@ -251,6 +332,19 @@ interface Props<Route extends BaseRoute> {
|
|
|
251
332
|
onSideAccessoryPress?: () => void;
|
|
252
333
|
}
|
|
253
334
|
|
|
335
|
+
const defaultGetIcon = ({
|
|
336
|
+
route,
|
|
337
|
+
focused,
|
|
338
|
+
}: {
|
|
339
|
+
route: BaseRoute;
|
|
340
|
+
focused: boolean;
|
|
341
|
+
}) =>
|
|
342
|
+
route.unfocusedIcon
|
|
343
|
+
? focused
|
|
344
|
+
? route.focusedIcon
|
|
345
|
+
: route.unfocusedIcon
|
|
346
|
+
: route.focusedIcon;
|
|
347
|
+
|
|
254
348
|
const ANDROID_MAX_TABS = 100;
|
|
255
349
|
|
|
256
350
|
const BottomTabs = <Route extends BaseRoute>({
|
|
@@ -272,12 +366,7 @@ const BottomTabs = <Route extends BaseRoute>({
|
|
|
272
366
|
getBadgeTextColor = ({ route }: { route: Route }) => route.badgeTextColor,
|
|
273
367
|
getLazy = ({ route }: { route: Route }) => route.lazy,
|
|
274
368
|
getLabelText = ({ route }: { route: Route }) => route.title,
|
|
275
|
-
getIcon =
|
|
276
|
-
route.unfocusedIcon
|
|
277
|
-
? focused
|
|
278
|
-
? route.focusedIcon
|
|
279
|
-
: route.unfocusedIcon
|
|
280
|
-
: route.focusedIcon,
|
|
369
|
+
getIcon = defaultGetIcon,
|
|
281
370
|
getHidden = ({ route }: { route: Route }) => route.hidden,
|
|
282
371
|
getActiveTintColor = ({ route }: { route: Route }) => route.activeTintColor,
|
|
283
372
|
getTestID = ({ route }: { route: Route }) => route.testID,
|
|
@@ -303,7 +392,9 @@ const BottomTabs = <Route extends BaseRoute>({
|
|
|
303
392
|
}: Props<Route>) => {
|
|
304
393
|
// @ts-ignore
|
|
305
394
|
const focusedKey = navigationState.routes[navigationState.index].key;
|
|
306
|
-
const customTabBarWrapperRef = useRef<
|
|
395
|
+
const customTabBarWrapperRef = useRef<React.ComponentRef<typeof View>>(
|
|
396
|
+
null
|
|
397
|
+
) as React.RefObject<any>;
|
|
307
398
|
const nativeBottomTabsRef =
|
|
308
399
|
useRef<React.ElementRef<typeof NativeBottomTabs>>(null);
|
|
309
400
|
const [nativeTabBarHeight, setNativeTabBarHeight] = React.useState(0);
|
|
@@ -415,40 +506,14 @@ const BottomTabs = <Route extends BaseRoute>({
|
|
|
415
506
|
);
|
|
416
507
|
|
|
417
508
|
const resolvedIconAssets = React.useMemo(
|
|
418
|
-
() =>
|
|
419
|
-
icons.map((icon) => {
|
|
420
|
-
if (icon && !isAppleSymbol(icon)) {
|
|
421
|
-
// @ts-ignore - resolveAssetSource accepts ImageSourcePropType
|
|
422
|
-
const resolved = Image.resolveAssetSource(icon);
|
|
423
|
-
return {
|
|
424
|
-
uri: resolved?.uri ?? "",
|
|
425
|
-
width: resolved?.width ?? 0,
|
|
426
|
-
height: resolved?.height ?? 0,
|
|
427
|
-
scale: resolved?.scale ?? 1,
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
return { uri: "", width: 0, height: 0, scale: 1 };
|
|
431
|
-
}),
|
|
509
|
+
() => icons.map((icon) => resolveTabIconSource(icon)),
|
|
432
510
|
[icons]
|
|
433
511
|
);
|
|
434
512
|
|
|
435
513
|
// Focused (solid) assets passed to iOS as selectedImage. iOS only — Android
|
|
436
514
|
// ignores selectedIcons and keeps swapping via the focusedKey array above.
|
|
437
515
|
const resolvedSelectedIconAssets = React.useMemo(
|
|
438
|
-
() =>
|
|
439
|
-
focusedIcons.map((icon) => {
|
|
440
|
-
if (icon && !isAppleSymbol(icon)) {
|
|
441
|
-
// @ts-ignore - resolveAssetSource accepts ImageSourcePropType
|
|
442
|
-
const resolved = Image.resolveAssetSource(icon);
|
|
443
|
-
return {
|
|
444
|
-
uri: resolved?.uri ?? "",
|
|
445
|
-
width: resolved?.width ?? 0,
|
|
446
|
-
height: resolved?.height ?? 0,
|
|
447
|
-
scale: resolved?.scale ?? 1,
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
return { uri: "", width: 0, height: 0, scale: 1 };
|
|
451
|
-
}),
|
|
516
|
+
() => focusedIcons.map((icon) => resolveTabIconSource(icon)),
|
|
452
517
|
[focusedIcons]
|
|
453
518
|
);
|
|
454
519
|
|
|
@@ -514,17 +579,9 @@ const BottomTabs = <Route extends BaseRoute>({
|
|
|
514
579
|
if (!isIOS || !sideAccessoryIcon) {
|
|
515
580
|
return undefined;
|
|
516
581
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
? {
|
|
521
|
-
uri: resolved.uri,
|
|
522
|
-
width: resolved.width ?? 0,
|
|
523
|
-
height: resolved.height ?? 0,
|
|
524
|
-
scale: resolved.scale ?? 1,
|
|
525
|
-
}
|
|
526
|
-
: undefined;
|
|
527
|
-
}, [sideAccessoryIcon]);
|
|
582
|
+
const resolved = resolveTabIconSource(sideAccessoryIcon);
|
|
583
|
+
return resolved.uri ? resolved : undefined;
|
|
584
|
+
}, [isIOS, sideAccessoryIcon]);
|
|
528
585
|
|
|
529
586
|
useLayoutEffect(() => {
|
|
530
587
|
if (renderCustomTabBar && customTabBarWrapperRef.current) {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {
|
|
2
|
+
codegenNativeComponent,
|
|
3
|
+
type CodegenTypes,
|
|
4
|
+
type ViewProps,
|
|
5
|
+
} from "react-native";
|
|
6
|
+
|
|
7
7
|
|
|
8
8
|
export interface BottomTabsDrawerNativeProps extends ViewProps {
|
|
9
|
-
enabled?: WithDefault<boolean, false>;
|
|
10
|
-
open?: WithDefault<boolean, false>;
|
|
11
|
-
swipeEnabled?: WithDefault<boolean, false>;
|
|
12
|
-
hapticFeedbackEnabled?: WithDefault<boolean, false>;
|
|
13
|
-
bottomBarHeight?: Double;
|
|
14
|
-
onDrawerOpenChange?: DirectEventHandler<Readonly<{ open: boolean }>>;
|
|
9
|
+
enabled?: CodegenTypes.WithDefault<boolean, false>;
|
|
10
|
+
open?: CodegenTypes.WithDefault<boolean, false>;
|
|
11
|
+
swipeEnabled?: CodegenTypes.WithDefault<boolean, false>;
|
|
12
|
+
hapticFeedbackEnabled?: CodegenTypes.WithDefault<boolean, false>;
|
|
13
|
+
bottomBarHeight?: CodegenTypes.Double;
|
|
14
|
+
onDrawerOpenChange?: CodegenTypes.DirectEventHandler<Readonly<{ open: boolean }>>;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export default codegenNativeComponent<BottomTabsDrawerNativeProps>(
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//@ts-ignore
|
|
1
|
+
import {
|
|
2
|
+
codegenNativeComponent,
|
|
3
|
+
type CodegenTypes,
|
|
4
|
+
type ColorValue,
|
|
5
|
+
type ProcessedColorValue,
|
|
6
|
+
type ViewProps,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
// @ts-ignore
|
|
10
9
|
import type { ImageSource } from 'react-native/Libraries/Image/ImageSource';
|
|
11
10
|
|
|
12
11
|
export type OnPageSelectedEventData = Readonly<{
|
|
@@ -14,12 +13,12 @@ export type OnPageSelectedEventData = Readonly<{
|
|
|
14
13
|
}>;
|
|
15
14
|
|
|
16
15
|
export type OnTabBarMeasured = Readonly<{
|
|
17
|
-
height: Int32;
|
|
16
|
+
height: CodegenTypes.Int32;
|
|
18
17
|
}>;
|
|
19
18
|
|
|
20
19
|
export type OnNativeLayout = Readonly<{
|
|
21
|
-
width: Double;
|
|
22
|
-
height: Double;
|
|
20
|
+
width: CodegenTypes.Double;
|
|
21
|
+
height: CodegenTypes.Double;
|
|
23
22
|
}>;
|
|
24
23
|
|
|
25
24
|
// Where the system draws the tab bar: 'bottom', or 'leading' / 'trailing' for
|
|
@@ -47,10 +46,10 @@ export type BottomTabsItems = ReadonlyArray<{
|
|
|
47
46
|
export interface BottomTabsNativeProps extends ViewProps {
|
|
48
47
|
items: BottomTabsItems;
|
|
49
48
|
selectedPage: string;
|
|
50
|
-
onPageSelected?: DirectEventHandler<OnPageSelectedEventData>;
|
|
51
|
-
onTabDoublePress?: DirectEventHandler<OnPageSelectedEventData>;
|
|
52
|
-
onTabBarMeasured?: DirectEventHandler<OnTabBarMeasured>;
|
|
53
|
-
onNativeLayout?: DirectEventHandler<OnNativeLayout>;
|
|
49
|
+
onPageSelected?: CodegenTypes.DirectEventHandler<OnPageSelectedEventData>;
|
|
50
|
+
onTabDoublePress?: CodegenTypes.DirectEventHandler<OnPageSelectedEventData>;
|
|
51
|
+
onTabBarMeasured?: CodegenTypes.DirectEventHandler<OnTabBarMeasured>;
|
|
52
|
+
onNativeLayout?: CodegenTypes.DirectEventHandler<OnNativeLayout>;
|
|
54
53
|
icons?: ReadonlyArray<ImageSource>;
|
|
55
54
|
selectedIcons?: ReadonlyArray<ImageSource>;
|
|
56
55
|
tabBarHidden?: boolean;
|
|
@@ -58,8 +57,8 @@ export interface BottomTabsNativeProps extends ViewProps {
|
|
|
58
57
|
sidebarAdaptable?: boolean;
|
|
59
58
|
scrollEdgeAppearance?: string;
|
|
60
59
|
barTintColor?: ColorValue;
|
|
61
|
-
translucent?: WithDefault<boolean, true>;
|
|
62
|
-
androidBottomBlurEnabled?: WithDefault<boolean, false>;
|
|
60
|
+
translucent?: CodegenTypes.WithDefault<boolean, true>;
|
|
61
|
+
androidBottomBlurEnabled?: CodegenTypes.WithDefault<boolean, false>;
|
|
63
62
|
rippleColor?: ColorValue;
|
|
64
63
|
activeTintColor?: ColorValue;
|
|
65
64
|
inactiveTintColor?: ColorValue;
|
|
@@ -69,15 +68,15 @@ export interface BottomTabsNativeProps extends ViewProps {
|
|
|
69
68
|
minimizeBehavior?: string;
|
|
70
69
|
fontFamily?: string;
|
|
71
70
|
fontWeight?: string;
|
|
72
|
-
fontSize?: Int32;
|
|
71
|
+
fontSize?: CodegenTypes.Int32;
|
|
73
72
|
ignoreBottomInsets?: boolean;
|
|
74
|
-
androidTabBarStyle?: WithDefault<'default' | 'floating', 'default'>;
|
|
75
|
-
ignoreKeyboardInsets?: WithDefault<boolean, true>;
|
|
76
|
-
onTabBarPlacementChange?: DirectEventHandler<OnTabBarPlacementChange>;
|
|
73
|
+
androidTabBarStyle?: CodegenTypes.WithDefault<'default' | 'floating', 'default'>;
|
|
74
|
+
ignoreKeyboardInsets?: CodegenTypes.WithDefault<boolean, true>;
|
|
75
|
+
onTabBarPlacementChange?: CodegenTypes.DirectEventHandler<OnTabBarPlacementChange>;
|
|
77
76
|
// A round button drawn above a vertical tab bar; iOS only.
|
|
78
77
|
sideAccessoryIcon?: ImageSource;
|
|
79
78
|
sideAccessoryLabel?: string;
|
|
80
|
-
onSideAccessoryPress?: DirectEventHandler<OnSideAccessoryPress>;
|
|
79
|
+
onSideAccessoryPress?: CodegenTypes.DirectEventHandler<OnSideAccessoryPress>;
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
export default codegenNativeComponent<BottomTabsNativeProps>('RNBottomTabsView');
|
package/src/index.tsx
CHANGED
|
@@ -15,4 +15,10 @@ export { BottomTabBarHeightContext } from './utils/BottomTabBarHeightContext';
|
|
|
15
15
|
/**
|
|
16
16
|
* Types
|
|
17
17
|
*/
|
|
18
|
-
export type {
|
|
18
|
+
export type {
|
|
19
|
+
AppleIcon,
|
|
20
|
+
BottomTabIconSource,
|
|
21
|
+
NamedIcon,
|
|
22
|
+
TabBarPlacement,
|
|
23
|
+
TabRole,
|
|
24
|
+
} from './types';
|