@momo-kits/suggest-action 0.0.62-beta.8 → 0.0.65-beta.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/index.js +128 -113
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,129 +1,144 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import {
|
|
2
|
+
Button,
|
|
3
|
+
Colors,
|
|
4
|
+
Icon,
|
|
5
|
+
IconSource,
|
|
6
|
+
Image,
|
|
7
|
+
ScaleSize,
|
|
8
|
+
Shadow,
|
|
9
|
+
Spacing,
|
|
10
|
+
Text,
|
|
11
|
+
TouchableOpacity,
|
|
12
|
+
} from '@momo-kits/core-v2';
|
|
13
|
+
import React, {forwardRef, useEffect, useImperativeHandle, useRef} from 'react';
|
|
14
|
+
import {Animated, StyleSheet, View} from 'react-native';
|
|
14
15
|
import ExpenseI18n from './ExpenseI18n';
|
|
15
16
|
|
|
16
|
-
export default SuggestAction = ({
|
|
17
|
+
export default SuggestAction = forwardRef((props, ref) => {
|
|
18
|
+
const {
|
|
17
19
|
icon,
|
|
18
20
|
name,
|
|
19
21
|
buttonTitle = 'Thêm ngay',
|
|
20
22
|
onPressButton,
|
|
21
23
|
onPressClose,
|
|
22
24
|
iconTintColor,
|
|
23
|
-
visible = false,
|
|
24
25
|
style,
|
|
25
26
|
contentType = 'add',
|
|
26
|
-
}
|
|
27
|
-
const getContent = (contentType) => {
|
|
28
|
-
switch (contentType) {
|
|
29
|
-
case 'add':
|
|
30
|
-
return {
|
|
31
|
-
start: ExpenseI18n.get('add'),
|
|
32
|
-
end: ExpenseI18n.get('favorite'),
|
|
33
|
-
};
|
|
34
|
-
case 'move':
|
|
35
|
-
return {
|
|
36
|
-
start: ExpenseI18n.get('move'),
|
|
37
|
-
end: ExpenseI18n.get('homescreen'),
|
|
38
|
-
};
|
|
39
|
-
case 'share':
|
|
40
|
-
return {
|
|
41
|
-
start: ExpenseI18n.get('share'),
|
|
42
|
-
end: ExpenseI18n.get('friend'),
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
};
|
|
27
|
+
} = props;
|
|
46
28
|
|
|
47
|
-
|
|
48
|
-
|
|
29
|
+
const getContent = contentType => {
|
|
30
|
+
switch (contentType) {
|
|
31
|
+
case 'add':
|
|
32
|
+
return {
|
|
33
|
+
start: ExpenseI18n.get('add'),
|
|
34
|
+
end: ExpenseI18n.get('favorite'),
|
|
35
|
+
};
|
|
36
|
+
case 'move':
|
|
37
|
+
return {
|
|
38
|
+
start: ExpenseI18n.get('move'),
|
|
39
|
+
end: ExpenseI18n.get('homescreen'),
|
|
40
|
+
};
|
|
41
|
+
case 'share':
|
|
42
|
+
return {
|
|
43
|
+
start: ExpenseI18n.get('share'),
|
|
44
|
+
end: ExpenseI18n.get('friend'),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const fadeAnimation = useRef(new Animated.Value(0)).current;
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
50
|
+
const contentStart = getContent(contentType).start;
|
|
51
|
+
const contentEnd = getContent(contentType).end;
|
|
52
|
+
|
|
53
|
+
const show = () => {
|
|
54
|
+
Animated.timing(fadeAnimation, {
|
|
55
|
+
toValue: 1,
|
|
56
|
+
duration: 100,
|
|
57
|
+
useNativeDriver: true,
|
|
58
|
+
}).start();
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const hide = () => {
|
|
62
|
+
Animated.timing(fadeAnimation, {
|
|
63
|
+
toValue: 0,
|
|
64
|
+
useNativeDriver: true,
|
|
65
|
+
duration: 100,
|
|
66
|
+
}).start();
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
useImperativeHandle(
|
|
70
|
+
ref,
|
|
71
|
+
() => ({
|
|
72
|
+
show,
|
|
73
|
+
hide,
|
|
74
|
+
}),
|
|
75
|
+
[],
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<Animated.View
|
|
80
|
+
style={[styles.container, style, Shadow.Light, {opacity: fadeAnimation}]}>
|
|
81
|
+
{icon && (
|
|
82
|
+
<Image source={icon} style={styles.icon} tintColor={iconTintColor} />
|
|
83
|
+
)}
|
|
84
|
+
<Text style={styles.description} numberOfLines={2}>
|
|
85
|
+
{contentStart}{' '}
|
|
86
|
+
<Text style={[styles.description, {fontWeight: 'bold'}]}>{name}</Text>{' '}
|
|
87
|
+
{contentEnd}
|
|
88
|
+
</Text>
|
|
89
|
+
<Button
|
|
90
|
+
title={buttonTitle}
|
|
91
|
+
type="tonal"
|
|
92
|
+
style={styles.button}
|
|
93
|
+
size="small"
|
|
94
|
+
onPress={onPressButton}
|
|
95
|
+
/>
|
|
96
|
+
<TouchableOpacity onPress={onPressClose}>
|
|
97
|
+
<Image
|
|
98
|
+
source={IconSource.ic_close_x_24}
|
|
99
|
+
tintColor={Colors.black_10}
|
|
100
|
+
style={styles.iconClose}
|
|
101
|
+
/>
|
|
102
|
+
</TouchableOpacity>
|
|
103
|
+
</Animated.View>
|
|
104
|
+
);
|
|
105
|
+
});
|
|
84
106
|
|
|
85
107
|
const styles = StyleSheet.create({
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
description: {
|
|
123
|
-
fontSize: 12,
|
|
124
|
-
lineHeight: 16,
|
|
125
|
-
paddingHorizontal: Spacing.S,
|
|
126
|
-
color: '#475160',
|
|
127
|
-
fontWeight: '500',
|
|
128
|
-
},
|
|
108
|
+
container: {
|
|
109
|
+
minHeight: 60,
|
|
110
|
+
margin: Spacing.M,
|
|
111
|
+
paddingHorizontal: Spacing.M,
|
|
112
|
+
paddingVertical: ScaleSize(14),
|
|
113
|
+
borderRadius: Spacing.S,
|
|
114
|
+
backgroundColor: Colors.white,
|
|
115
|
+
|
|
116
|
+
flexDirection: 'row',
|
|
117
|
+
alignItems: 'center',
|
|
118
|
+
position: 'absolute',
|
|
119
|
+
zIndex: 99,
|
|
120
|
+
},
|
|
121
|
+
button: {
|
|
122
|
+
height: ScaleSize(28),
|
|
123
|
+
// paddingVertical: ScaleSize(6),
|
|
124
|
+
// paddingHorizontal: Spacing.S,
|
|
125
|
+
},
|
|
126
|
+
icon: {
|
|
127
|
+
width: 36,
|
|
128
|
+
height: 36,
|
|
129
|
+
marginRight: Spacing.S,
|
|
130
|
+
marginLeft: Spacing.XS,
|
|
131
|
+
},
|
|
132
|
+
iconClose: {
|
|
133
|
+
width: ScaleSize(24),
|
|
134
|
+
height: ScaleSize(24),
|
|
135
|
+
marginLeft: Spacing.S,
|
|
136
|
+
},
|
|
137
|
+
description: {
|
|
138
|
+
fontSize: 12,
|
|
139
|
+
lineHeight: 16,
|
|
140
|
+
paddingHorizontal: Spacing.S,
|
|
141
|
+
color: '#475160',
|
|
142
|
+
fontWeight: '500',
|
|
143
|
+
},
|
|
129
144
|
});
|
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.65-beta.1",
|
|
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"
|