react-native-tab-view 3.5.0 → 3.5.2
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/README.md +2 -646
- package/lib/commonjs/Pager.android.js +3 -4
- package/lib/commonjs/Pager.android.js.map +1 -1
- package/lib/commonjs/Pager.ios.js +3 -4
- package/lib/commonjs/Pager.ios.js.map +1 -1
- package/lib/commonjs/Pager.js +3 -4
- package/lib/commonjs/Pager.js.map +1 -1
- package/lib/commonjs/PagerViewAdapter.js +4 -4
- package/lib/commonjs/PagerViewAdapter.js.map +1 -1
- package/lib/commonjs/PanResponderAdapter.js +3 -4
- package/lib/commonjs/PanResponderAdapter.js.map +1 -1
- package/lib/commonjs/PlatformPressable.js +1 -1
- package/lib/commonjs/PlatformPressable.js.map +1 -1
- package/lib/commonjs/SceneMap.js +1 -1
- package/lib/commonjs/SceneMap.js.map +1 -1
- package/lib/commonjs/SceneView.js +1 -1
- package/lib/commonjs/SceneView.js.map +1 -1
- package/lib/commonjs/TabBar.js +7 -7
- package/lib/commonjs/TabBar.js.map +1 -1
- package/lib/commonjs/TabBarIndicator.js +3 -4
- package/lib/commonjs/TabBarIndicator.js.map +1 -1
- package/lib/commonjs/TabBarItem.js +32 -34
- package/lib/commonjs/TabBarItem.js.map +1 -1
- package/lib/commonjs/TabBarItemLabel.js +36 -0
- package/lib/commonjs/TabBarItemLabel.js.map +1 -0
- package/lib/commonjs/TabView.js +7 -8
- package/lib/commonjs/TabView.js.map +1 -1
- package/lib/commonjs/index.js +10 -11
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/useAnimatedValue.js +1 -1
- package/lib/commonjs/useAnimatedValue.js.map +1 -1
- package/lib/module/Pager.android.js +1 -1
- package/lib/module/Pager.android.js.map +1 -1
- package/lib/module/Pager.ios.js +1 -1
- package/lib/module/Pager.ios.js.map +1 -1
- package/lib/module/Pager.js +1 -1
- package/lib/module/Pager.js.map +1 -1
- package/lib/module/PagerViewAdapter.js +2 -2
- package/lib/module/PagerViewAdapter.js.map +1 -1
- package/lib/module/PanResponderAdapter.js +2 -2
- package/lib/module/PanResponderAdapter.js.map +1 -1
- package/lib/module/PlatformPressable.js +1 -1
- package/lib/module/PlatformPressable.js.map +1 -1
- package/lib/module/SceneMap.js +1 -1
- package/lib/module/SceneMap.js.map +1 -1
- package/lib/module/SceneView.js +1 -1
- package/lib/module/SceneView.js.map +1 -1
- package/lib/module/TabBar.js +4 -4
- package/lib/module/TabBar.js.map +1 -1
- package/lib/module/TabBarIndicator.js +2 -2
- package/lib/module/TabBarIndicator.js.map +1 -1
- package/lib/module/TabBarItem.js +31 -32
- package/lib/module/TabBarItem.js.map +1 -1
- package/lib/module/TabBarItemLabel.js +28 -0
- package/lib/module/TabBarItemLabel.js.map +1 -0
- package/lib/module/TabView.js +4 -4
- package/lib/module/TabView.js.map +1 -1
- package/lib/module/index.js +5 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/useAnimatedValue.js +1 -1
- package/lib/module/useAnimatedValue.js.map +1 -1
- package/lib/typescript/src/Pager.android.d.ts +1 -1
- package/lib/typescript/src/Pager.android.d.ts.map +1 -1
- package/lib/typescript/src/Pager.d.ts +1 -1
- package/lib/typescript/src/Pager.d.ts.map +1 -1
- package/lib/typescript/src/Pager.ios.d.ts +1 -1
- package/lib/typescript/src/Pager.ios.d.ts.map +1 -1
- package/lib/typescript/src/PagerViewAdapter.d.ts +1 -1
- package/lib/typescript/src/PagerViewAdapter.d.ts.map +1 -1
- package/lib/typescript/src/PanResponderAdapter.d.ts +1 -1
- package/lib/typescript/src/PanResponderAdapter.d.ts.map +1 -1
- package/lib/typescript/src/PlatformPressable.d.ts +1 -1
- package/lib/typescript/src/PlatformPressable.d.ts.map +1 -1
- package/lib/typescript/src/SceneMap.d.ts +1 -1
- package/lib/typescript/src/SceneMap.d.ts.map +1 -1
- package/lib/typescript/src/SceneView.d.ts +1 -1
- package/lib/typescript/src/SceneView.d.ts.map +1 -1
- package/lib/typescript/src/TabBar.d.ts +1 -1
- package/lib/typescript/src/TabBar.d.ts.map +1 -1
- package/lib/typescript/src/TabBarIndicator.d.ts +1 -2
- package/lib/typescript/src/TabBarIndicator.d.ts.map +1 -1
- package/lib/typescript/src/TabBarItem.d.ts +1 -2
- package/lib/typescript/src/TabBarItem.d.ts.map +1 -1
- package/lib/typescript/src/TabBarItemLabel.d.ts +11 -0
- package/lib/typescript/src/TabBarItemLabel.d.ts.map +1 -0
- package/lib/typescript/src/TabView.d.ts +1 -1
- package/lib/typescript/src/TabView.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +5 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/useAnimatedValue.d.ts +1 -1
- package/lib/typescript/src/useAnimatedValue.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/Pager.android.tsx +1 -1
- package/src/Pager.ios.tsx +1 -1
- package/src/Pager.tsx +1 -1
- package/src/PagerViewAdapter.tsx +2 -2
- package/src/PanResponderAdapter.tsx +2 -2
- package/src/PlatformPressable.tsx +1 -1
- package/src/SceneMap.tsx +1 -1
- package/src/SceneView.tsx +2 -2
- package/src/TabBar.tsx +4 -4
- package/src/TabBarIndicator.tsx +2 -2
- package/src/TabBarItem.tsx +52 -46
- package/src/TabBarItemLabel.tsx +39 -0
- package/src/TabView.tsx +4 -4
- package/src/index.tsx +5 -5
- package/src/useAnimatedValue.tsx +1 -1
package/src/TabBarItem.tsx
CHANGED
|
@@ -11,7 +11,8 @@ import {
|
|
|
11
11
|
} from 'react-native';
|
|
12
12
|
import useLatestCallback from 'use-latest-callback';
|
|
13
13
|
|
|
14
|
-
import PlatformPressable from './PlatformPressable';
|
|
14
|
+
import { PlatformPressable } from './PlatformPressable';
|
|
15
|
+
import { TabBarItemLabel } from './TabBarItemLabel';
|
|
15
16
|
import type { NavigationState, Route, Scene } from './types';
|
|
16
17
|
|
|
17
18
|
export type Props<T extends Route> = {
|
|
@@ -85,18 +86,26 @@ const getInactiveOpacity = (
|
|
|
85
86
|
|
|
86
87
|
type TabBarItemInternalProps<T extends Route> = Omit<
|
|
87
88
|
Props<T>,
|
|
88
|
-
'navigationState'
|
|
89
|
+
| 'navigationState'
|
|
90
|
+
| 'getAccessibilityLabel'
|
|
91
|
+
| 'getLabelText'
|
|
92
|
+
| 'getTestID'
|
|
93
|
+
| 'getAccessible'
|
|
89
94
|
> & {
|
|
90
95
|
isFocused: boolean;
|
|
91
96
|
index: number;
|
|
92
97
|
routesLength: number;
|
|
98
|
+
accessibilityLabel?: string;
|
|
99
|
+
label?: string;
|
|
100
|
+
testID?: string;
|
|
101
|
+
accessible?: boolean;
|
|
93
102
|
};
|
|
94
103
|
|
|
95
104
|
const TabBarItemInternal = <T extends Route>({
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
105
|
+
accessibilityLabel,
|
|
106
|
+
accessible,
|
|
107
|
+
label: labelText,
|
|
108
|
+
testID,
|
|
100
109
|
onLongPress,
|
|
101
110
|
onPress,
|
|
102
111
|
isFocused,
|
|
@@ -166,29 +175,16 @@ const TabBarItemInternal = <T extends Route>({
|
|
|
166
175
|
}
|
|
167
176
|
}
|
|
168
177
|
|
|
169
|
-
const renderLabel =
|
|
170
|
-
renderLabelCustom
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
styles.label,
|
|
180
|
-
icon ? { marginTop: 0 } : null,
|
|
181
|
-
labelStyle,
|
|
182
|
-
{ color: labelProps.color },
|
|
183
|
-
]}
|
|
184
|
-
>
|
|
185
|
-
{labelText}
|
|
186
|
-
</Animated.Text>
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return labelText;
|
|
191
|
-
};
|
|
178
|
+
const renderLabel = renderLabelCustom
|
|
179
|
+
? renderLabelCustom
|
|
180
|
+
: (labelProps: { color: string }) => (
|
|
181
|
+
<TabBarItemLabel
|
|
182
|
+
{...labelProps}
|
|
183
|
+
icon={icon}
|
|
184
|
+
label={labelText}
|
|
185
|
+
labelStyle={labelStyle}
|
|
186
|
+
/>
|
|
187
|
+
);
|
|
192
188
|
|
|
193
189
|
if (renderLabel) {
|
|
194
190
|
const activeLabel = renderLabel({
|
|
@@ -225,20 +221,16 @@ const TabBarItemInternal = <T extends Route>({
|
|
|
225
221
|
|
|
226
222
|
const scene = { route };
|
|
227
223
|
|
|
228
|
-
let accessibilityLabel = getAccessibilityLabel(scene);
|
|
229
|
-
|
|
230
224
|
accessibilityLabel =
|
|
231
|
-
typeof accessibilityLabel !== 'undefined'
|
|
232
|
-
? accessibilityLabel
|
|
233
|
-
: getLabelText(scene);
|
|
225
|
+
typeof accessibilityLabel !== 'undefined' ? accessibilityLabel : labelText;
|
|
234
226
|
|
|
235
227
|
const badge = renderBadge ? renderBadge(scene) : null;
|
|
236
228
|
|
|
237
229
|
return (
|
|
238
230
|
<PlatformPressable
|
|
239
231
|
android_ripple={android_ripple}
|
|
240
|
-
testID={
|
|
241
|
-
accessible={
|
|
232
|
+
testID={testID}
|
|
233
|
+
accessible={accessible}
|
|
242
234
|
accessibilityLabel={accessibilityLabel}
|
|
243
235
|
accessibilityRole="tab"
|
|
244
236
|
accessibilityState={{ selected: isFocused }}
|
|
@@ -265,15 +257,32 @@ const MemoizedTabBarItemInternal = React.memo(
|
|
|
265
257
|
TabBarItemInternal
|
|
266
258
|
) as typeof TabBarItemInternal;
|
|
267
259
|
|
|
268
|
-
function TabBarItem<T extends Route>(props: Props<T>) {
|
|
269
|
-
const {
|
|
270
|
-
|
|
260
|
+
export function TabBarItem<T extends Route>(props: Props<T>) {
|
|
261
|
+
const {
|
|
262
|
+
onPress,
|
|
263
|
+
onLongPress,
|
|
264
|
+
onLayout,
|
|
265
|
+
navigationState,
|
|
266
|
+
route,
|
|
267
|
+
getAccessibilityLabel,
|
|
268
|
+
getLabelText,
|
|
269
|
+
getTestID,
|
|
270
|
+
getAccessible,
|
|
271
|
+
...rest
|
|
272
|
+
} = props;
|
|
271
273
|
const onPressLatest = useLatestCallback(onPress);
|
|
272
274
|
const onLongPressLatest = useLatestCallback(onLongPress);
|
|
273
275
|
const onLayoutLatest = useLatestCallback(onLayout ? onLayout : () => {});
|
|
274
276
|
|
|
275
277
|
const tabIndex = navigationState.routes.indexOf(route);
|
|
276
278
|
|
|
279
|
+
const scene = { route };
|
|
280
|
+
|
|
281
|
+
const accessibilityLabel = getAccessibilityLabel(scene);
|
|
282
|
+
const label = getLabelText(scene);
|
|
283
|
+
const testID = getTestID(scene);
|
|
284
|
+
const accessible = getAccessible(scene);
|
|
285
|
+
|
|
277
286
|
return (
|
|
278
287
|
<MemoizedTabBarItemInternal
|
|
279
288
|
{...rest}
|
|
@@ -284,18 +293,15 @@ function TabBarItem<T extends Route>(props: Props<T>) {
|
|
|
284
293
|
route={route}
|
|
285
294
|
index={tabIndex}
|
|
286
295
|
routesLength={navigationState.routes.length}
|
|
296
|
+
accessibilityLabel={accessibilityLabel}
|
|
297
|
+
label={label}
|
|
298
|
+
testID={testID}
|
|
299
|
+
accessible={accessible}
|
|
287
300
|
/>
|
|
288
301
|
);
|
|
289
302
|
}
|
|
290
303
|
|
|
291
|
-
export default TabBarItem;
|
|
292
|
-
|
|
293
304
|
const styles = StyleSheet.create({
|
|
294
|
-
label: {
|
|
295
|
-
margin: 4,
|
|
296
|
-
backgroundColor: 'transparent',
|
|
297
|
-
textTransform: 'uppercase',
|
|
298
|
-
},
|
|
299
305
|
icon: {
|
|
300
306
|
margin: 2,
|
|
301
307
|
},
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { Animated, StyleSheet } from 'react-native';
|
|
4
|
+
|
|
5
|
+
interface TabBarItemLabelProps {
|
|
6
|
+
color: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
labelStyle: StyleProp<ViewStyle>;
|
|
9
|
+
icon: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const TabBarItemLabel = React.memo(
|
|
13
|
+
({ color, label, labelStyle, icon }: TabBarItemLabelProps) => {
|
|
14
|
+
if (!label) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Animated.Text
|
|
20
|
+
style={[
|
|
21
|
+
styles.label,
|
|
22
|
+
icon ? { marginTop: 0 } : null,
|
|
23
|
+
labelStyle,
|
|
24
|
+
{ color: color },
|
|
25
|
+
]}
|
|
26
|
+
>
|
|
27
|
+
{label}
|
|
28
|
+
</Animated.Text>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const styles = StyleSheet.create({
|
|
34
|
+
label: {
|
|
35
|
+
margin: 4,
|
|
36
|
+
backgroundColor: 'transparent',
|
|
37
|
+
textTransform: 'uppercase',
|
|
38
|
+
},
|
|
39
|
+
});
|
package/src/TabView.tsx
CHANGED
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
ViewStyle,
|
|
8
8
|
} from 'react-native';
|
|
9
9
|
|
|
10
|
-
import Pager from './Pager';
|
|
11
|
-
import SceneView from './SceneView';
|
|
12
|
-
import TabBar from './TabBar';
|
|
10
|
+
import { Pager } from './Pager';
|
|
11
|
+
import { SceneView } from './SceneView';
|
|
12
|
+
import { TabBar } from './TabBar';
|
|
13
13
|
import type {
|
|
14
14
|
Layout,
|
|
15
15
|
NavigationState,
|
|
@@ -35,7 +35,7 @@ export type Props<T extends Route> = PagerProps & {
|
|
|
35
35
|
style?: StyleProp<ViewStyle>;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
export
|
|
38
|
+
export function TabView<T extends Route>({
|
|
39
39
|
onIndexChange,
|
|
40
40
|
navigationState,
|
|
41
41
|
renderScene,
|
package/src/index.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { SceneMap } from './SceneMap';
|
|
2
2
|
export type { Props as TabBarProps } from './TabBar';
|
|
3
|
-
export {
|
|
3
|
+
export { TabBar } from './TabBar';
|
|
4
4
|
export type { Props as TabBarIndicatorProps } from './TabBarIndicator';
|
|
5
|
-
export {
|
|
5
|
+
export { TabBarIndicator } from './TabBarIndicator';
|
|
6
6
|
export type { Props as TabBarItemProps } from './TabBarItem';
|
|
7
|
-
export {
|
|
7
|
+
export { TabBarItem } from './TabBarItem';
|
|
8
8
|
export type { Props as TabViewProps } from './TabView';
|
|
9
|
-
export {
|
|
9
|
+
export { TabView } from './TabView';
|
|
10
10
|
export type { NavigationState, Route, SceneRendererProps } from './types';
|
package/src/useAnimatedValue.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Animated } from 'react-native';
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export function useAnimatedValue(initialValue: number) {
|
|
5
5
|
const lazyRef = React.useRef<Animated.Value>();
|
|
6
6
|
|
|
7
7
|
if (lazyRef.current === undefined) {
|