react-native-tab-view 4.0.0-alpha.9 → 4.0.0-rc.1
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/commonjs/Pager.android.js.map +1 -1
- package/lib/commonjs/Pager.ios.js.map +1 -1
- package/lib/commonjs/Pager.js.map +1 -1
- package/lib/commonjs/PagerViewAdapter.js +24 -24
- package/lib/commonjs/PagerViewAdapter.js.map +1 -1
- package/lib/commonjs/PanResponderAdapter.js +27 -29
- package/lib/commonjs/PanResponderAdapter.js.map +1 -1
- package/lib/commonjs/PlatformPressable.js +20 -22
- package/lib/commonjs/PlatformPressable.js.map +1 -1
- package/lib/commonjs/SceneMap.js +16 -20
- package/lib/commonjs/SceneMap.js.map +1 -1
- package/lib/commonjs/SceneView.js +11 -12
- package/lib/commonjs/SceneView.js.map +1 -1
- package/lib/commonjs/TabBar.js +87 -106
- package/lib/commonjs/TabBar.js.map +1 -1
- package/lib/commonjs/TabBarIndicator.js +25 -17
- package/lib/commonjs/TabBarIndicator.js.map +1 -1
- package/lib/commonjs/TabBarItem.js +44 -36
- package/lib/commonjs/TabBarItem.js.map +1 -1
- package/lib/commonjs/TabBarItemLabel.js +7 -8
- package/lib/commonjs/TabBarItemLabel.js.map +1 -1
- package/lib/commonjs/TabView.js +37 -42
- package/lib/commonjs/TabView.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.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.map +1 -1
- package/lib/module/Pager.ios.js.map +1 -1
- package/lib/module/Pager.js.map +1 -1
- package/lib/module/PagerViewAdapter.js +22 -22
- package/lib/module/PagerViewAdapter.js.map +1 -1
- package/lib/module/PanResponderAdapter.js +25 -28
- package/lib/module/PanResponderAdapter.js.map +1 -1
- package/lib/module/PlatformPressable.js +19 -21
- package/lib/module/PlatformPressable.js.map +1 -1
- package/lib/module/SceneMap.js +15 -19
- package/lib/module/SceneMap.js.map +1 -1
- package/lib/module/SceneView.js +10 -11
- package/lib/module/SceneView.js.map +1 -1
- package/lib/module/TabBar.js +85 -104
- package/lib/module/TabBar.js.map +1 -1
- package/lib/module/TabBarIndicator.js +24 -16
- package/lib/module/TabBarIndicator.js.map +1 -1
- package/lib/module/TabBarItem.js +43 -35
- package/lib/module/TabBarItem.js.map +1 -1
- package/lib/module/TabBarItemLabel.js +6 -7
- package/lib/module/TabBarItemLabel.js.map +1 -1
- package/lib/module/TabView.js +36 -41
- package/lib/module/TabView.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/useAnimatedValue.js.map +1 -1
- package/lib/typescript/src/PagerViewAdapter.d.ts.map +1 -1
- package/lib/typescript/src/PanResponderAdapter.d.ts.map +1 -1
- package/lib/typescript/src/PlatformPressable.d.ts.map +1 -1
- package/lib/typescript/src/TabBarIndicator.d.ts.map +1 -1
- package/lib/typescript/src/TabBarItem.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +6 -6
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useAnimatedValue.d.ts.map +1 -1
- package/package.json +6 -7
- package/src/PagerViewAdapter.tsx +16 -16
- package/src/PanResponderAdapter.tsx +12 -15
- package/src/PlatformPressable.tsx +4 -1
- package/src/TabBar.tsx +2 -2
- package/src/TabBarIndicator.tsx +19 -4
- package/src/TabBarItem.tsx +8 -2
- package/src/types.tsx +5 -6
package/src/TabBarIndicator.tsx
CHANGED
|
@@ -33,14 +33,29 @@ const getTranslateX = (
|
|
|
33
33
|
routes: Route[],
|
|
34
34
|
getTabWidth: GetTabWidth,
|
|
35
35
|
direction: LocaleDirection,
|
|
36
|
-
gap?: number
|
|
36
|
+
gap?: number,
|
|
37
|
+
width?: number | string
|
|
37
38
|
) => {
|
|
38
39
|
const inputRange = routes.map((_, i) => i);
|
|
39
40
|
|
|
40
41
|
// every index contains widths at all previous indices
|
|
41
42
|
const outputRange = routes.reduce<number[]>((acc, _, i) => {
|
|
42
|
-
if (
|
|
43
|
-
|
|
43
|
+
if (typeof width === 'number') {
|
|
44
|
+
if (i === 0) return [getTabWidth(i) / 2 - width / 2];
|
|
45
|
+
|
|
46
|
+
let sumTabWidth = 0;
|
|
47
|
+
for (let j = 0; j < i; j++) {
|
|
48
|
+
sumTabWidth += getTabWidth(j);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return [
|
|
52
|
+
...acc,
|
|
53
|
+
sumTabWidth + getTabWidth(i) / 2 + (gap ? gap * i : 0) - width / 2,
|
|
54
|
+
];
|
|
55
|
+
} else {
|
|
56
|
+
if (i === 0) return [0];
|
|
57
|
+
return [...acc, acc[i - 1] + getTabWidth(i - 1) + (gap ?? 0)];
|
|
58
|
+
}
|
|
44
59
|
}, []);
|
|
45
60
|
|
|
46
61
|
const translateX = position.interpolate({
|
|
@@ -106,7 +121,7 @@ export function TabBarIndicator<T extends Route>({
|
|
|
106
121
|
if (layout.width) {
|
|
107
122
|
const translateX =
|
|
108
123
|
routes.length > 1
|
|
109
|
-
? getTranslateX(position, routes, getTabWidth, direction, gap)
|
|
124
|
+
? getTranslateX(position, routes, getTabWidth, direction, gap, width)
|
|
110
125
|
: 0;
|
|
111
126
|
|
|
112
127
|
transform.push({ translateX });
|
package/src/TabBarItem.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
Animated,
|
|
4
4
|
type LayoutChangeEvent,
|
|
5
|
+
Platform,
|
|
5
6
|
type PressableAndroidRippleConfig,
|
|
6
7
|
type StyleProp,
|
|
7
8
|
StyleSheet,
|
|
@@ -176,7 +177,7 @@ const TabBarItemInternal = <T extends Route>({
|
|
|
176
177
|
focused,
|
|
177
178
|
color: focused ? activeColor : inactiveColor,
|
|
178
179
|
style: labelStyle,
|
|
179
|
-
|
|
180
|
+
labelText,
|
|
180
181
|
allowFontScaling: labelAllowFontScaling,
|
|
181
182
|
route,
|
|
182
183
|
})
|
|
@@ -240,7 +241,7 @@ const TabBarItemInternal = <T extends Route>({
|
|
|
240
241
|
</Animated.View>
|
|
241
242
|
</View>
|
|
242
243
|
{customBadge != null ? (
|
|
243
|
-
<View style={styles.badge}>{customBadge()}</View>
|
|
244
|
+
<View style={styles.badge}>{customBadge({ route })}</View>
|
|
244
245
|
) : null}
|
|
245
246
|
</View>
|
|
246
247
|
</PlatformPressable>
|
|
@@ -295,5 +296,10 @@ const styles = StyleSheet.create({
|
|
|
295
296
|
// The label is not pressable on Windows
|
|
296
297
|
// Adding backgroundColor: 'transparent' seems to fix it
|
|
297
298
|
backgroundColor: 'transparent',
|
|
299
|
+
...Platform.select({
|
|
300
|
+
// Roundness for iPad hover effect
|
|
301
|
+
ios: { borderRadius: 10 },
|
|
302
|
+
default: null,
|
|
303
|
+
}),
|
|
298
304
|
},
|
|
299
305
|
});
|
package/src/types.tsx
CHANGED
|
@@ -3,27 +3,26 @@ import type { PagerViewProps } from 'react-native-pager-view';
|
|
|
3
3
|
|
|
4
4
|
export type TabDescriptor<T extends Route> = {
|
|
5
5
|
accessibilityLabel?: string;
|
|
6
|
-
labelStyle?: StyleProp<TextStyle>;
|
|
7
6
|
accessible?: boolean;
|
|
8
7
|
testID?: string;
|
|
9
8
|
labelText?: string;
|
|
10
9
|
labelAllowFontScaling?: boolean;
|
|
11
10
|
href?: string;
|
|
12
11
|
label?: (props: {
|
|
12
|
+
route: T;
|
|
13
|
+
labelText?: string;
|
|
13
14
|
focused: boolean;
|
|
14
15
|
color: string;
|
|
15
|
-
style?: StyleProp<TextStyle>;
|
|
16
16
|
allowFontScaling?: boolean;
|
|
17
|
-
|
|
18
|
-
route: T;
|
|
17
|
+
style?: StyleProp<TextStyle>;
|
|
19
18
|
}) => React.ReactElement;
|
|
20
19
|
icon?: (props: {
|
|
20
|
+
route: T;
|
|
21
21
|
focused: boolean;
|
|
22
22
|
color: string;
|
|
23
23
|
size: number;
|
|
24
|
-
route: T;
|
|
25
24
|
}) => React.ReactElement;
|
|
26
|
-
badge?: () => React.ReactElement;
|
|
25
|
+
badge?: (props: { route: T }) => React.ReactElement;
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
export type LocaleDirection = 'ltr' | 'rtl';
|