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