@momo-kits/foundation 1.0.11 → 1.0.12

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/Assets/icon.json CHANGED
@@ -3934,5 +3934,14 @@
3934
3934
  },
3935
3935
  "ic_error": {
3936
3936
  "uri": "https://img.mservice.com.vn/app/img/kits/error_mess_icon.png"
3937
+ },
3938
+ "media_fail": {
3939
+ "uri": "https://static.momocdn.net/app/img/kits/media_fail.png"
3940
+ },
3941
+ "ic_checked": {
3942
+ "uri": "https://img.mservice.com.vn/app/img/kits/checked_ic.png"
3943
+ },
3944
+ "ic_minus": {
3945
+ "uri": "https://img.mservice.com.vn/app/img/kits/minus.png"
3937
3946
  }
3938
3947
  }
package/Button/index.tsx CHANGED
@@ -11,6 +11,7 @@ import {Typography} from '../Text/types';
11
11
  import {Colors} from '../Consts';
12
12
  import styles from './styles';
13
13
  import {Image} from '../Image';
14
+ import {Icon} from '../Icon';
14
15
 
15
16
  export interface ButtonProps extends TouchableOpacityProps {
16
17
  type?:
@@ -179,11 +180,7 @@ const Button: FC<ButtonProps> = ({
179
180
  styles.leading,
180
181
  {width: iconSize, height: iconSize, marginRight},
181
182
  ]}>
182
- <Image
183
- tintColor={color}
184
- source={{uri: iconLeft}}
185
- style={{width: iconSize, height: iconSize}}
186
- />
183
+ <Icon color={color} source={iconLeft} size={iconSize} />
187
184
  </View>
188
185
  );
189
186
  }
@@ -203,11 +200,7 @@ const Button: FC<ButtonProps> = ({
203
200
  styles.trailing,
204
201
  {width: iconSize, height: iconSize, marginLeft},
205
202
  ]}>
206
- <Image
207
- tintColor={color}
208
- source={{uri: iconRight}}
209
- style={{width: iconSize, height: iconSize}}
210
- />
203
+ <Icon color={color} source={iconRight} size={iconSize} />
211
204
  </View>
212
205
  );
213
206
  }
@@ -2,13 +2,10 @@ import React, {FC, useContext} from 'react';
2
2
  import {TouchableOpacity, View} from 'react-native';
3
3
  import {CheckBoxProps} from './types';
4
4
  import styles from './styles';
5
- import Image from 'react-native-fast-image';
6
5
  import {ApplicationContext} from '../Navigation';
7
6
  import {Text} from '../Text';
7
+ import {Icon} from '../Icon';
8
8
 
