@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,57 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type Props = {
|
|
4
|
+
/**
|
|
5
|
+
* Whether lazy rendering is enabled.
|
|
6
|
+
*/
|
|
7
|
+
lazy: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Whether the component is visible.
|
|
10
|
+
*/
|
|
11
|
+
visible: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Content to render.
|
|
14
|
+
*/
|
|
15
|
+
children: React.ReactElement;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Render content lazily based on visibility.
|
|
20
|
+
*
|
|
21
|
+
* When lazy is enabled:
|
|
22
|
+
* - If content is visible, it will render immediately
|
|
23
|
+
* - If content is not visible, it won't render until it becomes visible
|
|
24
|
+
*
|
|
25
|
+
* Otherwise:
|
|
26
|
+
* - If content is visible, it will render immediately
|
|
27
|
+
* - If content is not visible, it will defer rendering
|
|
28
|
+
*
|
|
29
|
+
* Once rendered, the content remains rendered.
|
|
30
|
+
*/
|
|
31
|
+
export function Deferred({ lazy, visible, children }: Props) {
|
|
32
|
+
const [rendered, setRendered] = React.useState(lazy ? visible : false);
|
|
33
|
+
|
|
34
|
+
const shouldRenderDeferred = !(lazy || visible || rendered);
|
|
35
|
+
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
if (shouldRenderDeferred === false) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
React.startTransition(() => {
|
|
42
|
+
setRendered(true);
|
|
43
|
+
});
|
|
44
|
+
}, [shouldRenderDeferred]);
|
|
45
|
+
|
|
46
|
+
if (visible && rendered === false) {
|
|
47
|
+
setRendered(true);
|
|
48
|
+
|
|
49
|
+
return children;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (rendered) {
|
|
53
|
+
return children;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
@@ -2,7 +2,6 @@ import { getHeaderTitle, Header } from '@react-navigation/elements';
|
|
|
2
2
|
import { Screen } from '@react-navigation/elements/internal';
|
|
3
3
|
import type { ParamListBase, Route } from '@react-navigation/native';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
6
5
|
|
|
7
6
|
import type {
|
|
8
7
|
BottomTabNavigationOptions,
|
|
@@ -21,7 +20,7 @@ export function ScreenContent({
|
|
|
21
20
|
route: Route<string>;
|
|
22
21
|
navigation: BottomTabNavigationProp<ParamListBase>;
|
|
23
22
|
options: BottomTabNavigationOptions;
|
|
24
|
-
style?:
|
|
23
|
+
style?: React.ComponentProps<typeof Screen>['style'];
|
|
25
24
|
children: React.ReactNode;
|
|
26
25
|
}) {
|
|
27
26
|
const {
|
package/src/views/TabBarIcon.tsx
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Badge } from '@react-navigation/elements';
|
|
1
|
+
import { Badge, type Icon, PlatformIcon } from '@react-navigation/elements';
|
|
2
2
|
import { MissingIcon } from '@react-navigation/elements/internal';
|
|
3
|
-
import {
|
|
4
|
-
import React from 'react';
|
|
3
|
+
import { type Route } from '@react-navigation/native';
|
|
4
|
+
import * as React from 'react';
|
|
5
5
|
import {
|
|
6
6
|
type ColorValue,
|
|
7
|
-
Image,
|
|
8
7
|
type StyleProp,
|
|
9
8
|
StyleSheet,
|
|
10
9
|
type TextStyle,
|
|
@@ -12,26 +11,24 @@ import {
|
|
|
12
11
|
type ViewStyle,
|
|
13
12
|
} from 'react-native';
|
|
14
13
|
|
|
15
|
-
import type { BottomTabIcon } from '../types';
|
|
16
|
-
|
|
17
14
|
export type TabBarIconProps = {
|
|
18
15
|
route: Route<string>;
|
|
19
16
|
variant: 'uikit' | 'material';
|
|
20
17
|
size: 'compact' | 'regular';
|
|
21
|
-
badge?: string | number;
|
|
22
|
-
badgeStyle?: StyleProp<TextStyle
|
|
18
|
+
badge?: string | number | undefined;
|
|
19
|
+
badgeStyle?: StyleProp<TextStyle> | undefined;
|
|
23
20
|
activeOpacity: number;
|
|
24
21
|
inactiveOpacity: number;
|
|
25
22
|
activeTintColor: ColorValue;
|
|
26
23
|
inactiveTintColor: ColorValue;
|
|
27
24
|
icon:
|
|
28
|
-
|
|
|
25
|
+
| Icon
|
|
29
26
|
| ((props: {
|
|
30
27
|
focused: boolean;
|
|
31
28
|
color: ColorValue;
|
|
32
29
|
size: number;
|
|
33
|
-
}) =>
|
|
34
|
-
allowFontScaling?: boolean;
|
|
30
|
+
}) => Icon | React.ReactNode);
|
|
31
|
+
allowFontScaling?: boolean | undefined;
|
|
35
32
|
style: StyleProp<ViewStyle>;
|
|
36
33
|
};
|
|
37
34
|
|
|
@@ -43,8 +40,8 @@ const ICON_SIZE_WIDE = 31;
|
|
|
43
40
|
const ICON_SIZE_WIDE_COMPACT = 23;
|
|
44
41
|
const ICON_SIZE_TALL = 28;
|
|
45
42
|
const ICON_SIZE_TALL_COMPACT = 20;
|
|
46
|
-
const
|
|
47
|
-
const
|
|
43
|
+
const ICON_SIZE_SQUARE = 23;
|
|
44
|
+
const ICON_SIZE_SQUARE_COMPACT = 17;
|
|
48
45
|
const ICON_SIZE_MATERIAL = 24;
|
|
49
46
|
|
|
50
47
|
export function TabBarIcon({
|
|
@@ -65,8 +62,8 @@ export function TabBarIcon({
|
|
|
65
62
|
variant === 'material'
|
|
66
63
|
? ICON_SIZE_MATERIAL
|
|
67
64
|
: size === 'compact'
|
|
68
|
-
?
|
|
69
|
-
:
|
|
65
|
+
? ICON_SIZE_SQUARE_COMPACT
|
|
66
|
+
: ICON_SIZE_SQUARE;
|
|
70
67
|
|
|
71
68
|
// We render the icon twice at the same position on top of each other:
|
|
72
69
|
// active and inactive one, so we can fade between them.
|
|
@@ -141,47 +138,7 @@ function renderIcon({
|
|
|
141
138
|
iconValue != null &&
|
|
142
139
|
'type' in iconValue
|
|
143
140
|
) {
|
|
144
|
-
|
|
145
|
-
case 'image':
|
|
146
|
-
return (
|
|
147
|
-
<Image
|
|
148
|
-
source={iconValue.source}
|
|
149
|
-
style={{
|
|
150
|
-
width: size,
|
|
151
|
-
height: size,
|
|
152
|
-
tintColor: iconValue.tinted === false ? undefined : color,
|
|
153
|
-
}}
|
|
154
|
-
/>
|
|
155
|
-
);
|
|
156
|
-
case 'resource':
|
|
157
|
-
return (
|
|
158
|
-
<Image
|
|
159
|
-
source={{ uri: iconValue.name }}
|
|
160
|
-
style={{
|
|
161
|
-
width: size,
|
|
162
|
-
height: size,
|
|
163
|
-
tintColor: iconValue.tinted === false ? undefined : color,
|
|
164
|
-
}}
|
|
165
|
-
/>
|
|
166
|
-
);
|
|
167
|
-
case 'sfSymbol':
|
|
168
|
-
return <SFSymbol name={iconValue.name} size={size} color={color} />;
|
|
169
|
-
case 'materialSymbol':
|
|
170
|
-
return (
|
|
171
|
-
<MaterialSymbol
|
|
172
|
-
name={iconValue.name}
|
|
173
|
-
variant={iconValue.variant}
|
|
174
|
-
weight={iconValue.weight}
|
|
175
|
-
size={size}
|
|
176
|
-
color={color}
|
|
177
|
-
/>
|
|
178
|
-
);
|
|
179
|
-
default: {
|
|
180
|
-
const _exhaustiveCheck: never = iconValue;
|
|
181
|
-
|
|
182
|
-
return _exhaustiveCheck;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
141
|
+
return <PlatformIcon icon={iconValue} size={size} color={color} />;
|
|
185
142
|
}
|
|
186
143
|
|
|
187
144
|
return <MissingIcon color={color} size={size} />;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["BottomTabViewCustom","BottomTabViewNative","jsx","_jsx","BottomTabView","props","implementation"],"sourceRoot":"../../../src","sources":["views/BottomTabViewCommon.tsx"],"mappings":";;AAUA,SAASA,mBAAmB,QAAQ,0BAAuB;AAC3D,SAASC,mBAAmB,QAAQ,uBAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAQ5D,OAAO,SAASC,aAAaA,CAACC,KAAY,EAAE;EAC1C,IAAIA,KAAK,CAACC,cAAc,KAAK,QAAQ,EAAE;IACrC,oBAAOH,IAAA,CAACH,mBAAmB;MAAA,GAAKK;IAAK,CAAG,CAAC;EAC3C;EAEA,oBAAOF,IAAA,CAACF,mBAAmB;IAAA,GAAKI;EAAK,CAAG,CAAC;AAC3C","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BottomTabViewCommon.d.ts","sourceRoot":"","sources":["../../../../src/views/BottomTabViewCommon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EACV,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,UAAU,CAAC;AAIlB,KAAK,KAAK,GAAG,yBAAyB,GAAG;IACvC,KAAK,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC;IACzC,UAAU,EAAE,0BAA0B,CAAC;IACvC,WAAW,EAAE,sBAAsB,CAAC;CACrC,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,2CAMzC"}
|
|
File without changes
|