@momo-kits/suggest-action 0.0.61-beta.8 → 0.0.62-alpha.13
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/index.js +52 -28
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -5,25 +5,32 @@ import {
|
|
|
5
5
|
IconSource,
|
|
6
6
|
Image,
|
|
7
7
|
ScaleSize,
|
|
8
|
+
Shadow,
|
|
8
9
|
Spacing,
|
|
9
10
|
Text,
|
|
10
11
|
TouchableOpacity,
|
|
11
|
-
} from '@momo-kits/core';
|
|
12
|
-
import React
|
|
13
|
-
|
|
12
|
+
} from '@momo-kits/core-v2';
|
|
13
|
+
import React, {
|
|
14
|
+
forwardRef,
|
|
15
|
+
useEffect,
|
|
16
|
+
useImperativeHandle,
|
|
17
|
+
useRef,
|
|
18
|
+
} from 'react';
|
|
19
|
+
import { Animated, StyleSheet, View } from 'react-native';
|
|
14
20
|
import ExpenseI18n from './ExpenseI18n';
|
|
15
21
|
|
|
16
|
-
export default SuggestAction = ({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
22
|
+
export default SuggestAction = forwardRef((props, ref) => {
|
|
23
|
+
const {
|
|
24
|
+
icon,
|
|
25
|
+
name,
|
|
26
|
+
buttonTitle = 'Thêm ngay',
|
|
27
|
+
onPressButton,
|
|
28
|
+
onPressClose,
|
|
29
|
+
iconTintColor,
|
|
30
|
+
style,
|
|
31
|
+
contentType = 'add',
|
|
32
|
+
} = props;
|
|
33
|
+
|
|
27
34
|
const getContent = (contentType) => {
|
|
28
35
|
switch (contentType) {
|
|
29
36
|
case 'add':
|
|
@@ -43,12 +50,37 @@ export default SuggestAction = ({
|
|
|
43
50
|
};
|
|
44
51
|
}
|
|
45
52
|
};
|
|
53
|
+
const fadeAnimation = useRef(new Animated.Value(0)).current;
|
|
46
54
|
|
|
47
55
|
const contentStart = getContent(contentType).start;
|
|
48
56
|
const contentEnd = getContent(contentType).end;
|
|
49
57
|
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
const show = () => {
|
|
59
|
+
Animated.timing(fadeAnimation, {
|
|
60
|
+
toValue: 1,
|
|
61
|
+
duration: 100,
|
|
62
|
+
useNativeDriver: true,
|
|
63
|
+
}).start();
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const hide = () => {
|
|
67
|
+
Animated.timing(fadeAnimation, {
|
|
68
|
+
toValue: 0,
|
|
69
|
+
useNativeDriver: true,
|
|
70
|
+
duration: 100,
|
|
71
|
+
}).start();
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
useImperativeHandle(ref, () => ({ show, hide }), []);
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<Animated.View
|
|
78
|
+
style={[
|
|
79
|
+
styles.container,
|
|
80
|
+
style,
|
|
81
|
+
Shadow.Light,
|
|
82
|
+
{ opacity: fadeAnimation },
|
|
83
|
+
]}>
|
|
52
84
|
{icon && (
|
|
53
85
|
<Image
|
|
54
86
|
source={icon}
|
|
@@ -56,7 +88,6 @@ export default SuggestAction = ({
|
|
|
56
88
|
tintColor={iconTintColor}
|
|
57
89
|
/>
|
|
58
90
|
)}
|
|
59
|
-
<View></View>
|
|
60
91
|
<Text style={styles.description} numberOfLines={2}>
|
|
61
92
|
{contentStart}{' '}
|
|
62
93
|
<Text style={[styles.description, { fontWeight: 'bold' }]}>
|
|
@@ -78,9 +109,9 @@ export default SuggestAction = ({
|
|
|
78
109
|
style={styles.iconClose}
|
|
79
110
|
/>
|
|
80
111
|
</TouchableOpacity>
|
|
81
|
-
</View>
|
|
82
|
-
)
|
|
83
|
-
};
|
|
112
|
+
</Animated.View>
|
|
113
|
+
);
|
|
114
|
+
});
|
|
84
115
|
|
|
85
116
|
const styles = StyleSheet.create({
|
|
86
117
|
container: {
|
|
@@ -90,14 +121,7 @@ const styles = StyleSheet.create({
|
|
|
90
121
|
paddingVertical: ScaleSize(14),
|
|
91
122
|
borderRadius: Spacing.S,
|
|
92
123
|
backgroundColor: Colors.white,
|
|
93
|
-
|
|
94
|
-
shadowOffset: {
|
|
95
|
-
width: 0,
|
|
96
|
-
height: 4,
|
|
97
|
-
},
|
|
98
|
-
shadowOpacity: 0.3,
|
|
99
|
-
shadowRadius: 4.65,
|
|
100
|
-
elevation: 8,
|
|
124
|
+
|
|
101
125
|
flexDirection: 'row',
|
|
102
126
|
alignItems: 'center',
|
|
103
127
|
position: 'absolute',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/suggest-action",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.62-alpha.13",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {},
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"prop-types": "^15.7.2",
|
|
10
10
|
"react": "16.9.0",
|
|
11
11
|
"react-native": ">=0.55",
|
|
12
|
-
"@momo-kits/core": ">=0.0.5-beta"
|
|
12
|
+
"@momo-kits/core-v2": ">=0.0.5-beta"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {},
|
|
15
15
|
"license": "MoMo"
|