@momo-kits/suggest-action 0.80.8-beta.5 → 0.80.8-beta.8
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 +27 -34
- package/package.json +2 -2
- package/types.ts +12 -5
package/index.tsx
CHANGED
|
@@ -17,6 +17,24 @@ import {
|
|
|
17
17
|
} from '@momo-kits/foundation';
|
|
18
18
|
import styles from './styles';
|
|
19
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
|
+
|
|
20
38
|
const DURATION = 200;
|
|
21
39
|
|
|
22
40
|
const SuggestAction: ForwardRefRenderFunction<
|
|
@@ -26,11 +44,10 @@ const SuggestAction: ForwardRefRenderFunction<
|
|
|
26
44
|
{
|
|
27
45
|
image,
|
|
28
46
|
onPressButton = () => {},
|
|
47
|
+
name,
|
|
29
48
|
onClose,
|
|
49
|
+
type = 'addToFavorite',
|
|
30
50
|
bottom = 72,
|
|
31
|
-
message = 'Message',
|
|
32
|
-
buttonTitle = 'Button',
|
|
33
|
-
boldMessage,
|
|
34
51
|
},
|
|
35
52
|
ref,
|
|
36
53
|
) => {
|
|
@@ -65,34 +82,6 @@ const SuggestAction: ForwardRefRenderFunction<
|
|
|
65
82
|
hide();
|
|
66
83
|
};
|
|
67
84
|
|
|
68
|
-
const renderMessage = () => {
|
|
69
|
-
if (!!boldMessage) {
|
|
70
|
-
let splitMessage = [];
|
|
71
|
-
let index = message.toLowerCase().indexOf(boldMessage.toLowerCase());
|
|
72
|
-
if (index !== -1) {
|
|
73
|
-
splitMessage = [
|
|
74
|
-
message.substring(0, index),
|
|
75
|
-
boldMessage,
|
|
76
|
-
message.substring(index + boldMessage.length),
|
|
77
|
-
];
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<Text style={styles.content} typography={'paragraph_default'}>
|
|
81
|
-
{splitMessage[0]}
|
|
82
|
-
<Text typography={'action_s'}>{splitMessage[1]}</Text>
|
|
83
|
-
{splitMessage[2]}
|
|
84
|
-
</Text>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<Text style={styles.content} typography={'description_s'}>
|
|
91
|
-
{message}
|
|
92
|
-
</Text>
|
|
93
|
-
);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
85
|
return (
|
|
97
86
|
<Animated.View
|
|
98
87
|
style={[
|
|
@@ -104,11 +93,15 @@ const SuggestAction: ForwardRefRenderFunction<
|
|
|
104
93
|
},
|
|
105
94
|
Shadow.Light,
|
|
106
95
|
]}>
|
|
107
|
-
|
|
108
|
-
{
|
|
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>
|
|
109
102
|
<Button
|
|
110
103
|
type="tonal"
|
|
111
|
-
title={buttonTitle}
|
|
104
|
+
title={contents[type].buttonTitle}
|
|
112
105
|
onPress={handleButtonPress}
|
|
113
106
|
size={'small'}
|
|
114
107
|
full={false}
|
package/package.json
CHANGED
package/types.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export type SuggestActionProps = {
|
|
2
|
+
/**
|
|
3
|
+
* The name of the action to be displayed.
|
|
4
|
+
*/
|
|
5
|
+
name: string;
|
|
6
|
+
|
|
2
7
|
/**
|
|
3
8
|
* Optional. A callback function that is triggered when the action suggestion is closed.
|
|
4
9
|
*/
|
|
@@ -12,16 +17,18 @@ export type SuggestActionProps = {
|
|
|
12
17
|
/**
|
|
13
18
|
* The image associated with the action, typically displayed as part of the suggestion.
|
|
14
19
|
*/
|
|
15
|
-
image
|
|
20
|
+
image: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Optional. Specifies the type of the action, such as adding to favorites, adding to device, or sharing.
|
|
24
|
+
* Can be one of 'addToFavorite', 'addToDevice', or 'share'.
|
|
25
|
+
*/
|
|
26
|
+
type?: 'addToFavorite' | 'addToDevice' | 'share';
|
|
16
27
|
|
|
17
28
|
/**
|
|
18
29
|
* Optional. Specifies the bottom margin for the component. Useful for positioning or spacing within a layout.
|
|
19
30
|
*/
|
|
20
31
|
bottom?: number;
|
|
21
|
-
|
|
22
|
-
message: string;
|
|
23
|
-
buttonTitle: string;
|
|
24
|
-
boldMessage?: string;
|
|
25
32
|
};
|
|
26
33
|
|
|
27
34
|
/**
|