@momo-kits/suggest-action 0.0.51-beta.3

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/ExpenseI18n.js ADDED
@@ -0,0 +1,35 @@
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 ADDED
@@ -0,0 +1,129 @@
1
+ import {
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';
14
+ import ExpenseI18n from './ExpenseI18n';
15
+
16
+ export default SuggestAction = ({
17
+ icon,
18
+ name,
19
+ buttonTitle = 'Thêm ngay',
20
+ onPressButton,
21
+ onPressClose,
22
+ iconTintColor,
23
+ visible = false,
24
+ style,
25
+ 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
+ };
46
+
47
+ const contentStart = getContent(contentType).start;
48
+ const contentEnd = getContent(contentType).end;
49
+
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
+ };
84
+
85
+ const styles = StyleSheet.create({
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
+ },
129
+ });
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@momo-kits/suggest-action",
3
+ "version": "0.0.51-beta.3",
4
+ "private": false,
5
+ "main": "index.js",
6
+ "dependencies": {
7
+ "@momo-platform/versions": "4.0.2"
8
+ },
9
+ "peerDependencies": {
10
+ "lodash": "^4.17.15",
11
+ "prop-types": "^15.7.2",
12
+ "react": "16.9.0",
13
+ "react-native": ">=0.55",
14
+ "@momo-kits/core": ">=0.0.5-beta"
15
+ },
16
+ "devDependencies": {},
17
+ "license": "MoMo"
18
+ }
package/publish.sh ADDED
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+ rm -rf dist
3
+ mkdir dist
4
+
5
+ cp . ./dist
6
+
7
+ # GET VERSION from mck_package.json
8
+ VERSIONSTRING=( v$(jq .version package.json) )
9
+ VERSION=(${VERSIONSTRING//[\"]/})
10
+ echo VERSION: $VERSION
11
+
12
+ rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type.js' --exclude 'prop-types.js' ./* dist
13
+
14
+ # #babel component to dist
15
+ #babel ./dist -d dist --copy-files
16
+
17
+ #copy option
18
+ #cp -r ./src/ dist
19
+
20
+
21
+ #npm login
22
+ #publish dist to npm
23
+ cd dist
24
+ npm publish --tag beta --access=public --tag beta
25
+ cd ..
26
+ rm -rf dist
27
+
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"}'