react-native-tab-view 3.5.1 → 4.0.0-alpha.0
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/PanResponderAdapter.js +6 -5
- package/lib/commonjs/PanResponderAdapter.js.map +1 -1
- package/lib/commonjs/SceneView.js.map +1 -1
- package/lib/commonjs/TabBar.js +79 -32
- package/lib/commonjs/TabBar.js.map +1 -1
- package/lib/commonjs/TabBarIndicator.js +8 -6
- package/lib/commonjs/TabBarIndicator.js.map +1 -1
- package/lib/commonjs/TabBarItem.js +29 -29
- 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 +6 -1
- package/lib/commonjs/TabView.js.map +1 -1
- package/lib/module/PanResponderAdapter.js +7 -6
- package/lib/module/PanResponderAdapter.js.map +1 -1
- package/lib/module/SceneView.js.map +1 -1
- package/lib/module/TabBar.js +79 -32
- package/lib/module/TabBar.js.map +1 -1
- package/lib/module/TabBarIndicator.js +9 -7
- package/lib/module/TabBarIndicator.js.map +1 -1
- package/lib/module/TabBarItem.js +29 -29
- 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 +7 -2
- package/lib/module/TabView.js.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/TabBar.d.ts +3 -2
- package/lib/typescript/src/TabBar.d.ts.map +1 -1
- package/lib/typescript/src/TabBarIndicator.d.ts +6 -4
- package/lib/typescript/src/TabBarIndicator.d.ts.map +1 -1
- 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 +4 -3
- package/lib/typescript/src/TabView.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +1 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/PanResponderAdapter.tsx +7 -5
- package/src/SceneView.tsx +1 -1
- package/src/TabBar.tsx +139 -44
- package/src/TabBarIndicator.tsx +20 -7
- package/src/TabBarItem.tsx +50 -42
- package/src/TabBarItemLabel.tsx +39 -0
- package/src/TabView.tsx +18 -1
- package/src/types.tsx +2 -0
package/src/TabView.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import {
|
|
3
|
+
I18nManager,
|
|
3
4
|
LayoutChangeEvent,
|
|
5
|
+
Platform,
|
|
4
6
|
StyleProp,
|
|
5
7
|
StyleSheet,
|
|
6
8
|
View,
|
|
@@ -12,13 +14,14 @@ import { SceneView } from './SceneView';
|
|
|
12
14
|
import { TabBar } from './TabBar';
|
|
13
15
|
import type {
|
|
14
16
|
Layout,
|
|
17
|
+
LocaleDirection,
|
|
15
18
|
NavigationState,
|
|
16
19
|
PagerProps,
|
|
17
20
|
Route,
|
|
18
21
|
SceneRendererProps,
|
|
19
22
|
} from './types';
|
|
20
23
|
|
|
21
|
-
export type Props<T extends Route> = PagerProps & {
|
|
24
|
+
export type Props<T extends Route> = Omit<PagerProps, 'layoutDirection'> & {
|
|
22
25
|
onIndexChange: (index: number) => void;
|
|
23
26
|
navigationState: NavigationState<T>;
|
|
24
27
|
renderScene: (props: SceneRendererProps & { route: T }) => React.ReactNode;
|
|
@@ -31,6 +34,7 @@ export type Props<T extends Route> = PagerProps & {
|
|
|
31
34
|
lazy?: ((props: { route: T }) => boolean) | boolean;
|
|
32
35
|
lazyPreloadDistance?: number;
|
|
33
36
|
sceneContainerStyle?: StyleProp<ViewStyle>;
|
|
37
|
+
direction?: LocaleDirection;
|
|
34
38
|
pagerStyle?: StyleProp<ViewStyle>;
|
|
35
39
|
style?: StyleProp<ViewStyle>;
|
|
36
40
|
};
|
|
@@ -50,11 +54,23 @@ export function TabView<T extends Route>({
|
|
|
50
54
|
sceneContainerStyle,
|
|
51
55
|
pagerStyle,
|
|
52
56
|
style,
|
|
57
|
+
direction = I18nManager.getConstants().isRTL ? 'rtl' : 'ltr',
|
|
53
58
|
swipeEnabled = true,
|
|
54
59
|
tabBarPosition = 'top',
|
|
55
60
|
animationEnabled = true,
|
|
56
61
|
overScrollMode,
|
|
57
62
|
}: Props<T>) {
|
|
63
|
+
if (
|
|
64
|
+
Platform.OS !== 'web' &&
|
|
65
|
+
direction !== (I18nManager.getConstants().isRTL ? 'rtl' : 'ltr')
|
|
66
|
+
) {
|
|
67
|
+
console.warn(
|
|
68
|
+
`The 'direction' prop is set to '${direction}' but the effective value is '${
|
|
69
|
+
I18nManager.getConstants().isRTL ? 'rtl' : 'ltr'
|
|
70
|
+
}'. This is not supported. Please use I18nManager.forceRTL to change the layout direction.`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
58
74
|
const [layout, setLayout] = React.useState({
|
|
59
75
|
width: 0,
|
|
60
76
|
height: 0,
|
|
@@ -92,6 +108,7 @@ export function TabView<T extends Route>({
|
|
|
92
108
|
animationEnabled={animationEnabled}
|
|
93
109
|
overScrollMode={overScrollMode}
|
|
94
110
|
style={pagerStyle}
|
|
111
|
+
layoutDirection={direction}
|
|
95
112
|
>
|
|
96
113
|
{({ position, render, addEnterListener, jumpTo }) => {
|
|
97
114
|
// All of the props here must not change between re-renders
|