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.
Files changed (49) hide show
  1. package/README.md +2 -646
  2. package/lib/commonjs/PanResponderAdapter.js +6 -5
  3. package/lib/commonjs/PanResponderAdapter.js.map +1 -1
  4. package/lib/commonjs/SceneView.js.map +1 -1
  5. package/lib/commonjs/TabBar.js +79 -32
  6. package/lib/commonjs/TabBar.js.map +1 -1
  7. package/lib/commonjs/TabBarIndicator.js +8 -6
  8. package/lib/commonjs/TabBarIndicator.js.map +1 -1
  9. package/lib/commonjs/TabBarItem.js +29 -29
  10. package/lib/commonjs/TabBarItem.js.map +1 -1
  11. package/lib/commonjs/TabBarItemLabel.js +36 -0
  12. package/lib/commonjs/TabBarItemLabel.js.map +1 -0
  13. package/lib/commonjs/TabView.js +6 -1
  14. package/lib/commonjs/TabView.js.map +1 -1
  15. package/lib/module/PanResponderAdapter.js +7 -6
  16. package/lib/module/PanResponderAdapter.js.map +1 -1
  17. package/lib/module/SceneView.js.map +1 -1
  18. package/lib/module/TabBar.js +79 -32
  19. package/lib/module/TabBar.js.map +1 -1
  20. package/lib/module/TabBarIndicator.js +9 -7
  21. package/lib/module/TabBarIndicator.js.map +1 -1
  22. package/lib/module/TabBarItem.js +29 -29
  23. package/lib/module/TabBarItem.js.map +1 -1
  24. package/lib/module/TabBarItemLabel.js +28 -0
  25. package/lib/module/TabBarItemLabel.js.map +1 -0
  26. package/lib/module/TabView.js +7 -2
  27. package/lib/module/TabView.js.map +1 -1
  28. package/lib/typescript/src/PanResponderAdapter.d.ts +1 -1
  29. package/lib/typescript/src/PanResponderAdapter.d.ts.map +1 -1
  30. package/lib/typescript/src/TabBar.d.ts +3 -2
  31. package/lib/typescript/src/TabBar.d.ts.map +1 -1
  32. package/lib/typescript/src/TabBarIndicator.d.ts +6 -4
  33. package/lib/typescript/src/TabBarIndicator.d.ts.map +1 -1
  34. package/lib/typescript/src/TabBarItem.d.ts.map +1 -1
  35. package/lib/typescript/src/TabBarItemLabel.d.ts +11 -0
  36. package/lib/typescript/src/TabBarItemLabel.d.ts.map +1 -0
  37. package/lib/typescript/src/TabView.d.ts +4 -3
  38. package/lib/typescript/src/TabView.d.ts.map +1 -1
  39. package/lib/typescript/src/types.d.ts +1 -0
  40. package/lib/typescript/src/types.d.ts.map +1 -1
  41. package/package.json +7 -7
  42. package/src/PanResponderAdapter.tsx +7 -5
  43. package/src/SceneView.tsx +1 -1
  44. package/src/TabBar.tsx +139 -44
  45. package/src/TabBarIndicator.tsx +20 -7
  46. package/src/TabBarItem.tsx +50 -42
  47. package/src/TabBarItemLabel.tsx +39 -0
  48. package/src/TabView.tsx +18 -1
  49. 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
package/src/types.tsx CHANGED
@@ -1,6 +1,8 @@
1
1
  import type { Animated } from 'react-native';
2
2
  import type { PagerViewProps } from 'react-native-pager-view';
3
3
 
4
+ export type LocaleDirection = 'ltr' | 'rtl';
5
+
4
6
  export type Route = {
5
7
  key: string;
6
8
  icon?: string;