@momo-kits/suggest-action 0.75.1-beta.6 → 0.77.8-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.tsx ADDED
@@ -0,0 +1,117 @@
1
+ import React, {
2
+ forwardRef,
3
+ ForwardRefRenderFunction,
4
+ useContext,
5
+ useImperativeHandle,
6
+ useRef,
7
+ } from 'react';
8
+ import {Animated, Easing, TouchableOpacity} from 'react-native';
9
+ import {SuggestActionProps, SuggestActionRef} from './types';
10
+ import {
11
+ ApplicationContext,
12
+ Button,
13
+ Icon,
14
+ Image,
15
+ Shadow,
16
+ Text,
17
+ } from '@momo-kits/foundation';
18
+ import styles from './styles';
19
+
20
+ const contents = {
21
+ addToFavorite: {
22
+ prefix: 'Thêm',
23
+ postfix: 'vào dịch vụ yêu thích',
24
+ buttonTitle: 'Thêm ngay',
25
+ },
26
+ addToDevice: {
27
+ prefix: 'Thêm',
28
+ postfix: 'ra ngoài màn hình thiết bị',
29
+ buttonTitle: 'Thêm ngay',
30
+ },
31
+ share: {
32
+ prefix: 'Chia sẻ',
33
+ postfix: 'với người khác ngay',
34
+ buttonTitle: 'Chia sẻ',
35
+ },
36
+ };
37
+
38
+ const DURATION = 200;
39
+
40
+ const SuggestAction: ForwardRefRenderFunction<
41
+ SuggestActionRef,
42
+ SuggestActionProps
43
+ > = (
44
+ {
45
+ image,
46
+ onPressButton = () => {},
47
+ name,
48
+ onClose,
49
+ type = 'addToFavorite',
50
+ bottom = 72,
51
+ },
52
+ ref,
53
+ ) => {
54
+ const {theme} = useContext(ApplicationContext);
55
+ const opacity = useRef(new Animated.Value(0)).current;
56
+
57
+ useImperativeHandle(ref, () => ({show}));
58
+ const show = () => {
59
+ Animated.timing(opacity, {
60
+ toValue: 1,
61
+ duration: DURATION,
62
+ useNativeDriver: false,
63
+ easing: Easing.linear,
64
+ }).start();
65
+ };
66
+ const hide = () => {
67
+ Animated.timing(opacity, {
68
+ toValue: 0,
69
+ duration: DURATION,
70
+ easing: Easing.linear,
71
+ useNativeDriver: false,
72
+ }).start();
73
+ };
74
+
75
+ const handleClose = () => {
76
+ onClose?.();
77
+ hide();
78
+ };
79
+
80
+ const handleButtonPress = () => {
81
+ onPressButton?.();
82
+ hide();
83
+ };
84
+
85
+ return (
86
+ <Animated.View
87
+ style={[
88
+ styles.container,
89
+ {
90
+ backgroundColor: theme.colors.background.surface,
91
+ opacity,
92
+ bottom,
93
+ },
94
+ Shadow.Light,
95
+ ]}>
96
+ <Image source={{uri: image}} style={styles.image} />
97
+ <Text style={styles.content} typography={'description_s'}>
98
+ {contents[type].prefix}
99
+ <Text typography={'action_xs'}>{` ${name} `}</Text>
100
+ {contents[type].postfix}
101
+ </Text>
102
+ <Button
103
+ type="tonal"
104
+ title={contents[type].buttonTitle}
105
+ onPress={handleButtonPress}
106
+ size={'small'}
107
+ full={false}
108
+ />
109
+ <TouchableOpacity style={styles.closeIcon} onPress={handleClose}>
110
+ <Icon source={'navigation_close'} />
111
+ </TouchableOpacity>
112
+ </Animated.View>
113
+ );
114
+ };
115
+
116
+ export default forwardRef(SuggestAction);
117
+ export type {SuggestActionRef, SuggestActionProps};
package/package.json CHANGED
@@ -1,15 +1,14 @@
1
1
  {
2
2
  "name": "@momo-kits/suggest-action",
3
- "version": "0.75.1-beta.6",
3
+ "version": "0.77.8-beta.01",
4
4
  "private": false,
5
- "main": "index.js",
5
+ "main": "index.tsx",
6
6
  "dependencies": {},
7
7
  "peerDependencies": {
8
- "lodash": "^4.17.15",
8
+ "@momo-kits/foundation": "latest",
9
9
  "prop-types": "^15.7.2",
10
10
  "react": "16.9.0",
11
- "react-native": ">=0.55",
12
- "@momo-kits/core-v2": ">=0.0.5-beta"
11
+ "react-native": ">=0.55"
13
12
  },
14
13
  "devDependencies": {},
15
14
  "license": "MoMo"
package/publish.sh CHANGED
@@ -26,4 +26,4 @@ cd ..
26
26
  rm -rf dist
27
27
 
28
28
 
29
- #curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/suggest new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/suggest-action"}'
29
+ ##curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/suggest-action new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/suggest-action"}'
package/styles.ts ADDED
@@ -0,0 +1,30 @@
1
+ import {Dimensions, StyleSheet} from 'react-native';
2
+ import {Radius, Spacing} from '@momo-kits/foundation';
3
+
4
+ const screenWidth = Dimensions.get('window').width;
5
+
6
+ export default StyleSheet.create({
7
+ image: {
8
+ width: 32,
9
+ height: 32,
10
+ borderRadius: Radius.XS,
11
+ marginRight: Spacing.S,
12
+ },
13
+ container: {
14
+ flexDirection: 'row',
15
+ width: screenWidth - Spacing.M * 2,
16
+ marginHorizontal: Spacing.M,
17
+ padding: Spacing.M,
18
+ borderRadius: Radius.S,
19
+ alignItems: 'center',
20
+ position: 'absolute',
21
+ zIndex: 10,
22
+ },
23
+ content: {
24
+ flex: 1,
25
+ marginRight: Spacing.M,
26
+ },
27
+ closeIcon: {
28
+ marginLeft: Spacing.S,
29
+ },
30
+ });
package/types.ts ADDED
@@ -0,0 +1,12 @@
1
+ export type SuggestActionProps = {
2
+ name: string;
3
+ onClose?: () => void;
4
+ onPressButton?: () => void;
5
+ image: string;
6
+ type?: 'addToFavorite' | 'addToDevice' | 'share';
7
+ bottom?: number;
8
+ };
9
+
10
+ export type SuggestActionRef = {
11
+ show: () => void;
12
+ };
package/ExpenseI18n.js DELETED
@@ -1,35 +0,0 @@
1
- import { LocalizedStrings } from '@momo-kits/core';
2
-
3
- let ExpenseI18n = new LocalizedStrings({
4
- vi: {
5
- add: 'Thêm',
6
- move: 'Đưa',
7
- share: 'Chia sẻ',
8
- favorite: 'vào Dịch vụ yêu thích',
9
- homescreen: 'ra ngoài màn hình thiết bị',
10
- friend: 'với người khác ngay',
11
- },
12
- en: {
13
- add: 'Add',
14
- move: 'Add',
15
- share: 'Share',
16
- favorite: 'to your Favorite Service',
17
- homescreen: 'to your home screen',
18
- friend: 'with your friends',
19
- },
20
- });
21
-
22
- ExpenseI18n.get = (key, defaultValue = '') => {
23
- let value;
24
- value = LocalizedStrings.getLocalize(key);
25
- console.log(value);
26
- if (!value || value.length <= 0) {
27
- value = defaultValue;
28
- }
29
- if (!value || typeof value !== 'string') {
30
- value = '';
31
- }
32
- return value;
33
- };
34
-
35
- export default ExpenseI18n;
package/index.js DELETED
@@ -1,144 +0,0 @@
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';
15
- import ExpenseI18n from './ExpenseI18n';
16
-
17
- export default SuggestAction = forwardRef((props, ref) => {
18
- const {
19
- icon,
20
- name,
21
- buttonTitle = 'Thêm ngay',
22
- onPressButton,
23
- onPressClose,
24
- iconTintColor,
25
- style,
26
- contentType = 'add',
27
- } = props;
28
-
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
-
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
- });
106
-
107
- 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
- },
144
- });