9
- const IC_INDETERMINATED = 'https://img.mservice.com.vn/app/img/kits/minus.png';
10
- const IC_CHECKED_DEFAULT =
11
- 'https://img.mservice.com.vn/app/img/kits/checked_ic.png';
12
9
  const CheckBox: FC<CheckBoxProps> = props => {
13
10
  const {theme} = useContext(ApplicationContext);
14
11
  const {value, disabled, onChange, style, label, indeterminated} = props;
@@ -21,11 +18,7 @@ const CheckBox: FC<CheckBoxProps> = props => {
21
18
  ? theme.colors.primary
22
19
  : theme.colors.background.surface;
23
20
 
24
- let iconSource = value ? IC_CHECKED_DEFAULT : undefined;
25
-
26
- if (indeterminated) {
27
- iconSource = IC_INDETERMINATED;
28
- }
21
+ let iconSource = indeterminated ? 'ic_minus' : 'ic_checked';
29
22
 
30
23
  if (disabled) {
31
24
  borderColor = haveValue
@@ -47,7 +40,13 @@ const CheckBox: FC<CheckBoxProps> = props => {
47
40
  disabled={disabled}
48
41
  style={[style, styles.container]}>
49
42
  <View style={[checkboxStyle, styles.checkbox]}>
50
- <Image style={styles.icon} source={{uri: iconSource}} />
43
+ {haveValue && (
44
+ <Icon
45
+ color={theme.colors.background.surface}
46
+ size={20}
47
+ source={iconSource}
48
+ />
49
+ )}
51
50
  </View>
52
51
  <Text typography={'description_default'}>{label}</Text>
53
52
  </TouchableOpacity>
@@ -12,5 +12,4 @@ export default StyleSheet.create({
12
12
  alignItems: 'center',
13
13
  },
14
14
  container: {flexDirection: 'row'},
15
- icon: {width: 20, height: 20},
16
15
  });
package/Image/index.tsx CHANGED
@@ -29,7 +29,7 @@ const Image: React.FC<ImageProps> = ({style, source, ...rest}) => {
29
29
  if (fail) {
30
30
  content = (
31
31
  <View style={Styles.flexCenter}>
32
- <Icon source="error-outline" />
32
+ <Icon source="media_fail" color={theme.colors.text.disable} />
33
33
  </View>
34
34
  );
35
35
  }
package/Input/Input.tsx CHANGED
@@ -113,11 +113,7 @@ const Input: FC<InputProps> = ({
113
113
  </TouchableOpacity>
114
114
  )}
115
115
  {icon && (
116
- <Image
117
- tintColor={iconTintColor}
118
- source={{uri: icon}}
119
- style={styles.icon}
120
- />
116
+ <Icon icon={iconTintColor} source={icon} style={styles.icon} />
121
117
  )}
122
118
  </View>
123
119
  </View>
@@ -116,13 +116,7 @@ const InputMoney: FC<InputMoneyProps> = ({
116
116
  />
117
117
  </TouchableOpacity>
118
118
  )}
119
- {icon && (
120
- <Image
121
- tintColor={iconTintColor}
122
- source={{uri: icon}}
123
- style={styles.icon}
124
- />
125
- )}
119
+ {icon && <Icon color={iconTintColor} source={icon} />}
126
120
  </View>
127
121
  </View>
128
122
  );
@@ -112,11 +112,7 @@ const InputSearch: FC<InputSearchProps> = ({
112
112
  },
113
113
  ]}
114
114
  />
115
- <Image
116
- tintColor={iconTintColor}
117
- source={{uri: icon}}
118
- style={styles.iconSearchInput}
119
- />
115
+ <Icon color={iconTintColor} source={icon} />
120
116
  </View>
121
117
  )}
122
118
  </View>
package/Input/common.tsx CHANGED
@@ -100,9 +100,10 @@ export const FloatingView: FC<FloatingViewProps> = ({
100
100
  )}
101
101
  </Text>
102
102
  {floatingIcon && (
103
- <Image
104
- tintColor={floatingIconTintColor}
105
- source={{uri: floatingIcon}}
103
+ <Icon
104
+ color={floatingIconTintColor}
105
+ source={floatingIcon}
106
+ size={16}
106
107
  style={styles.floatingIcon}
107
108
  />
108
109
  )}
