@momo-kits/foundation 0.109.1-optimize.6 → 0.109.1-optimize.7
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.
|
@@ -26,11 +26,7 @@ const HELP_CENTER_ICON = 'help_center';
|
|
|
26
26
|
*/
|
|
27
27
|
const HeaderRight: React.FC<any> = props => {
|
|
28
28
|
const {headerRight = {}} = props;
|
|
29
|
-
const {
|
|
30
|
-
useOnBoarding = false,
|
|
31
|
-
buttonOnBoarding,
|
|
32
|
-
onPressButtonOnBoarding,
|
|
33
|
-
} = headerRight;
|
|
29
|
+
const {useOnBoarding = false, buttonOnBoarding, onPress} = headerRight;
|
|
34
30
|
const context = useContext<any>(MiniAppContext);
|
|
35
31
|
const {translate} = useContext(ApplicationContext);
|
|
36
32
|
if (
|
|
@@ -44,11 +40,9 @@ const HeaderRight: React.FC<any> = props => {
|
|
|
44
40
|
return <View />;
|
|
45
41
|
}
|
|
46
42
|
|
|
47
|
-
if (useOnBoarding &&
|
|
43
|
+
if (useOnBoarding && onPress) {
|
|
48
44
|
return (
|
|
49
|
-
<TouchableOpacity
|
|
50
|
-
onPress={onPressButtonOnBoarding}
|
|
51
|
-
style={styles.onBoarding}>
|
|
45
|
+
<TouchableOpacity onPress={onPress} style={styles.onBoarding}>
|
|
52
46
|
<Text typography={'action_s_bold'}>
|
|
53
47
|
{buttonOnBoarding || translate?.('skip')}
|
|
54
48
|
</Text>
|
|
@@ -71,6 +71,25 @@ const TitleUser: React.FC<TitleUserProps> = ({
|
|
|
71
71
|
verify,
|
|
72
72
|
onPress,
|
|
73
73
|
}) => {
|
|
74
|
+
const {theme} = useContext(ApplicationContext);
|
|
75
|
+
const getShortName = (name: string) => {
|
|
76
|
+
const words = name.split(' ');
|
|
77
|
+
const lastTwoWords = words.slice(-2);
|
|
78
|
+
return lastTwoWords.map(word => word.charAt(0).toUpperCase()).join('');
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const renderImage = () => {
|
|
82
|
+
if (!!image) {
|
|
83
|
+
return <Image source={{uri: image}} style={styles.circle} />;
|
|
84
|
+
} else {
|
|
85
|
+
return (
|
|
86
|
+
<Text color={Colors.pink_03} typography={'description_xs_regular'}>
|
|
87
|
+
{getShortName(title)}
|
|
88
|
+
</Text>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
74
93
|
return (
|
|
75
94
|
<TouchableOpacity
|
|
76
95
|
style={styles.headerTitleContainer}
|
|
@@ -78,7 +97,13 @@ const TitleUser: React.FC<TitleUserProps> = ({
|
|
|
78
97
|
disabled={onPress === undefined}>
|
|
79
98
|
<View style={Styles.row}>
|
|
80
99
|
<View>
|
|
81
|
-
<
|
|
100
|
+
<View
|
|
101
|
+
style={[
|
|
102
|
+
styles.imageContainer,
|
|
103
|
+
{borderColor: theme.colors.border.default},
|
|
104
|
+
]}>
|
|
105
|
+
{renderImage()}
|
|
106
|
+
</View>
|
|
82
107
|
{!!dotColor && (
|
|
83
108
|
<View style={[styles.dotAvatar, {backgroundColor: dotColor}]} />
|
|
84
109
|
)}
|
|
@@ -236,14 +261,21 @@ const styles = StyleSheet.create({
|
|
|
236
261
|
headerTitleContainer: {
|
|
237
262
|
alignItems: 'center',
|
|
238
263
|
justifyContent: 'center',
|
|
239
|
-
width: Dimensions.get('window').width -
|
|
264
|
+
width: Dimensions.get('window').width - 158,
|
|
240
265
|
},
|
|
241
266
|
circle: {
|
|
242
267
|
width: 32,
|
|
243
268
|
height: 32,
|
|
269
|
+
},
|
|
270
|
+
imageContainer: {
|
|
271
|
+
width: 32,
|
|
272
|
+
height: 32,
|
|
244
273
|
borderRadius: 16,
|
|
274
|
+
backgroundColor: Colors.pink_09,
|
|
245
275
|
borderWidth: 0.5,
|
|
246
|
-
|
|
276
|
+
justifyContent: 'center',
|
|
277
|
+
alignItems: 'center',
|
|
278
|
+
overflow: 'hidden',
|
|
247
279
|
},
|
|
248
280
|
dotAvatar: {
|
|
249
281
|
position: 'absolute',
|
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
import {Radius, Spacing, Styles} from '../../Consts';
|
|
2
2
|
import {InputRef, InputSearch} from '../../Input';
|
|
3
|
-
import {
|
|
4
|
-
Animated,
|
|
5
|
-
Dimensions,
|
|
6
|
-
StyleSheet,
|
|
7
|
-
TouchableOpacity,
|
|
8
|
-
View,
|
|
9
|
-
} from 'react-native';
|
|
3
|
+
import {Animated, StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
10
4
|
import React, {useContext, useEffect, useRef} from 'react';
|
|
11
5
|
import {SearchHeaderProps} from '../types';
|
|
12
|
-
import {ApplicationContext} from '../index';
|
|
6
|
+
import {ApplicationContext, MiniAppContext} from '../index';
|
|
13
7
|
import {Text} from '../../Text';
|
|
14
8
|
|
|
15
9
|
const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
|
|
16
|
-
(
|
|
17
|
-
{
|
|
18
|
-
|
|
19
|
-
buttonText = 'Huỷ',
|
|
20
|
-
showButtonText = true,
|
|
21
|
-
onPressButtonText,
|
|
22
|
-
...props
|
|
23
|
-
},
|
|
24
|
-
ref
|
|
25
|
-
) => {
|
|
26
|
-
const {theme} = useContext(ApplicationContext);
|
|
27
|
-
const width = Dimensions.get('window').width;
|
|
10
|
+
({animatedValue, buttonText = 'Huỷ', onPressButtonText, ...props}, ref) => {
|
|
11
|
+
const {theme, navigator} = useContext(ApplicationContext);
|
|
12
|
+
const context = useContext<any>(MiniAppContext);
|
|
28
13
|
|
|
29
14
|
const animated = useRef(new Animated.Value(0));
|
|
30
15
|
|
|
@@ -48,8 +33,38 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
|
|
|
48
33
|
extrapolate: 'clamp',
|
|
49
34
|
});
|
|
50
35
|
|
|
36
|
+
const goBack = () => {
|
|
37
|
+
const canGoBack = navigator?.ref?.current?.canGoBack?.();
|
|
38
|
+
const currentRoute = navigator?.ref?.current?.getCurrentRoute?.();
|
|
39
|
+
const params = {
|
|
40
|
+
...context,
|
|
41
|
+
screen_name: currentRoute?.params?.screen?.name ?? currentRoute?.name,
|
|
42
|
+
trigger_id: '111154000000000000',
|
|
43
|
+
icon_name: 'back',
|
|
44
|
+
};
|
|
45
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
46
|
+
appId: `auto - ${context.appId}`,
|
|
47
|
+
message: 'service_icon_clicked',
|
|
48
|
+
params,
|
|
49
|
+
});
|
|
50
|
+
navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
|
|
51
|
+
if (canGoBack) {
|
|
52
|
+
navigator?.ref?.current?.goBack?.();
|
|
53
|
+
} else if (navigator?.maxApi) {
|
|
54
|
+
navigator?.maxApi?.dismiss?.(navigator?.dismissData);
|
|
55
|
+
} else {
|
|
56
|
+
(global as any)?.miniAppApi?.dispatch?.('dismiss', context);
|
|
57
|
+
}
|
|
58
|
+
onPressButtonText?.();
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const goBackSafe = () => {
|
|
62
|
+
goBack();
|
|
63
|
+
return true;
|
|
64
|
+
};
|
|
65
|
+
|
|
51
66
|
return (
|
|
52
|
-
<View style={
|
|
67
|
+
<View style={styles.container}>
|
|
53
68
|
<View style={Styles.flex}>
|
|
54
69
|
<Animated.View style={{backgroundColor, borderRadius: Radius.XL}}>
|
|
55
70
|
<InputSearch
|
|
@@ -60,13 +75,9 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
|
|
|
60
75
|
/>
|
|
61
76
|
</Animated.View>
|
|
62
77
|
</View>
|
|
63
|
-
{
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
style={styles.searchAction}>
|
|
67
|
-
<Text typography={'action_default_bold'}>{buttonText}</Text>
|
|
68
|
-
</TouchableOpacity>
|
|
69
|
-
)}
|
|
78
|
+
<TouchableOpacity onPress={goBackSafe} style={styles.searchAction}>
|
|
79
|
+
<Text typography={'action_default_bold'}>{buttonText}</Text>
|
|
80
|
+
</TouchableOpacity>
|
|
70
81
|
</View>
|
|
71
82
|
);
|
|
72
83
|
}
|
|
@@ -57,7 +57,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
57
57
|
*/
|
|
58
58
|
useEffect(() => {
|
|
59
59
|
if (['Invalid', 'screen'].includes(screenName)) {
|
|
60
|
-
navigator?.maxApi
|
|
60
|
+
navigator?.maxApi?.showPopup?.('notice', {
|
|
61
61
|
title: 'Invalid screen name',
|
|
62
62
|
message:
|
|
63
63
|
'Your screen has not been rendered because Platform has not detected the screen name. Please migrate to support this feature.',
|
package/Application/types.ts
CHANGED
package/Layout/Screen.tsx
CHANGED
|
@@ -342,6 +342,7 @@ const Screen = forwardRef(
|
|
|
342
342
|
const setSearchHeader = (params: SearchHeaderProps) => {
|
|
343
343
|
const options: StackNavigationOptions = {
|
|
344
344
|
headerRight: undefined,
|
|
345
|
+
headerLeft: () => {},
|
|
345
346
|
headerTitle: (props: any) => (
|
|
346
347
|
<SearchHeader
|
|
347
348
|
{...props}
|