@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.
Files changed (2) hide show
  1. package/index.js +113 -128
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -1,144 +1,129 @@
1
1
  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';
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 = forwardRef((props, ref) => {
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
- } = props;
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
- 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;
47
+ const contentStart = getContent(contentType).start;
48
+ const contentEnd = getContent(contentType).end;
49
49
 
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
- });
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
- 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
- },
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.16",
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-v2": ">=0.0.5-beta"
12
+ "@momo-kits/core": ">=0.0.5-beta"
13
13
  },
14
14
  "devDependencies": {},
15
15
  "license": "MoMo"