package/Input/styles.ts CHANGED
@@ -25,7 +25,7 @@ export default StyleSheet.create({
25
25
  paddingHorizontal: Spacing.S,
26
26
  flexDirection: 'row',
27
27
  },
28
- floatingIcon: {width: 16, height: 16, marginLeft: Spacing.XS},
28
+ floatingIcon: {marginLeft: Spacing.XS},
29
29
  errorIcon: {marginRight: Spacing.XS},
30
30
  errorView: {
31
31
  flexDirection: 'row',
@@ -1,8 +1,7 @@
1
1
  import React, {FC} from 'react';
2
- import {View} from 'react-native';
3
- import {BottomTabItemProps, BottomTabProps} from './types';
2
+ import {BottomTabProps} from './types';
4
3
  import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
5
- import {Icon} from '@momo-kits/foundation';
4
+ import {Icon} from '../Icon';
6
5
 
7
6
  const Tab = createBottomTabNavigator();
8
7
 
@@ -1,31 +1,29 @@
1
- import React, {useContext, useEffect, useMemo, useRef} from 'react';
2
- import {Animated, Platform, useWindowDimensions, View} from 'react-native';
1
+ import React, {useEffect, useMemo, useRef, useState} from 'react';
2
+ import {Animated, Easing, Platform, StyleSheet, View} from 'react-native';
3
3
  import LinearGradient from 'react-native-linear-gradient';
4
4
  import {SkeletonTypes} from './types';
5
- import {ApplicationContext} from '../Navigation';
6
5
  import {Styles} from '../Consts';
7
6
  import styles from './styles';
7
+ import {Colors} from '@momo-kits/foundation';
8
+
8
9
  const Skeleton: React.FC<SkeletonTypes> = ({style}) => {
9
- const {width} = useWindowDimensions();
10
- const {theme} = useContext(ApplicationContext);
11
- const beginShimmerPosition = useRef(new Animated.Value(-1)).current;
10
+ const [width, setWidth] = useState(0);
11
+ const PRIMARY_COLOR = Colors.black_05;
12
+ const HIGHLIGHT_COLOR1 = Colors.black_05;
13
+ const HIGHLIGHT_COLOR2 = Colors.black_03;
14
+ const beginShimmerPosition = useRef(new Animated.Value(0)).current;
12
15
 
13
- const shimmerColors = [
14
- theme.colors.text.disable + '40',
15
- theme.colors.text.disable + '80',
16
- theme.colors.text.disable,
17
- ];
18
- const location = [0.3, 0.5, 0.7];
16
+ const shimmerColors = [HIGHLIGHT_COLOR1, HIGHLIGHT_COLOR2, HIGHLIGHT_COLOR1];
19
17
  const linearTranslate = beginShimmerPosition.interpolate({
20
- inputRange: [-1, 1],
21
- outputRange: [0, width],
18
+ inputRange: [0, 1],
19
+ outputRange: [-width, width],
22
20
  });
23
21
  const animatedValue = useMemo(() => {
24
22
  return Animated.loop(
25
23
  Animated.timing(beginShimmerPosition, {
26
24
  toValue: 1,
27
- delay: 0,
28
25
  duration: 1000,
26
+ easing: Easing.linear,
29
27
  useNativeDriver: Platform.OS !== 'web',
30
28
  }),
31
29
  );
@@ -38,23 +36,33 @@ const Skeleton: React.FC<SkeletonTypes> = ({style}) => {
38
36
  };
39
37
  }, [animatedValue]);
40
38
 
39
+ const onLayout = (newWidth: number) => {
40
+ if (newWidth !== width) {
41
+ setWidth(newWidth);
42
+ }
43
+ };
41
44
  return (
42
45
  <View style={[styles.container, style]}>
43
- <View style={[Styles.flex, {backgroundColor: shimmerColors[0]}]}>
46
+ <View
47
+ onLayout={e => onLayout(e.nativeEvent.layout.width)}
48
+ style={[Styles.flex, {backgroundColor: PRIMARY_COLOR}]}>
44
49
  <Animated.View
45
- style={[Styles.flex, {transform: [{translateX: linearTranslate}]}]}>
50
+ style={{
51
+ transform: [{translateX: linearTranslate}],
52
+ width: '60%',
53
+ height: '100%',
54
+ }}>
46
55
  <LinearGradient
56
+ style={[StyleSheet.absoluteFill]}
47
57
  colors={shimmerColors}
48
- style={[Styles.flex, {width: width}]}
49
58
  start={{
50
- x: -1,
51
- y: 0.5,
59
+ x: 0,
60
+ y: 0,
52
61
  }}
53
62
  end={{
54
- x: 2,
55
- y: 0.5,
63
+ x: 1,
64
+ y: 0,
56
65
  }}
57
- locations={location}
58
66
  />
59
67
  </Animated.View>
60
68
  </View>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {