@momo-kits/foundation 0.110.2-beta.3 → 0.110.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/Application/BottomSheet.tsx +14 -44
- package/Application/Components/BottomSheetHelpCenter.tsx +3 -3
- package/Application/Components/HeaderAnimated.tsx +1 -2
- package/Application/Components/HeaderBackground.tsx +8 -15
- package/Application/Components/HeaderExtendHeader.tsx +20 -40
- package/Application/Components/HeaderLeft.tsx +11 -16
- package/Application/Components/HeaderRight.tsx +8 -17
- package/Application/Components/HeaderTitle.tsx +2 -3
- package/Application/ModalScreen.tsx +42 -48
- package/Application/NavigationContainer.tsx +4 -80
- package/Application/StackScreen.tsx +38 -24
- package/Application/types.ts +1 -5
- package/Application/utils.tsx +24 -2
- package/Button/index.tsx +2 -0
- package/Input/Input.tsx +2 -0
- package/Input/InputDropDown.tsx +2 -0
- package/Input/InputMoney.tsx +2 -0
- package/Input/InputOTP.tsx +2 -0
- package/Input/InputSearch.tsx +2 -0
- package/Input/InputTextArea.tsx +0 -1
- package/Input/styles.ts +0 -1
- package/Popup/PopupNotify.tsx +3 -13
- package/Popup/PopupPromotion.tsx +2 -8
- package/Text/index.tsx +4 -10
- package/Title/index.tsx +4 -18
- package/Title/types.ts +0 -6
- package/package.json +4 -4
- package/publish.sh +1 -0
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {useRef, useEffect, useCallback, useContext} from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Animated,
|
|
4
4
|
Dimensions,
|
|
5
|
-
Easing,
|
|
6
5
|
KeyboardAvoidingView,
|
|
7
|
-
Modal,
|
|
8
6
|
PanResponder,
|
|
9
7
|
Platform,
|
|
10
|
-
Pressable,
|
|
11
8
|
StyleSheet,
|
|
12
9
|
TouchableOpacity,
|
|
13
10
|
View,
|
|
11
|
+
Modal,
|
|
14
12
|
} from 'react-native';
|
|
15
13
|
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
16
14
|
import {ApplicationContext} from './index';
|
|
@@ -32,10 +30,8 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
32
30
|
barrierDismissible = false,
|
|
33
31
|
draggable = true,
|
|
34
32
|
useBottomInset = true,
|
|
35
|
-
useKeyboardAvoidingView = true,
|
|
36
33
|
keyboardVerticalOffset,
|
|
37
34
|
}: BottomSheetParams = props.route.params;
|
|
38
|
-
|
|
39
35
|
const pan = useRef(
|
|
40
36
|
new Animated.ValueXY({
|
|
41
37
|
y: heightDevice,
|
|
@@ -43,9 +39,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
43
39
|
})
|
|
44
40
|
).current;
|
|
45
41
|
|
|
46
|
-
const customEasingOpen = Easing.bezier(0.05, 0.7, 0.1, 1);
|
|
47
|
-
const customEasingClose = Easing.bezier(0.3, 0.0, 0.8, 0.15);
|
|
48
|
-
|
|
49
42
|
const panResponder = useRef(
|
|
50
43
|
PanResponder.create({
|
|
51
44
|
onStartShouldSetPanResponder: () => draggable,
|
|
@@ -72,7 +65,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
72
65
|
},
|
|
73
66
|
})
|
|
74
67
|
).current;
|
|
75
|
-
|
|
76
68
|
let Container: any = View;
|
|
77
69
|
if (useNativeModal) {
|
|
78
70
|
Container = Modal;
|
|
@@ -89,10 +81,8 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
89
81
|
Animated.timing(pan, {
|
|
90
82
|
toValue: {x: 0, y: 0},
|
|
91
83
|
useNativeDriver: false,
|
|
92
|
-
|
|
93
|
-
duration: 500,
|
|
84
|
+
duration: 150,
|
|
94
85
|
}).start();
|
|
95
|
-
|
|
96
86
|
return () => {
|
|
97
87
|
props.route.params?.onDismiss?.(action.current);
|
|
98
88
|
};
|
|
@@ -111,8 +101,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
111
101
|
Animated.timing(pan, {
|
|
112
102
|
toValue: {x: 0, y: heightDevice},
|
|
113
103
|
useNativeDriver: false,
|
|
114
|
-
|
|
115
|
-
duration: 300,
|
|
104
|
+
duration: 200,
|
|
116
105
|
}).start(() => {
|
|
117
106
|
navigator?.pop();
|
|
118
107
|
});
|
|
@@ -181,39 +170,20 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
181
170
|
onRequestClose={() => {
|
|
182
171
|
onDismiss();
|
|
183
172
|
}}
|
|
184
|
-
style={
|
|
173
|
+
style={styles.overlay}>
|
|
185
174
|
<KeyboardAvoidingView
|
|
186
|
-
behavior={Platform.
|
|
187
|
-
ios: 'padding',
|
|
188
|
-
android: undefined,
|
|
189
|
-
})}
|
|
175
|
+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
190
176
|
keyboardVerticalOffset={keyboardVerticalOffset ?? -20}
|
|
191
|
-
enabled={useKeyboardAvoidingView}
|
|
192
177
|
style={[Styles.flex, {justifyContent: 'flex-end'}]}>
|
|
193
|
-
<
|
|
194
|
-
style={
|
|
178
|
+
<TouchableOpacity
|
|
179
|
+
style={Styles.flex}
|
|
180
|
+
activeOpacity={1}
|
|
195
181
|
onPress={() => {
|
|
196
182
|
action.current = 'touch';
|
|
197
183
|
onDismiss();
|
|
198
|
-
}}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
styles.overlay,
|
|
202
|
-
{
|
|
203
|
-
opacity: pan.y.interpolate({
|
|
204
|
-
inputRange: [0, heightDevice],
|
|
205
|
-
outputRange: [1, 0],
|
|
206
|
-
extrapolate: 'clamp',
|
|
207
|
-
}),
|
|
208
|
-
},
|
|
209
|
-
]}
|
|
210
|
-
/>
|
|
211
|
-
</Pressable>
|
|
212
|
-
|
|
213
|
-
<Animated.View
|
|
214
|
-
style={{
|
|
215
|
-
transform: pan.getTranslateTransform(),
|
|
216
|
-
}}>
|
|
184
|
+
}}
|
|
185
|
+
/>
|
|
186
|
+
<Animated.View style={{transform: pan.getTranslateTransform()}}>
|
|
217
187
|
{renderHeader()}
|
|
218
188
|
<View style={{backgroundColor: backgroundColor}}>
|
|
219
189
|
<Screen
|
|
@@ -233,8 +203,8 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
233
203
|
|
|
234
204
|
const styles = StyleSheet.create({
|
|
235
205
|
overlay: {
|
|
236
|
-
|
|
237
|
-
|
|
206
|
+
...StyleSheet.absoluteFillObject,
|
|
207
|
+
justifyContent: 'flex-end',
|
|
238
208
|
},
|
|
239
209
|
indicator: {
|
|
240
210
|
width: 40,
|
|
@@ -46,7 +46,7 @@ const BottomSheetHelpCenter: React.FC<any> = ({onRequestClose}) => {
|
|
|
46
46
|
context?.autoTracking?.({
|
|
47
47
|
...context,
|
|
48
48
|
componentName: 'TouchableOpacity',
|
|
49
|
-
componentId: '
|
|
49
|
+
componentId: 'navigation_faq_item',
|
|
50
50
|
screenName: screenName,
|
|
51
51
|
});
|
|
52
52
|
|
|
@@ -69,7 +69,7 @@ const BottomSheetHelpCenter: React.FC<any> = ({onRequestClose}) => {
|
|
|
69
69
|
context?.autoTracking?.({
|
|
70
70
|
...context,
|
|
71
71
|
componentName: 'TouchableOpacity',
|
|
72
|
-
componentId: '
|
|
72
|
+
componentId: 'navigation_chatbot_item',
|
|
73
73
|
screenName: screenName,
|
|
74
74
|
});
|
|
75
75
|
|
|
@@ -100,7 +100,7 @@ const BottomSheetHelpCenter: React.FC<any> = ({onRequestClose}) => {
|
|
|
100
100
|
context?.autoTracking?.({
|
|
101
101
|
...context,
|
|
102
102
|
componentName: 'TouchableOpacity',
|
|
103
|
-
componentId: '
|
|
103
|
+
componentId: 'navigation_feedback_item',
|
|
104
104
|
screenName: screenName,
|
|
105
105
|
});
|
|
106
106
|
|
|
@@ -16,12 +16,12 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
|
16
16
|
animatedValue = new Animated.Value(0),
|
|
17
17
|
useGradient = true,
|
|
18
18
|
useShadowHeader = true,
|
|
19
|
-
gradientColor
|
|
19
|
+
gradientColor,
|
|
20
20
|
headerBackground,
|
|
21
21
|
}) => {
|
|
22
22
|
const {theme} = useContext(ApplicationContext);
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const linearGradientColor = gradientColor ?? theme.colors.gradient;
|
|
25
25
|
|
|
26
26
|
let headerImage = headerBackground ?? theme.assets?.headerBackground;
|
|
27
27
|
if (image === null) {
|
|
@@ -48,21 +48,13 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
|
48
48
|
{
|
|
49
49
|
backgroundColor: theme.colors.background.surface,
|
|
50
50
|
opacity: opacityBackground,
|
|
51
|
-
overflow: 'hidden',
|
|
52
51
|
},
|
|
53
|
-
]}
|
|
54
|
-
|
|
55
|
-
<Image
|
|
56
|
-
style={styles.headerBackground}
|
|
57
|
-
source={{uri: theme?.assets?.headerBackground}}
|
|
58
|
-
loading={false}
|
|
59
|
-
/>
|
|
60
|
-
)}
|
|
61
|
-
</Animated.View>
|
|
52
|
+
]}
|
|
53
|
+
/>
|
|
62
54
|
<View style={styles.gradientContainer}>
|
|
63
|
-
{useGradient &&
|
|
55
|
+
{useGradient && (
|
|
64
56
|
<LinearGradientAnimated
|
|
65
|
-
colors={[
|
|
57
|
+
colors={[linearGradientColor, linearGradientColor + '00']}
|
|
66
58
|
style={[styles.extendedHeader, {opacity: opacityGradient}]}>
|
|
67
59
|
{!!headerImage && (
|
|
68
60
|
<Image
|
|
@@ -115,8 +107,9 @@ const styles = StyleSheet.create({
|
|
|
115
107
|
},
|
|
116
108
|
headerBackground: {
|
|
117
109
|
width: '100%',
|
|
110
|
+
height: undefined,
|
|
118
111
|
position: 'absolute',
|
|
119
|
-
aspectRatio: 375 /
|
|
112
|
+
aspectRatio: 375 / 154,
|
|
120
113
|
},
|
|
121
114
|
dividerHeader: {
|
|
122
115
|
borderBottomWidth: 1,
|
|
@@ -105,36 +105,26 @@ const HeaderExtendHeader: React.FC<{
|
|
|
105
105
|
width: '100%',
|
|
106
106
|
height: heightHeader,
|
|
107
107
|
zIndex: 1,
|
|
108
|
-
overflow: 'hidden',
|
|
109
108
|
},
|
|
110
|
-
]}
|
|
111
|
-
|
|
112
|
-
<Image
|
|
113
|
-
style={styles.headerBackground}
|
|
114
|
-
source={{uri: headerBackground}}
|
|
115
|
-
loading={false}
|
|
116
|
-
/>
|
|
117
|
-
)}
|
|
118
|
-
</Animated.View>
|
|
109
|
+
]}
|
|
110
|
+
/>
|
|
119
111
|
|
|
120
112
|
<Animated.View
|
|
121
113
|
style={[
|
|
122
114
|
styles.headerBox,
|
|
123
115
|
{height: headerType === 'extended' ? height : heightHeader},
|
|
124
116
|
]}>
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
</LinearGradientAnimated>
|
|
137
|
-
)}
|
|
117
|
+
<LinearGradientAnimated
|
|
118
|
+
colors={[gradientColor, gradientColor + '00']}
|
|
119
|
+
style={[styles.extendedHeader, {opacity: opacityGradient}]}>
|
|
120
|
+
{!!theme.assets?.headerBackground && (
|
|
121
|
+
<Image
|
|
122
|
+
style={styles.headerBackground}
|
|
123
|
+
source={{uri: theme.assets?.headerBackground}}
|
|
124
|
+
loading={false}
|
|
125
|
+
/>
|
|
126
|
+
)}
|
|
127
|
+
</LinearGradientAnimated>
|
|
138
128
|
</Animated.View>
|
|
139
129
|
|
|
140
130
|
<Animated.View
|
|
@@ -185,30 +175,20 @@ const HeaderExtendHeader: React.FC<{
|
|
|
185
175
|
height: heightHeader,
|
|
186
176
|
backgroundColor: theme.colors.background.surface,
|
|
187
177
|
opacity: opacityBackground,
|
|
188
|
-
overflow: 'hidden',
|
|
189
178
|
},
|
|
190
|
-
]}
|
|
191
|
-
|
|
179
|
+
]}
|
|
180
|
+
/>
|
|
181
|
+
<LinearGradientAnimated
|
|
182
|
+
colors={[gradientColor, gradientColor + '00']}
|
|
183
|
+
style={[styles.extendedHeader, {opacity: opacityGradient}]}>
|
|
184
|
+
{!!headerBackground && (
|
|
192
185
|
<Image
|
|
193
186
|
style={styles.headerBackground}
|
|
194
187
|
source={{uri: headerBackground}}
|
|
195
188
|
loading={false}
|
|
196
189
|
/>
|
|
197
190
|
)}
|
|
198
|
-
</
|
|
199
|
-
{!!gradientColor && (
|
|
200
|
-
<LinearGradientAnimated
|
|
201
|
-
colors={[gradientColor, gradientColor + '00']}
|
|
202
|
-
style={[styles.extendedHeader, {opacity: opacityGradient}]}>
|
|
203
|
-
{!!headerBackground && (
|
|
204
|
-
<Image
|
|
205
|
-
style={styles.headerBackground}
|
|
206
|
-
source={{uri: headerBackground}}
|
|
207
|
-
loading={false}
|
|
208
|
-
/>
|
|
209
|
-
)}
|
|
210
|
-
</LinearGradientAnimated>
|
|
211
|
-
)}
|
|
191
|
+
</LinearGradientAnimated>
|
|
212
192
|
<View style={{height: heightHeader}} />
|
|
213
193
|
<Verified />
|
|
214
194
|
</>
|
|
@@ -12,11 +12,19 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
12
12
|
tintColor,
|
|
13
13
|
preventBack,
|
|
14
14
|
onPressLeftHeader,
|
|
15
|
-
onBackHandler,
|
|
16
15
|
}) => {
|
|
17
16
|
const context = useContext<any>(MiniAppContext);
|
|
18
17
|
const {navigator} = useContext(ApplicationContext);
|
|
19
18
|
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const backHandler = BackHandler.addEventListener(
|
|
21
|
+
'hardwareBackPress',
|
|
22
|
+
goBackSafe
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return () => backHandler.remove();
|
|
26
|
+
}, []);
|
|
27
|
+
|
|
20
28
|
const goBackSafe = () => {
|
|
21
29
|
const goBack = () => {
|
|
22
30
|
const canGoBack = navigator?.ref?.current?.canGoBack?.();
|
|
@@ -35,6 +43,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
35
43
|
} else {
|
|
36
44
|
(global as any)?.miniAppApi?.dispatch?.('dismiss', context);
|
|
37
45
|
}
|
|
46
|
+
onPressLeftHeader?.();
|
|
38
47
|
};
|
|
39
48
|
|
|
40
49
|
if (preventBack) {
|
|
@@ -53,25 +62,11 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
53
62
|
),
|
|
54
63
|
});
|
|
55
64
|
} else {
|
|
56
|
-
|
|
57
|
-
if (typeof onBackHandler === 'function') {
|
|
58
|
-
onBackHandler(goBack);
|
|
59
|
-
} else {
|
|
60
|
-
goBack();
|
|
61
|
-
}
|
|
65
|
+
goBack();
|
|
62
66
|
}
|
|
63
67
|
return true;
|
|
64
68
|
};
|
|
65
69
|
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
const backHandler = BackHandler.addEventListener(
|
|
68
|
-
'hardwareBackPress',
|
|
69
|
-
goBackSafe
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
return () => backHandler.remove();
|
|
73
|
-
}, [goBackSafe]);
|
|
74
|
-
|
|
75
70
|
return (
|
|
76
71
|
<View style={styles.headerLeft}>
|
|
77
72
|
<NavigationButton
|
|
@@ -15,7 +15,6 @@ import {scaleSize, Text} from '../../Text';
|
|
|
15
15
|
import {BottomSheetHelpCenter} from './BottomSheetHelpCenter';
|
|
16
16
|
import {Image} from '../../Image';
|
|
17
17
|
|
|
18
|
-
const DID_SYNC_NEW_HOME = 'did_sync_new_home';
|
|
19
18
|
/**
|
|
20
19
|
* main component for header right
|
|
21
20
|
*/
|
|
@@ -65,19 +64,8 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
65
64
|
useEffect(() => {
|
|
66
65
|
if (useShortcut) {
|
|
67
66
|
checkAppIsFavorite();
|
|
68
|
-
|
|
69
|
-
const favoriteObserver = navigator?.maxApi?.observer?.(
|
|
70
|
-
DID_SYNC_NEW_HOME,
|
|
71
|
-
(updatedData: any) => {
|
|
72
|
-
const status = updatedData?.items?.includes(context?.code);
|
|
73
|
-
setIsFavorite(status);
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
return () => {
|
|
77
|
-
favoriteObserver?.remove?.();
|
|
78
|
-
};
|
|
79
67
|
}
|
|
80
|
-
}, [useShortcut,
|
|
68
|
+
}, [useShortcut, useMore, tools]);
|
|
81
69
|
|
|
82
70
|
let buttonStyle: ViewStyle = {};
|
|
83
71
|
if (tintColor === Colors.black_01 || tintColor === 'white') {
|
|
@@ -90,14 +78,17 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
90
78
|
/**
|
|
91
79
|
* check app is favorite
|
|
92
80
|
*/
|
|
93
|
-
const checkAppIsFavorite = () =>
|
|
81
|
+
const checkAppIsFavorite = () => {
|
|
94
82
|
navigator?.maxApi?.dispatchFunction?.(
|
|
95
83
|
'isFavoriteApp',
|
|
96
|
-
context?.
|
|
84
|
+
context?.app_code,
|
|
97
85
|
(result: boolean) => {
|
|
98
|
-
|
|
86
|
+
if (result !== isFavorite) {
|
|
87
|
+
setIsFavorite(result);
|
|
88
|
+
}
|
|
99
89
|
}
|
|
100
90
|
);
|
|
91
|
+
};
|
|
101
92
|
|
|
102
93
|
/**
|
|
103
94
|
* close navigation container
|
|
@@ -107,7 +98,7 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
107
98
|
context?.autoTracking?.({
|
|
108
99
|
...context,
|
|
109
100
|
componentName: 'IconButton',
|
|
110
|
-
componentId: '
|
|
101
|
+
componentId: 'navigation_more',
|
|
111
102
|
screenName: currentRoute?.params?.screen?.name ?? currentRoute?.name,
|
|
112
103
|
});
|
|
113
104
|
|
|
@@ -79,7 +79,6 @@ const TitleUser: React.FC<TitleUserProps> = ({
|
|
|
79
79
|
isLoading,
|
|
80
80
|
}) => {
|
|
81
81
|
const {theme} = useContext(ApplicationContext);
|
|
82
|
-
const maxWidth = icons?.length === 2 ? '73%' : '100%';
|
|
83
82
|
const getShortName = (name: string) => {
|
|
84
83
|
const words = name.split(' ');
|
|
85
84
|
const lastTwoWords = words.slice(-2);
|
|
@@ -228,7 +227,7 @@ const TitleUser: React.FC<TitleUserProps> = ({
|
|
|
228
227
|
}
|
|
229
228
|
}
|
|
230
229
|
|
|
231
|
-
if (typeof image === 'string'
|
|
230
|
+
if (typeof image === 'string') {
|
|
232
231
|
return <Image source={{uri: image}} style={styles.circle} />;
|
|
233
232
|
}
|
|
234
233
|
|
|
@@ -307,7 +306,7 @@ const TitleUser: React.FC<TitleUserProps> = ({
|
|
|
307
306
|
<View style={[styles.dotAvatar, {backgroundColor: dotColor}]} />
|
|
308
307
|
)}
|
|
309
308
|
</View>
|
|
310
|
-
<View style={[Styles.flex, {marginLeft: 6
|
|
309
|
+
<View style={[Styles.flex, {marginLeft: 6}]}>
|
|
311
310
|
<View style={Styles.row}>
|
|
312
311
|
<Text
|
|
313
312
|
typography="action_xs_bold"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, {useContext, useEffect, useRef} from 'react';
|
|
2
2
|
import {
|
|
3
|
-
Animated,
|
|
4
3
|
KeyboardAvoidingView,
|
|
5
4
|
Platform,
|
|
6
5
|
Pressable,
|
|
7
6
|
StyleSheet,
|
|
7
|
+
View,
|
|
8
8
|
} from 'react-native';
|
|
9
9
|
|
|
10
10
|
import {ApplicationContext} from './index';
|
|
@@ -22,11 +22,8 @@ const ModalScreen: React.FC<any> = props => {
|
|
|
22
22
|
|
|
23
23
|
const Modal: React.FC<ModalParams> = props => {
|
|
24
24
|
const {navigator} = useContext(ApplicationContext);
|
|
25
|
-
const {screen, barrierDismissible
|
|
25
|
+
const {screen, barrierDismissible} = props.route.params;
|
|
26
26
|
const Component = useRef(screen).current;
|
|
27
|
-
const opacity = useRef(new Animated.Value(0)).current;
|
|
28
|
-
const scale = useRef(new Animated.Value(0.8)).current;
|
|
29
|
-
|
|
30
27
|
const navigation = new Navigation(props.navigation);
|
|
31
28
|
const params = {
|
|
32
29
|
...props.route.params,
|
|
@@ -35,68 +32,65 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
35
32
|
delete params.screen;
|
|
36
33
|
|
|
37
34
|
useEffect(() => {
|
|
38
|
-
Animated.parallel([
|
|
39
|
-
Animated.timing(opacity, {
|
|
40
|
-
toValue: 1,
|
|
41
|
-
duration: 400,
|
|
42
|
-
useNativeDriver: true,
|
|
43
|
-
}),
|
|
44
|
-
Animated.spring(scale, {
|
|
45
|
-
toValue: 1,
|
|
46
|
-
useNativeDriver: true,
|
|
47
|
-
}),
|
|
48
|
-
]).start();
|
|
49
|
-
|
|
50
35
|
return () => {
|
|
51
36
|
props.route.params?.onDismiss?.();
|
|
52
37
|
};
|
|
53
|
-
}, [
|
|
38
|
+
}, []);
|
|
54
39
|
|
|
55
40
|
const onDismiss = () => {
|
|
56
41
|
if (barrierDismissible) {
|
|
57
42
|
return;
|
|
58
43
|
}
|
|
59
|
-
|
|
60
|
-
Animated.timing(opacity, {
|
|
61
|
-
toValue: 0,
|
|
62
|
-
duration: 250,
|
|
63
|
-
useNativeDriver: true,
|
|
64
|
-
}),
|
|
65
|
-
Animated.timing(scale, {
|
|
66
|
-
toValue: 0.8,
|
|
67
|
-
duration: 250,
|
|
68
|
-
useNativeDriver: true,
|
|
69
|
-
}),
|
|
70
|
-
]).start(() => {
|
|
71
|
-
navigator?.pop();
|
|
72
|
-
});
|
|
44
|
+
navigator?.pop();
|
|
73
45
|
};
|
|
74
46
|
|
|
75
47
|
return (
|
|
76
48
|
<KeyboardAvoidingView
|
|
77
|
-
style={Styles.
|
|
49
|
+
style={Styles.flex}
|
|
78
50
|
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}>
|
|
79
|
-
<
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
51
|
+
<View style={styles.container}>
|
|
52
|
+
<Pressable
|
|
53
|
+
style={styles.modalSpaceHorizontal}
|
|
54
|
+
onPress={() => onDismiss()}
|
|
55
|
+
/>
|
|
56
|
+
<View style={styles.modalCenterStage}>
|
|
57
|
+
<Pressable
|
|
58
|
+
style={styles.modalSpaceVertical}
|
|
59
|
+
onPress={() => onDismiss()}
|
|
60
|
+
/>
|
|
61
|
+
<View style={styles.modalContent}>
|
|
62
|
+
<Component {...params} />
|
|
63
|
+
</View>
|
|
64
|
+
<Pressable
|
|
65
|
+
style={styles.modalSpaceVertical}
|
|
66
|
+
onPress={() => onDismiss()}
|
|
67
|
+
/>
|
|
68
|
+
</View>
|
|
69
|
+
<Pressable
|
|
70
|
+
style={styles.modalSpaceHorizontal}
|
|
71
|
+
onPress={() => onDismiss()}
|
|
72
|
+
/>
|
|
73
|
+
</View>
|
|
92
74
|
</KeyboardAvoidingView>
|
|
93
75
|
);
|
|
94
76
|
};
|
|
95
77
|
|
|
96
78
|
const styles = StyleSheet.create({
|
|
97
|
-
|
|
79
|
+
container: {flex: 1, flexDirection: 'row'},
|
|
80
|
+
modalContent: {
|
|
81
|
+
maxWidth: '100%',
|
|
82
|
+
maxHeight: '80%',
|
|
83
|
+
},
|
|
84
|
+
modalCenterStage: {
|
|
85
|
+
maxWidth: '90%',
|
|
86
|
+
},
|
|
87
|
+
modalSpaceHorizontal: {
|
|
88
|
+
flex: 1,
|
|
89
|
+
minWidth: '5%',
|
|
90
|
+
},
|
|
91
|
+
modalSpaceVertical: {
|
|
98
92
|
flex: 1,
|
|
99
|
-
|
|
93
|
+
minHeight: '10%',
|
|
100
94
|
},
|
|
101
95
|
});
|
|
102
96
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {useEffect, useRef, useState} from 'react';
|
|
2
2
|
import {SafeAreaProvider} from 'react-native-safe-area-context';
|
|
3
3
|
import {
|
|
4
4
|
NavigationContainer as ReactNavigationContainer,
|
|
@@ -8,13 +8,13 @@ import {
|
|
|
8
8
|
createStackNavigator,
|
|
9
9
|
StackNavigationOptions,
|
|
10
10
|
} from '@react-navigation/stack';
|
|
11
|
-
import {DeviceEventEmitter
|
|
11
|
+
import {DeviceEventEmitter} from 'react-native';
|
|
12
12
|
import StackScreen from './StackScreen';
|
|
13
13
|
import ModalScreen from './ModalScreen';
|
|
14
14
|
import Navigator from './Navigator';
|
|
15
15
|
import {getDialogOptions, getModalOptions, getStackOptions} from './utils';
|
|
16
16
|
import {NavigationContainerProps} from './types';
|
|
17
|
-
import {ApplicationContext
|
|
17
|
+
import {ApplicationContext} from './index';
|
|
18
18
|
import Localize from './Localize';
|
|
19
19
|
import {defaultTheme} from '../Consts';
|
|
20
20
|
|
|
@@ -28,22 +28,11 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
28
28
|
initialParams,
|
|
29
29
|
localize = new Localize({vi: {}, en: {}}),
|
|
30
30
|
}) => {
|
|
31
|
-
const context = useContext<any>(MiniAppContext);
|
|
32
31
|
const navigationRef = useRef<NavigationContainerRef>(null);
|
|
33
|
-
const routes = useRef<any>();
|
|
34
32
|
const isReady = useRef(false);
|
|
35
33
|
const navigator = useRef(new Navigator(navigationRef, isReady));
|
|
36
34
|
const [showGrid, setShowGrid] = useState(false);
|
|
37
35
|
|
|
38
|
-
let config: any = null;
|
|
39
|
-
try {
|
|
40
|
-
config = JSON.parse(
|
|
41
|
-
NativeModules?.ConfigsModule?.getConfigSync?.('DESIGN_SYSTEM') || ''
|
|
42
|
-
);
|
|
43
|
-
} catch (e) {
|
|
44
|
-
console.log(e);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
36
|
/**
|
|
48
37
|
* inject data for navigator
|
|
49
38
|
*/
|
|
@@ -73,56 +62,12 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
73
62
|
return localize?.translate(data as string);
|
|
74
63
|
};
|
|
75
64
|
|
|
76
|
-
/**
|
|
77
|
-
* navigation state route change handle
|
|
78
|
-
* @param preScreenName
|
|
79
|
-
* @param screenName
|
|
80
|
-
* @param action
|
|
81
|
-
*/
|
|
82
|
-
const onScreenNavigated = (
|
|
83
|
-
preScreenName: string,
|
|
84
|
-
screenName: string,
|
|
85
|
-
action: string
|
|
86
|
-
) => {
|
|
87
|
-
console.log(preScreenName, screenName, action);
|
|
88
|
-
context?.autoTracking?.({
|
|
89
|
-
...context,
|
|
90
|
-
preScreenName,
|
|
91
|
-
screenName,
|
|
92
|
-
componentName: 'Screen',
|
|
93
|
-
state: 'navigated',
|
|
94
|
-
action,
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* debug toast
|
|
99
|
-
*/
|
|
100
|
-
maxApi?.showToastDebug?.({
|
|
101
|
-
appId: context.appId,
|
|
102
|
-
message: `${screenName} screen_navigated`,
|
|
103
|
-
type: 'ERROR',
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const headerBackground = config?.headerBar || theme.assets?.headerBackground;
|
|
108
|
-
const headerGradient = config?.headerGradient || theme.colors?.gradient;
|
|
109
|
-
|
|
110
65
|
return (
|
|
111
66
|
<SafeAreaProvider>
|
|
112
67
|
<ApplicationContext.Provider
|
|
113
68
|
value={{
|
|
114
69
|
navigator: navigator.current,
|
|
115
|
-
theme
|
|
116
|
-
...theme,
|
|
117
|
-
colors: {
|
|
118
|
-
...theme.colors,
|
|
119
|
-
gradient: headerGradient,
|
|
120
|
-
},
|
|
121
|
-
assets: {
|
|
122
|
-
...theme.assets,
|
|
123
|
-
headerBackground,
|
|
124
|
-
},
|
|
125
|
-
},
|
|
70
|
+
theme,
|
|
126
71
|
showGrid,
|
|
127
72
|
translate,
|
|
128
73
|
}}>
|
|
@@ -141,27 +86,6 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
141
86
|
ref={navigationRef}
|
|
142
87
|
onReady={() => {
|
|
143
88
|
isReady.current = true;
|
|
144
|
-
routes.current = navigationRef.current?.getRootState?.()?.routes;
|
|
145
|
-
maxApi?.getDataObserver('CURRENT_SCREEN', (data: any) => {
|
|
146
|
-
onScreenNavigated(data?.screenName, screen?.name, 'push');
|
|
147
|
-
maxApi?.setObserver('CURRENT_SCREEN', {screenName: screen?.name});
|
|
148
|
-
});
|
|
149
|
-
}}
|
|
150
|
-
onStateChange={state => {
|
|
151
|
-
const lastedRoute: any = state?.routes?.[state?.routes?.length - 1];
|
|
152
|
-
const oldRoute: any = routes.current?.[routes.current?.length - 1];
|
|
153
|
-
const lasted = lastedRoute?.params?.screen;
|
|
154
|
-
const previous = oldRoute?.params?.screen;
|
|
155
|
-
const preScreenName = previous?.name ?? previous?.type?.name;
|
|
156
|
-
const screenName = lasted?.name ?? lasted?.type?.name;
|
|
157
|
-
|
|
158
|
-
let action = 'push';
|
|
159
|
-
if (routes.current?.length > (state?.routes?.length ?? 0)) {
|
|
160
|
-
action = 'back';
|
|
161
|
-
}
|
|
162
|
-
onScreenNavigated(preScreenName, screenName, action);
|
|
163
|
-
maxApi?.setObserver('CURRENT_SCREEN', {screenName});
|
|
164
|
-
routes.current = state?.routes;
|
|
165
89
|
}}
|
|
166
90
|
independent={true}>
|
|
167
91
|
<Stack.Navigator initialRouteName="Stack" headerMode="screen">
|
|
@@ -6,8 +6,6 @@ import Navigation from './Navigation';
|
|
|
6
6
|
import {ApplicationContext, MiniAppContext, ScreenContext} from './index';
|
|
7
7
|
import {GridSystem} from '../Layout';
|
|
8
8
|
|
|
9
|
-
const runAfterInteractions = InteractionManager.runAfterInteractions;
|
|
10
|
-
|
|
11
9
|
/**
|
|
12
10
|
* container for stack screen
|
|
13
11
|
* @param props
|
|
@@ -44,6 +42,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
44
42
|
delete data.initialParams;
|
|
45
43
|
|
|
46
44
|
const screenName = Component?.name || Component?.type?.name || 'Invalid';
|
|
45
|
+
const routes = props.navigation.getState()?.routes || [];
|
|
47
46
|
|
|
48
47
|
/**
|
|
49
48
|
* set options for screen
|
|
@@ -68,7 +67,15 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
68
67
|
|
|
69
68
|
const subscription = props.navigation?.addListener?.('focus', () => {
|
|
70
69
|
navigator?.maxApi?.of?.({screenName});
|
|
71
|
-
navigator?.maxApi?.
|
|
70
|
+
navigator?.maxApi?.getDataObserver('CURRENT_SCREEN', (data: any) => {
|
|
71
|
+
let preScreenName = data?.screenName;
|
|
72
|
+
if (routes?.length > 1) {
|
|
73
|
+
const screen = routes?.[routes?.length - 2]?.params?.screen;
|
|
74
|
+
preScreenName = screen?.name || screen?.type?.name || 'Invalid';
|
|
75
|
+
}
|
|
76
|
+
onScreenNavigated(preScreenName);
|
|
77
|
+
navigator?.maxApi?.setObserver('CURRENT_SCREEN', {screenName});
|
|
78
|
+
});
|
|
72
79
|
});
|
|
73
80
|
navigator?.maxApi?.startTraceScreenLoad?.(
|
|
74
81
|
screenName,
|
|
@@ -181,39 +188,46 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
181
188
|
}
|
|
182
189
|
};
|
|
183
190
|
|
|
191
|
+
/**
|
|
192
|
+
* tracking for screen navigated
|
|
193
|
+
*/
|
|
194
|
+
const onScreenNavigated = (preScreenName: string) => {
|
|
195
|
+
context?.autoTracking?.({
|
|
196
|
+
...context,
|
|
197
|
+
preScreenName,
|
|
198
|
+
screenName,
|
|
199
|
+
componentName: 'Screen',
|
|
200
|
+
state: 'navigated',
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* debug toast
|
|
205
|
+
*/
|
|
206
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
207
|
+
appId: context.appId,
|
|
208
|
+
message: `${screenName} screen_navigated`,
|
|
209
|
+
type: 'ERROR',
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
|
|
184
213
|
return (
|
|
185
214
|
<ScreenContext.Provider
|
|
186
215
|
value={{
|
|
187
216
|
screenName,
|
|
188
217
|
onElementLoad: (data: any) => {
|
|
189
|
-
/**
|
|
190
|
-
* tracking for element screen load
|
|
191
|
-
*/
|
|
192
218
|
clearTimeout(tracking.current.timeoutLoad);
|
|
193
219
|
tracking.current.endTime = Date.now();
|
|
194
220
|
tracking.current.timeoutInteraction?.cancel?.();
|
|
195
|
-
tracking.current.timeoutInteraction =
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
* support for debug last element
|
|
202
|
-
*/
|
|
221
|
+
tracking.current.timeoutInteraction =
|
|
222
|
+
InteractionManager.runAfterInteractions(() => {
|
|
223
|
+
tracking.current.timeInteraction =
|
|
224
|
+
Date.now() - tracking.current.startTime;
|
|
225
|
+
});
|
|
226
|
+
|
|
203
227
|
if (data?.componentName) {
|
|
204
228
|
lastElement.current = data;
|
|
205
229
|
}
|
|
206
230
|
|
|
207
|
-
/**
|
|
208
|
-
* for stop tracking when user interaction
|
|
209
|
-
*/
|
|
210
|
-
if (data?.interaction) {
|
|
211
|
-
onScreenLoad();
|
|
212
|
-
onScreenInteraction();
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* timeout for handle tracking screen
|
|
216
|
-
*/
|
|
217
231
|
tracking.current.timeoutLoad = setTimeout(() => {
|
|
218
232
|
const time = tracking.current.endTime - tracking.current.startTime;
|
|
219
233
|
if (tracking.current.timeLoad === 0) {
|
package/Application/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {EventArg} from '@react-navigation/core';
|
|
2
2
|
import {StackNavigationOptions} from '@react-navigation/stack';
|
|
3
3
|
import React, {ReactNode} from 'react';
|
|
4
|
-
import {Animated, ViewProps
|
|
4
|
+
import {Animated, ViewProps} from 'react-native';
|
|
5
5
|
import {PopupNotifyProps} from '../Popup/types';
|
|
6
6
|
import Localize from './Localize';
|
|
7
7
|
import Navigation from './Navigation';
|
|
@@ -122,7 +122,6 @@ export type ModalParams = {
|
|
|
122
122
|
screen: React.ComponentType;
|
|
123
123
|
onDismiss?: () => void;
|
|
124
124
|
barrierDismissible?: boolean;
|
|
125
|
-
modalStyle?: ViewStyle;
|
|
126
125
|
};
|
|
127
126
|
|
|
128
127
|
export type BottomSheetParams = {
|
|
@@ -138,7 +137,6 @@ export type BottomSheetParams = {
|
|
|
138
137
|
barrierDismissible?: boolean;
|
|
139
138
|
draggable?: boolean;
|
|
140
139
|
useBottomInset?: boolean;
|
|
141
|
-
useKeyboardAvoidingView?: boolean;
|
|
142
140
|
keyboardVerticalOffset?: number;
|
|
143
141
|
};
|
|
144
142
|
|
|
@@ -160,7 +158,6 @@ export interface NavigationOptions
|
|
|
160
158
|
extends Omit<StackNavigationOptions, 'headerRight' | 'headerTitle'> {
|
|
161
159
|
preventBack?: PopupNotifyProps;
|
|
162
160
|
onPressLeftHeader?: () => void;
|
|
163
|
-
onBackHandler?: (goBack: () => void) => void;
|
|
164
161
|
hiddenBack?: boolean;
|
|
165
162
|
headerTitle?: HeaderTitleProps | string;
|
|
166
163
|
headerRight?: OnBoarding | HeaderRightToolkit | any;
|
|
@@ -181,7 +178,6 @@ export type HeaderRightToolkit = {
|
|
|
181
178
|
export interface HeaderBackProps extends NavigationButtonProps {
|
|
182
179
|
preventBack?: PopupNotifyProps;
|
|
183
180
|
onPressLeftHeader?: () => void;
|
|
184
|
-
onBackHandler?: (goBack: () => void) => void;
|
|
185
181
|
}
|
|
186
182
|
|
|
187
183
|
export type HeaderBackgroundProps = {
|
package/Application/utils.tsx
CHANGED
|
@@ -55,6 +55,21 @@ const getModalOptions = (): StackNavigationOptions => {
|
|
|
55
55
|
cardStyle: {backgroundColor: 'transparent'},
|
|
56
56
|
cardOverlayEnabled: true,
|
|
57
57
|
animationEnabled: false,
|
|
58
|
+
cardStyleInterpolator: ({current: {progress}}) => ({
|
|
59
|
+
cardStyle: {
|
|
60
|
+
opacity: progress.interpolate({
|
|
61
|
+
inputRange: [0, 0.5, 0.9, 1],
|
|
62
|
+
outputRange: [0, 0.25, 0.7, 1],
|
|
63
|
+
}),
|
|
64
|
+
},
|
|
65
|
+
overlayStyle: {
|
|
66
|
+
opacity: progress.interpolate({
|
|
67
|
+
inputRange: [0, 0.5, 0.9, 1],
|
|
68
|
+
outputRange: [0, 0.2, 0.4, 0.6],
|
|
69
|
+
extrapolate: 'clamp',
|
|
70
|
+
}),
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
58
73
|
};
|
|
59
74
|
};
|
|
60
75
|
|
|
@@ -72,7 +87,6 @@ const getOptions = (
|
|
|
72
87
|
*/
|
|
73
88
|
if (
|
|
74
89
|
typeof params.onPressLeftHeader === 'function' ||
|
|
75
|
-
typeof params.onBackHandler === 'function' ||
|
|
76
90
|
params.preventBack !== undefined ||
|
|
77
91
|
typeof params.hiddenBack === 'boolean'
|
|
78
92
|
) {
|
|
@@ -81,7 +95,6 @@ const getOptions = (
|
|
|
81
95
|
{...props}
|
|
82
96
|
preventBack={params.preventBack}
|
|
83
97
|
onPressLeftHeader={params.onPressLeftHeader}
|
|
84
|
-
onBackHandler={params.onBackHandler}
|
|
85
98
|
/>
|
|
86
99
|
);
|
|
87
100
|
if (params.hiddenBack) {
|
|
@@ -154,10 +167,19 @@ const exportHeaderTitle = (
|
|
|
154
167
|
return {};
|
|
155
168
|
};
|
|
156
169
|
|
|
170
|
+
const formatNameLength = (name = '') => {
|
|
171
|
+
let formattedName = name;
|
|
172
|
+
if (formattedName.length > 100) {
|
|
173
|
+
formattedName = formattedName.substring(0, 100);
|
|
174
|
+
}
|
|
175
|
+
return formattedName;
|
|
176
|
+
};
|
|
177
|
+
|
|
157
178
|
export {
|
|
158
179
|
getStackOptions,
|
|
159
180
|
getDialogOptions,
|
|
160
181
|
getModalOptions,
|
|
161
182
|
getOptions,
|
|
162
183
|
exportHeaderTitle,
|
|
184
|
+
formatNameLength,
|
|
163
185
|
};
|
package/Button/index.tsx
CHANGED
|
@@ -88,6 +88,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
88
88
|
...rest
|
|
89
89
|
}) => {
|
|
90
90
|
const {theme, config} = useContext(ApplicationContext);
|
|
91
|
+
const component = useContext<any>(ComponentContext);
|
|
91
92
|
const {gradient, color} = config?.navigationBar?.buttonColors ?? {};
|
|
92
93
|
let gradientPros;
|
|
93
94
|
let state = 'enabled';
|
|
@@ -292,6 +293,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
292
293
|
return (
|
|
293
294
|
<ComponentContext.Provider
|
|
294
295
|
value={{
|
|
296
|
+
...component,
|
|
295
297
|
componentName: 'Button',
|
|
296
298
|
params,
|
|
297
299
|
state: state,
|
package/Input/Input.tsx
CHANGED
|
@@ -67,6 +67,7 @@ const Input = forwardRef(
|
|
|
67
67
|
ref
|
|
68
68
|
) => {
|
|
69
69
|
const {theme} = useContext(ApplicationContext);
|
|
70
|
+
const component = useContext<any>(ComponentContext);
|
|
70
71
|
const [focused, setFocused] = useState(false);
|
|
71
72
|
const [haveValue, setHaveValue] = useState(!!value || !!props.defaultValue);
|
|
72
73
|
const [secureTextInput, setSecureTextInput] = useState(secureTextEntry);
|
|
@@ -269,6 +270,7 @@ const Input = forwardRef(
|
|
|
269
270
|
return (
|
|
270
271
|
<ComponentContext.Provider
|
|
271
272
|
value={{
|
|
273
|
+
...component,
|
|
272
274
|
componentName: 'Input',
|
|
273
275
|
params,
|
|
274
276
|
state: inputState,
|
package/Input/InputDropDown.tsx
CHANGED
|
@@ -30,6 +30,7 @@ const InputDropDown = ({
|
|
|
30
30
|
multiline,
|
|
31
31
|
}: InputDropDownProps) => {
|
|
32
32
|
const {theme} = useContext(ApplicationContext);
|
|
33
|
+
const component = useContext<any>(ComponentContext);
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
36
|
* Render the input view
|
|
@@ -105,6 +106,7 @@ const InputDropDown = ({
|
|
|
105
106
|
return (
|
|
106
107
|
<ComponentContext.Provider
|
|
107
108
|
value={{
|
|
109
|
+
...component,
|
|
108
110
|
componentName: 'InputDropDown',
|
|
109
111
|
params,
|
|
110
112
|
state: 'enabled',
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -62,6 +62,7 @@ const InputMoney = forwardRef(
|
|
|
62
62
|
ref
|
|
63
63
|
) => {
|
|
64
64
|
const {theme} = useContext(ApplicationContext);
|
|
65
|
+
const component = useContext<any>(ComponentContext);
|
|
65
66
|
|
|
66
67
|
const [focused, setFocused] = useState(false);
|
|
67
68
|
const inputRef = useRef<TextInput>(null);
|
|
@@ -206,6 +207,7 @@ const InputMoney = forwardRef(
|
|
|
206
207
|
return (
|
|
207
208
|
<ComponentContext.Provider
|
|
208
209
|
value={{
|
|
210
|
+
...component,
|
|
209
211
|
componentName: 'InputMoney',
|
|
210
212
|
params,
|
|
211
213
|
state: inputState,
|
package/Input/InputOTP.tsx
CHANGED
|
@@ -88,6 +88,7 @@ const InputOTP = forwardRef(
|
|
|
88
88
|
const [focused, setFocused] = useState(false);
|
|
89
89
|
const inputRef = useRef<TextInput | null>(null);
|
|
90
90
|
const {theme} = useContext(ApplicationContext);
|
|
91
|
+
const component = useContext<any>(ComponentContext);
|
|
91
92
|
|
|
92
93
|
useImperativeHandle(ref, () => ({
|
|
93
94
|
onChangeText: (text: string) => {
|
|
@@ -229,6 +230,7 @@ const InputOTP = forwardRef(
|
|
|
229
230
|
return (
|
|
230
231
|
<ComponentContext.Provider
|
|
231
232
|
value={{
|
|
233
|
+
...component,
|
|
232
234
|
componentName: 'InputOTP',
|
|
233
235
|
params,
|
|
234
236
|
state: 'enabled',
|
package/Input/InputSearch.tsx
CHANGED
|
@@ -139,6 +139,7 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
|
|
|
139
139
|
ref
|
|
140
140
|
) => {
|
|
141
141
|
const {theme} = useContext(ApplicationContext);
|
|
142
|
+
const component = useContext<any>(ComponentContext);
|
|
142
143
|
|
|
143
144
|
const [focused, setFocused] = useState(false);
|
|
144
145
|
const [haveValue, setHaveValue] = useState(!!value || !!defaultValue);
|
|
@@ -271,6 +272,7 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
|
|
|
271
272
|
return (
|
|
272
273
|
<ComponentContext.Provider
|
|
273
274
|
value={{
|
|
275
|
+
...component,
|
|
274
276
|
componentName: 'InputSearch',
|
|
275
277
|
params,
|
|
276
278
|
state: inputState,
|
package/Input/InputTextArea.tsx
CHANGED
package/Input/styles.ts
CHANGED
package/Popup/PopupNotify.tsx
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import React, {useContext, useEffect, useRef, useState} from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Dimensions,
|
|
4
|
-
ScrollView,
|
|
5
|
-
StyleSheet,
|
|
6
|
-
TouchableOpacity,
|
|
7
|
-
View,
|
|
8
|
-
} from 'react-native';
|
|
2
|
+
import {ScrollView, StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
9
3
|
import {ApplicationContext, MiniAppContext} from '../Application';
|
|
10
4
|
import {Button} from '../Button';
|
|
11
5
|
import {Radius, Spacing, Styles} from '../Consts';
|
|
@@ -28,8 +22,6 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
28
22
|
const context = useContext<any>(MiniAppContext);
|
|
29
23
|
const {theme, navigator, translate} = useContext(ApplicationContext);
|
|
30
24
|
const [scrollContent, setScrollContent] = useState(false);
|
|
31
|
-
const {width: widthDevice} = Dimensions.get('window');
|
|
32
|
-
|
|
33
25
|
const closeAction = useRef('touch_outside');
|
|
34
26
|
let descriptionStyle = {};
|
|
35
27
|
let Description: any = View;
|
|
@@ -198,10 +190,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
198
190
|
accessibilityLabel={'popup_notify'}
|
|
199
191
|
style={[
|
|
200
192
|
styles.container,
|
|
201
|
-
{
|
|
202
|
-
backgroundColor: theme.colors.background.surface,
|
|
203
|
-
width: widthDevice - Spacing.XL * 2,
|
|
204
|
-
},
|
|
193
|
+
{backgroundColor: theme.colors.background.surface},
|
|
205
194
|
]}>
|
|
206
195
|
{!!image && <Image source={{uri: image}} style={styles.image} />}
|
|
207
196
|
<View style={styles.content}>
|
|
@@ -245,6 +234,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
245
234
|
const styles = StyleSheet.create({
|
|
246
235
|
container: {
|
|
247
236
|
borderRadius: Radius.L,
|
|
237
|
+
minWidth: '100%',
|
|
248
238
|
},
|
|
249
239
|
image: {
|
|
250
240
|
borderTopLeftRadius: Radius.L,
|
package/Popup/PopupPromotion.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, {useContext, useEffect, useRef} from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
3
3
|
import {PopupPromotionProps} from './types';
|
|
4
4
|
import {ApplicationContext, MiniAppContext} from '../Application';
|
|
5
5
|
import {Image} from '../Image';
|
|
@@ -13,7 +13,6 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
13
13
|
}) => {
|
|
14
14
|
const context = useContext<any>(MiniAppContext);
|
|
15
15
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
16
|
-
const {width: widthDevice} = Dimensions.get('window');
|
|
17
16
|
const closeAction = useRef('touch_outside');
|
|
18
17
|
|
|
19
18
|
/**
|
|
@@ -84,12 +83,7 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
84
83
|
source={{
|
|
85
84
|
uri: image,
|
|
86
85
|
}}
|
|
87
|
-
style={
|
|
88
|
-
styles.container,
|
|
89
|
-
{
|
|
90
|
-
width: widthDevice - Spacing.XL * 2,
|
|
91
|
-
},
|
|
92
|
-
]}
|
|
86
|
+
style={styles.container}
|
|
93
87
|
/>
|
|
94
88
|
{buildCloseIcon()}
|
|
95
89
|
</View>
|
package/Text/index.tsx
CHANGED
|
@@ -111,9 +111,6 @@ const getTypoStyle = (typo: Typography, newFontFamily?: string) => {
|
|
|
111
111
|
fontFamily = `${font}-${MomoTrustSans[fontWeight]}${style}`;
|
|
112
112
|
break;
|
|
113
113
|
}
|
|
114
|
-
case 'Montserrat-Bold':
|
|
115
|
-
case 'iCielPanton-Black':
|
|
116
|
-
case 'iCielBCCubano-Normal':
|
|
117
114
|
case 'MomoTrustDisplay':
|
|
118
115
|
case 'MomoSignature': {
|
|
119
116
|
fontFamily = font;
|
|
@@ -176,19 +173,16 @@ const exportFontFamily = (
|
|
|
176
173
|
let newFontFamily;
|
|
177
174
|
|
|
178
175
|
switch (fontWeight) {
|
|
179
|
-
case 'bold':
|
|
180
|
-
case 'Bold':
|
|
176
|
+
case 'bold': {
|
|
181
177
|
typography = 'action_xs_bold';
|
|
182
178
|
break;
|
|
183
|
-
|
|
184
|
-
case 'regular':
|
|
185
|
-
case 'Regular':
|
|
179
|
+
}
|
|
180
|
+
case 'regular': {
|
|
186
181
|
typography = 'body_default_regular';
|
|
187
182
|
break;
|
|
188
|
-
|
|
183
|
+
}
|
|
189
184
|
default: {
|
|
190
185
|
typography = 'body_default_regular';
|
|
191
|
-
break;
|
|
192
186
|
}
|
|
193
187
|
}
|
|
194
188
|
|
package/Title/index.tsx
CHANGED
|
@@ -10,12 +10,6 @@ import {TitleProps} from './types';
|
|
|
10
10
|
import {Typography} from '../Text/types';
|
|
11
11
|
|
|
12
12
|
const Title: FC<TitleProps> = ({
|
|
13
|
-
accessibilityLabelIcon,
|
|
14
|
-
accessibilityLabelTitle,
|
|
15
|
-
accessibilityLabelRightAction,
|
|
16
|
-
accessibilityLabelDescription,
|
|
17
|
-
accessibilityLabelBadge,
|
|
18
|
-
accessibilityLabelTrailingAction,
|
|
19
13
|
title = 'Title',
|
|
20
14
|
type = 'section',
|
|
21
15
|
size = 'medium',
|
|
@@ -62,7 +56,7 @@ const Title: FC<TitleProps> = ({
|
|
|
62
56
|
}
|
|
63
57
|
|
|
64
58
|
return (
|
|
65
|
-
<View
|
|
59
|
+
<View style={[styles.iconView, iconStyle]}>
|
|
66
60
|
<Icon color={iconColor} source={icon} />
|
|
67
61
|
</View>
|
|
68
62
|
);
|
|
@@ -79,7 +73,6 @@ const Title: FC<TitleProps> = ({
|
|
|
79
73
|
}}
|
|
80
74
|
style={[styles.iconLeftView, flexStyle]}>
|
|
81
75
|
<RNText
|
|
82
|
-
accessibilityLabel={accessibilityLabelTitle}
|
|
83
76
|
numberOfLines={numberOfLines}
|
|
84
77
|
style={[
|
|
85
78
|
styleSheet[typography],
|
|
@@ -100,9 +93,7 @@ const Title: FC<TitleProps> = ({
|
|
|
100
93
|
}}
|
|
101
94
|
style={{
|
|
102
95
|
alignItems: 'center',
|
|
103
|
-
}}
|
|
104
|
-
accessibilityLabel={accessibilityLabelBadge}
|
|
105
|
-
>
|
|
96
|
+
}}>
|
|
106
97
|
<Badge style={styles.badge} label={badgeLabel} />
|
|
107
98
|
</View>
|
|
108
99
|
)}
|
|
@@ -110,7 +101,6 @@ const Title: FC<TitleProps> = ({
|
|
|
110
101
|
</View>
|
|
111
102
|
{description && (
|
|
112
103
|
<Text
|
|
113
|
-
accessibilityLabel={accessibilityLabelDescription}
|
|
114
104
|
style={styles.description}
|
|
115
105
|
color={theme.colors.text.secondary}
|
|
116
106
|
typography={'description_default_regular'}>
|
|
@@ -124,7 +114,6 @@ const Title: FC<TitleProps> = ({
|
|
|
124
114
|
const renderActionLeft = () => {
|
|
125
115
|
return (
|
|
126
116
|
<TouchableOpacity
|
|
127
|
-
accessibilityLabel={accessibilityLabelTrailingAction}
|
|
128
117
|
onPress={onPressTrailingAction}
|
|
129
118
|
style={styles.iconLeftView}
|
|
130
119
|
hitSlop={{top: 10, bottom: 10, left: 50, right: 10}}>
|
|
@@ -168,9 +157,7 @@ const Title: FC<TitleProps> = ({
|
|
|
168
157
|
{
|
|
169
158
|
backgroundColor: theme.colors.primary + '0F',
|
|
170
159
|
},
|
|
171
|
-
]}
|
|
172
|
-
accessibilityLabel={accessibilityLabelRightAction}
|
|
173
|
-
>
|
|
160
|
+
]}>
|
|
174
161
|
<Icon
|
|
175
162
|
source={'arrow_chevron_right_small'}
|
|
176
163
|
size={scaleSize(22)}
|
|
@@ -178,7 +165,7 @@ const Title: FC<TitleProps> = ({
|
|
|
178
165
|
/>
|
|
179
166
|
</TouchableOpacity>
|
|
180
167
|
) : (
|
|
181
|
-
<TouchableOpacity onPress={onPressRightAction}
|
|
168
|
+
<TouchableOpacity onPress={onPressRightAction}>
|
|
182
169
|
<Text color={theme.colors.primary} typography={buttonTypo}>
|
|
183
170
|
{buttonTitle}
|
|
184
171
|
</Text>
|
|
@@ -192,7 +179,6 @@ const Title: FC<TitleProps> = ({
|
|
|
192
179
|
return (
|
|
193
180
|
<View style={isSection && styles.margin}>
|
|
194
181
|
<RNText
|
|
195
|
-
accessibilityLabel={accessibilityLabelTitle}
|
|
196
182
|
numberOfLines={numberOfLines}
|
|
197
183
|
style={[styleSheet[typography], styles.title]}>
|
|
198
184
|
{title}
|
package/Title/types.ts
CHANGED
|
@@ -17,10 +17,4 @@ export type TitleProps = {
|
|
|
17
17
|
onPressTrailingAction?: () => void;
|
|
18
18
|
textOnly?: boolean;
|
|
19
19
|
style?: ViewStyle;
|
|
20
|
-
accessibilityLabelTitle?: string;
|
|
21
|
-
accessibilityLabelRightAction?: string;
|
|
22
|
-
accessibilityLabelDescription?: string;
|
|
23
|
-
accessibilityLabelIcon?: string;
|
|
24
|
-
accessibilityLabelBadge?: string;
|
|
25
|
-
accessibilityLabelTrailingAction?: string;
|
|
26
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.110.
|
|
3
|
+
"version": "0.110.3",
|
|
4
4
|
"description": "React Native Component Kits",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {},
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"react-native-gesture-handler": "1.10.3",
|
|
15
15
|
"react-native-modalize": "2.1.1",
|
|
16
16
|
"react-native-fast-image": "8.1.5",
|
|
17
|
-
"@react-navigation/bottom-tabs": "https://gitlab.mservice.com.vn/momo-platform/react-native-bottom-tabs.git",
|
|
18
17
|
"@react-navigation/core": "5.16.1",
|
|
19
18
|
"@react-navigation/native": "5.9.8",
|
|
20
19
|
"@react-navigation/routers": "5.7.4",
|
|
21
|
-
"lottie-react-native": "
|
|
22
|
-
"@react-navigation/stack": "https://gitlab.mservice.com.vn/momo-platform/react-navigation-stack.git"
|
|
20
|
+
"lottie-react-native": "https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/momo-lottie-react-native.git",
|
|
21
|
+
"@react-navigation/stack": "https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-navigation-stack.git",
|
|
22
|
+
"@react-navigation/bottom-tabs": "https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-bottom-tabs.git"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"react-native": "*"
|