@momo-kits/tab-view 0.92.6-rc.8 → 0.92.7
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/package.json +1 -1
- package/styles.ts +5 -1
- package/tabBar/CardTabBar.tsx +6 -2
- package/tabBar/SrollableTabBar.tsx +16 -6
- package/tabItem/CardTabItem.tsx +3 -3
- package/tabItem/TabItem.tsx +12 -4
package/package.json
CHANGED
package/styles.ts
CHANGED
|
@@ -52,6 +52,9 @@ export default StyleSheet.create({
|
|
|
52
52
|
flexDirection: 'row',
|
|
53
53
|
justifyContent: 'center',
|
|
54
54
|
alignItems: 'center',
|
|
55
|
+
paddingHorizontal: Spacing.S,
|
|
56
|
+
paddingTop: Spacing.S,
|
|
57
|
+
paddingBottom: Spacing.M,
|
|
55
58
|
},
|
|
56
59
|
cardTabOverlay: {
|
|
57
60
|
flexDirection: 'row',
|
|
@@ -65,7 +68,8 @@ export default StyleSheet.create({
|
|
|
65
68
|
height: '100%',
|
|
66
69
|
alignItems: 'center',
|
|
67
70
|
justifyContent: 'center',
|
|
68
|
-
|
|
71
|
+
paddingVertical: Spacing.M,
|
|
72
|
+
paddingHorizontal: Spacing.S,
|
|
69
73
|
flexDirection: 'row',
|
|
70
74
|
},
|
|
71
75
|
dotSmall: {
|
package/tabBar/CardTabBar.tsx
CHANGED
|
@@ -65,6 +65,7 @@ const CardTabBar: FC<TabBarProps> = ({
|
|
|
65
65
|
width: containerWidth / tabs.length,
|
|
66
66
|
borderTopRightRadius: Radius.M,
|
|
67
67
|
borderTopLeftRadius: Radius.M,
|
|
68
|
+
paddingHorizontal: tabs.length === 3 ? Spacing.S : Spacing.M,
|
|
68
69
|
},
|
|
69
70
|
]}>
|
|
70
71
|
{!!tabs[selectedIndex]?.renderIcon &&
|
|
@@ -90,7 +91,7 @@ const CardTabBar: FC<TabBarProps> = ({
|
|
|
90
91
|
<Text
|
|
91
92
|
color={selectedColor}
|
|
92
93
|
numberOfLines={1}
|
|
93
|
-
style={styles.textCenter}
|
|
94
|
+
style={[styles.textCenter, {flexShrink: 1}]}
|
|
94
95
|
typography={'header_s_semibold'}>
|
|
95
96
|
{tabs[selectedIndex]?.title || ''}
|
|
96
97
|
</Text>
|
|
@@ -104,7 +105,10 @@ const CardTabBar: FC<TabBarProps> = ({
|
|
|
104
105
|
)}
|
|
105
106
|
{!tabs[selectedIndex]?.showDot && tabs[selectedIndex]?.badgeValue && (
|
|
106
107
|
<View>
|
|
107
|
-
<Badge
|
|
108
|
+
<Badge
|
|
109
|
+
label={tabs[selectedIndex]?.badgeValue}
|
|
110
|
+
style={{marginLeft: Spacing.XS}}
|
|
111
|
+
/>
|
|
108
112
|
</View>
|
|
109
113
|
)}
|
|
110
114
|
</View>
|
|
@@ -11,12 +11,14 @@ const ScrollableTabBar: FC<TabBarProps> = ({
|
|
|
11
11
|
selectedIndex,
|
|
12
12
|
selectedColor,
|
|
13
13
|
unselectedColor,
|
|
14
|
+
direction,
|
|
14
15
|
}) => {
|
|
15
16
|
const {theme} = useContext(ApplicationContext);
|
|
16
17
|
const [itemWidthMap, setItemWidthMap] = useState<
|
|
17
18
|
{width: number; x: number}[]
|
|
18
19
|
>([]);
|
|
19
20
|
const animatedWidth = useRef(new Animated.Value(0)).current;
|
|
21
|
+
const animX = useRef(new Animated.Value(0)).current;
|
|
20
22
|
const scrollViewRef = useRef<ScrollView>(null);
|
|
21
23
|
|
|
22
24
|
useEffect(() => {
|
|
@@ -24,11 +26,18 @@ const ScrollableTabBar: FC<TabBarProps> = ({
|
|
|
24
26
|
scrollToIndex(selectedIndex);
|
|
25
27
|
}, [selectedIndex, itemWidthMap]);
|
|
26
28
|
const moveIndicator = () => {
|
|
27
|
-
Animated.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
Animated.parallel([
|
|
30
|
+
Animated.timing(animatedWidth, {
|
|
31
|
+
toValue: itemWidthMap[selectedIndex]?.width || 0,
|
|
32
|
+
duration: 250,
|
|
33
|
+
useNativeDriver: false,
|
|
34
|
+
}),
|
|
35
|
+
Animated.timing(animX, {
|
|
36
|
+
toValue: itemWidthMap[selectedIndex]?.x || 0,
|
|
37
|
+
duration: 250,
|
|
38
|
+
useNativeDriver: false,
|
|
39
|
+
}),
|
|
40
|
+
]).start();
|
|
32
41
|
};
|
|
33
42
|
|
|
34
43
|
const onLayout = (e: LayoutChangeEvent, index: number) => {
|
|
@@ -66,6 +75,7 @@ const ScrollableTabBar: FC<TabBarProps> = ({
|
|
|
66
75
|
tab={item}
|
|
67
76
|
selectedColor={selectedColor}
|
|
68
77
|
unselectedColor={unselectedColor}
|
|
78
|
+
direction={direction}
|
|
69
79
|
/>
|
|
70
80
|
</View>
|
|
71
81
|
);
|
|
@@ -88,7 +98,7 @@ const ScrollableTabBar: FC<TabBarProps> = ({
|
|
|
88
98
|
style={[
|
|
89
99
|
styles.indicator,
|
|
90
100
|
{
|
|
91
|
-
left:
|
|
101
|
+
left: animX,
|
|
92
102
|
width: animatedWidth,
|
|
93
103
|
backgroundColor: selectedColor,
|
|
94
104
|
},
|
package/tabItem/CardTabItem.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import React, {FC} from 'react';
|
|
|
2
2
|
import {TouchableOpacity, View} from 'react-native';
|
|
3
3
|
import {TabItemProps} from '../types';
|
|
4
4
|
import styles from '../styles';
|
|
5
|
-
import {Badge, BadgeDot, Icon, Spacing, Text
|
|
5
|
+
import {Badge, BadgeDot, Icon, Spacing, Text} from '@momo-kits/foundation';
|
|
6
6
|
|
|
7
7
|
const CardTabItem: FC<TabItemProps> = ({
|
|
8
8
|
tab,
|
|
@@ -42,7 +42,7 @@ const CardTabItem: FC<TabItemProps> = ({
|
|
|
42
42
|
)}
|
|
43
43
|
<Text
|
|
44
44
|
numberOfLines={1}
|
|
45
|
-
style={styles.textCenter}
|
|
45
|
+
style={[styles.textCenter, {flexShrink: 1}]}
|
|
46
46
|
typography={'body_default_regular'}>
|
|
47
47
|
{title}
|
|
48
48
|
</Text>
|
|
@@ -56,7 +56,7 @@ const CardTabItem: FC<TabItemProps> = ({
|
|
|
56
56
|
)}
|
|
57
57
|
{!showDot && badgeValue && (
|
|
58
58
|
<View>
|
|
59
|
-
<Badge label={badgeValue} />
|
|
59
|
+
<Badge label={badgeValue} style={{marginLeft: Spacing.XS}} />
|
|
60
60
|
</View>
|
|
61
61
|
)}
|
|
62
62
|
</TouchableOpacity>
|
package/tabItem/TabItem.tsx
CHANGED
|
@@ -47,6 +47,8 @@ const TabItem: FC<TabItemProps> = ({
|
|
|
47
47
|
height: scaleSize(48),
|
|
48
48
|
flexDirection: 'row',
|
|
49
49
|
overflow: 'hidden',
|
|
50
|
+
paddingVertical: Spacing.M,
|
|
51
|
+
paddingHorizontal: Spacing.M,
|
|
50
52
|
},
|
|
51
53
|
]}
|
|
52
54
|
onPress={onPressTabItem}>
|
|
@@ -56,19 +58,23 @@ const TabItem: FC<TabItemProps> = ({
|
|
|
56
58
|
style={[
|
|
57
59
|
styles.icon,
|
|
58
60
|
styles.iconHolder,
|
|
59
|
-
{marginRight: Spacing.
|
|
61
|
+
{marginRight: Spacing.S},
|
|
60
62
|
]}>
|
|
61
63
|
{renderIcon}
|
|
62
64
|
</View>
|
|
63
65
|
)}
|
|
64
66
|
{!renderIcon && !!icon && (
|
|
65
67
|
<Icon
|
|
66
|
-
style={[styles.icon, {marginRight: Spacing.
|
|
68
|
+
style={[styles.icon, {marginRight: Spacing.S}]}
|
|
67
69
|
source={icon}
|
|
68
70
|
color={color}
|
|
69
71
|
/>
|
|
70
72
|
)}
|
|
71
|
-
<Text
|
|
73
|
+
<Text
|
|
74
|
+
numberOfLines={1}
|
|
75
|
+
typography={typography}
|
|
76
|
+
color={color}
|
|
77
|
+
style={{flexShrink: 1}}>
|
|
72
78
|
{title}
|
|
73
79
|
</Text>
|
|
74
80
|
{showDot && (
|
|
@@ -76,7 +82,7 @@ const TabItem: FC<TabItemProps> = ({
|
|
|
76
82
|
)}
|
|
77
83
|
{!showDot && badgeValue && (
|
|
78
84
|
<View>
|
|
79
|
-
<Badge label={badgeValue} />
|
|
85
|
+
<Badge label={badgeValue} style={{marginLeft: Spacing.XS}} />
|
|
80
86
|
</View>
|
|
81
87
|
)}
|
|
82
88
|
</TouchableOpacity>
|
|
@@ -93,6 +99,8 @@ const TabItem: FC<TabItemProps> = ({
|
|
|
93
99
|
height: scaleSize(68),
|
|
94
100
|
flexDirection: 'column',
|
|
95
101
|
overflow: 'hidden',
|
|
102
|
+
paddingHorizontal: Spacing.M,
|
|
103
|
+
paddingVertical: Spacing.M,
|
|
96
104
|
},
|
|
97
105
|
]}
|
|
98
106
|
onPress={onPressTabItem}>
|