@momo-kits/foundation 0.103.4 → 0.103.5
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/Localize.ts
CHANGED
|
@@ -4,7 +4,7 @@ import defaultLanguage from '../Assets/language.json';
|
|
|
4
4
|
|
|
5
5
|
class Localize {
|
|
6
6
|
private assets: LocalizationObject;
|
|
7
|
-
private currentLanguage: 'en' | 'vi';
|
|
7
|
+
private readonly currentLanguage: 'en' | 'vi';
|
|
8
8
|
|
|
9
9
|
constructor(assets: LocalizationObject) {
|
|
10
10
|
this.assets = {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import React, {useContext, useEffect, useLayoutEffect, useRef} from 'react';
|
|
2
2
|
import {useHeaderHeight} from '@react-navigation/stack';
|
|
3
|
-
import {
|
|
3
|
+
import {InteractionManager} from 'react-native';
|
|
4
4
|
import {ScreenParams} from './types';
|
|
5
5
|
import Navigation from './Navigation';
|
|
6
6
|
import {ApplicationContext, MiniAppContext, ScreenContext} from './index';
|
|
7
7
|
import {GridSystem} from '../Layout';
|
|
8
|
-
import {Text} from '../Text';
|
|
9
|
-
import {Colors, Radius, Spacing} from '../Consts';
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
10
|
* container for stack screen
|
|
@@ -68,10 +66,12 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
68
66
|
* tracking for screen
|
|
69
67
|
*/
|
|
70
68
|
useEffect(() => {
|
|
71
|
-
if (['Invalid', 'screen'].includes(screenName)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
if (['Invalid', 'screen'].includes(screenName)) {
|
|
70
|
+
navigator?.maxApi.showPopup('notice', {
|
|
71
|
+
title: 'Invalid screen name',
|
|
72
|
+
message:
|
|
73
|
+
'Your screen has not been rendered because Platform has not detected the screen name. Please migrate to support this feature.',
|
|
74
|
+
});
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
const subscription = props.navigation?.addListener?.('focus', () => {
|
|
@@ -114,23 +114,21 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
114
114
|
*/
|
|
115
115
|
const onScreenLoad = () => {
|
|
116
116
|
if (!tracking.current?.releaseLoad) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
let timeLoad = tracking.current.timeLoad;
|
|
118
|
+
if (timeLoad === 0) {
|
|
119
|
+
timeLoad = tracking.current.endTime - tracking.current.startTime;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
context.autoTracking?.({
|
|
123
|
-
|
|
124
|
-
code: context.code,
|
|
125
|
-
buildNumber: context.buildNumber,
|
|
123
|
+
...context,
|
|
126
124
|
screenName,
|
|
127
125
|
componentName: 'Screen',
|
|
128
126
|
state: 'load',
|
|
129
|
-
duration:
|
|
127
|
+
duration: timeLoad,
|
|
130
128
|
});
|
|
131
129
|
navigator?.maxApi?.stopTrace?.(
|
|
132
130
|
tracking.current.traceIdLoad,
|
|
133
|
-
{value:
|
|
131
|
+
{value: timeLoad / 1000},
|
|
134
132
|
null
|
|
135
133
|
);
|
|
136
134
|
tracking.current.releaseLoad = true;
|
|
@@ -140,12 +138,9 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
140
138
|
*/
|
|
141
139
|
navigator?.maxApi?.showToastDebug?.({
|
|
142
140
|
appId: context.appId,
|
|
143
|
-
message: `${screenName} screen_load_time ${
|
|
141
|
+
message: `${screenName} screen_load_time ${timeLoad}`,
|
|
144
142
|
type: 'ERROR',
|
|
145
143
|
});
|
|
146
|
-
if (tracking.current.timeLoad <= 0 && context.enableAutoId) {
|
|
147
|
-
Alert.alert(screenName, "Can't get screen load time");
|
|
148
|
-
}
|
|
149
144
|
}
|
|
150
145
|
};
|
|
151
146
|
|
|
@@ -154,22 +149,20 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
154
149
|
*/
|
|
155
150
|
const onScreenInteraction = () => {
|
|
156
151
|
if (!tracking.current?.releaseInteraction) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
152
|
+
let timeLoad = tracking.current.timeLoad;
|
|
153
|
+
if (timeLoad === 0) {
|
|
154
|
+
timeLoad = tracking.current.endTime - tracking.current.startTime;
|
|
160
155
|
}
|
|
161
156
|
if (tracking.current.timeInteraction === 0) {
|
|
162
|
-
tracking.current.timeInteraction =
|
|
157
|
+
tracking.current.timeInteraction = timeLoad;
|
|
163
158
|
}
|
|
164
159
|
|
|
165
160
|
context.autoTracking?.({
|
|
166
|
-
|
|
167
|
-
code: context.code,
|
|
168
|
-
buildNumber: context.buildNumber,
|
|
161
|
+
...context,
|
|
169
162
|
screenName,
|
|
170
163
|
componentName: 'Screen',
|
|
171
164
|
state: 'interaction',
|
|
172
|
-
duration: tracking.current.timeInteraction -
|
|
165
|
+
duration: tracking.current.timeInteraction - timeLoad,
|
|
173
166
|
totalDuration: tracking.current.timeInteraction,
|
|
174
167
|
});
|
|
175
168
|
navigator?.maxApi?.stopTrace?.(
|
|
@@ -187,9 +180,6 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
187
180
|
message: `${screenName} screen_interaction_time ${tracking.current.timeInteraction}`,
|
|
188
181
|
type: 'ERROR',
|
|
189
182
|
});
|
|
190
|
-
if (tracking.current.timeInteraction <= 0 && context.enableAutoId) {
|
|
191
|
-
Alert.alert(screenName, "Can't get screen interaction time");
|
|
192
|
-
}
|
|
193
183
|
}
|
|
194
184
|
};
|
|
195
185
|
|
|
@@ -198,9 +188,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
198
188
|
*/
|
|
199
189
|
const onScreenNavigated = (preScreenName: string) => {
|
|
200
190
|
context.autoTracking?.({
|
|
201
|
-
|
|
202
|
-
code: context.code,
|
|
203
|
-
buildNumber: context.buildNumber,
|
|
191
|
+
...context,
|
|
204
192
|
preScreenName,
|
|
205
193
|
screenName,
|
|
206
194
|
componentName: 'Screen',
|
|
@@ -231,98 +219,19 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
231
219
|
Date.now() - tracking.current.startTime;
|
|
232
220
|
});
|
|
233
221
|
tracking.current.timeoutLoad = setTimeout(() => {
|
|
222
|
+
const time = tracking.current.endTime - tracking.current.startTime;
|
|
234
223
|
if (tracking.current.timeLoad === 0) {
|
|
235
|
-
tracking.current.timeLoad =
|
|
236
|
-
tracking.current.endTime - tracking.current.startTime;
|
|
224
|
+
tracking.current.timeLoad = time;
|
|
237
225
|
}
|
|
238
226
|
onScreenLoad();
|
|
239
227
|
onScreenInteraction();
|
|
240
228
|
}, 2000);
|
|
241
229
|
},
|
|
242
230
|
}}>
|
|
243
|
-
<Component
|
|
244
|
-
heightHeader={heightHeader}
|
|
245
|
-
{...data}
|
|
246
|
-
onScreenLoad={onScreenLoad}
|
|
247
|
-
onScreenInteraction={onScreenInteraction}
|
|
248
|
-
/>
|
|
231
|
+
<Component heightHeader={heightHeader} {...data} />
|
|
249
232
|
{showGrid && <GridSystem />}
|
|
250
233
|
</ScreenContext.Provider>
|
|
251
234
|
);
|
|
252
235
|
};
|
|
253
236
|
|
|
254
|
-
/**
|
|
255
|
-
* Empty screen for unvalidated screen name
|
|
256
|
-
* @constructor
|
|
257
|
-
*/
|
|
258
|
-
const EmptyScreen: React.FC = () => {
|
|
259
|
-
return (
|
|
260
|
-
<View
|
|
261
|
-
style={{
|
|
262
|
-
backgroundColor: Colors.black_01,
|
|
263
|
-
padding: Spacing.M,
|
|
264
|
-
borderRadius: Radius.M,
|
|
265
|
-
}}>
|
|
266
|
-
<Text typography={'header_m_bold'}>Unvalidated screen name</Text>
|
|
267
|
-
<Text
|
|
268
|
-
typography={'description_default_regular'}
|
|
269
|
-
style={{paddingVertical: Spacing.S}}>
|
|
270
|
-
Your screen has not been rendered because Platform has not detected the
|
|
271
|
-
screen name. Please migrate to support this feature.
|
|
272
|
-
</Text>
|
|
273
|
-
<Text typography={'header_default'} style={{width: '100%'}}>
|
|
274
|
-
Possible fixes:
|
|
275
|
-
</Text>
|
|
276
|
-
<View style={{marginLeft: Spacing.S}}>
|
|
277
|
-
<Text typography={'body_default_regular'}>1. Off webpack config</Text>
|
|
278
|
-
<Text typography={'body_default_regular'}>
|
|
279
|
-
2. Screen name refactoring
|
|
280
|
-
</Text>
|
|
281
|
-
<View style={{marginLeft: Spacing.S}}>
|
|
282
|
-
<Text
|
|
283
|
-
typography={'description_default_regular'}
|
|
284
|
-
style={{marginBottom: Spacing.S}}>
|
|
285
|
-
- Với các screen push/import dạng arrow function ={'>'} đổi thành
|
|
286
|
-
named function
|
|
287
|
-
</Text>
|
|
288
|
-
<Text
|
|
289
|
-
typography={'description_default_regular'}
|
|
290
|
-
style={{marginBottom: Spacing.S}}>
|
|
291
|
-
- Với các screen import dạng High Order Component ={'>'} rename
|
|
292
|
-
generic function thành named function
|
|
293
|
-
</Text>
|
|
294
|
-
<Text
|
|
295
|
-
typography={'description_default_regular'}
|
|
296
|
-
style={{marginBottom: Spacing.S}}>
|
|
297
|
-
- Với Tab Navigator, Platform sẽ lấy Tab Container làm screen name.
|
|
298
|
-
Trong trường hợp miniapp muốn track riêng action cho từng tab, tham
|
|
299
|
-
khảo theo docs
|
|
300
|
-
</Text>
|
|
301
|
-
</View>
|
|
302
|
-
</View>
|
|
303
|
-
<Text typography={'header_s_semibold'}>More information: </Text>
|
|
304
|
-
<Text
|
|
305
|
-
typography={'body_default_regular'}
|
|
306
|
-
color={Colors.blue_01}
|
|
307
|
-
onPress={() => {
|
|
308
|
-
Linking.openURL(
|
|
309
|
-
'https://gitlab.mservice.com.vn/momo-platform/mini-app/-/tree/vn.momo.uikits/dev/app'
|
|
310
|
-
);
|
|
311
|
-
}}>
|
|
312
|
-
Mini App: vn.momo.uikits/dev
|
|
313
|
-
</Text>
|
|
314
|
-
<Text
|
|
315
|
-
typography={'body_default_regular'}
|
|
316
|
-
color={Colors.blue_01}
|
|
317
|
-
onPress={() => {
|
|
318
|
-
Linking.openURL(
|
|
319
|
-
'https://docs.google.com/presentation/d/1bIFoh8gRXb6hsnGJz4O1Kxg4_oNikB1KuuEt2wULCDM/edit?usp=sharing'
|
|
320
|
-
);
|
|
321
|
-
}}>
|
|
322
|
-
https://docs.google.com/presentation/d/1bIFoh8gRXb6hsnGJz4O1Kxg4_oNikB1KuuEt2wULCDM/edit?usp=sharing
|
|
323
|
-
</Text>
|
|
324
|
-
</View>
|
|
325
|
-
);
|
|
326
|
-
};
|
|
327
|
-
|
|
328
237
|
export default StackScreen;
|
package/Popup/PopupNotify.tsx
CHANGED
|
@@ -40,8 +40,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
40
40
|
screen_name = routes[routesLength - 2]?.params?.screen?.name;
|
|
41
41
|
}
|
|
42
42
|
const tracking = {
|
|
43
|
-
|
|
44
|
-
code: context.code,
|
|
43
|
+
...context,
|
|
45
44
|
screen_name,
|
|
46
45
|
component_type: 'popup',
|
|
47
46
|
component_name: id,
|
package/Popup/PopupPromotion.tsx
CHANGED
|
@@ -26,8 +26,7 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
26
26
|
screen_name = routes[routesLength - 2]?.params?.screen?.name;
|
|
27
27
|
}
|
|
28
28
|
const tracking = {
|
|
29
|
-
|
|
30
|
-
code: context.code,
|
|
29
|
+
...context,
|
|
31
30
|
screen_name,
|
|
32
31
|
component_type: 'popup',
|
|
33
32
|
component_name: id,
|
package/Title/index.tsx
CHANGED
|
@@ -115,7 +115,8 @@ const Title: FC<TitleProps> = ({
|
|
|
115
115
|
return (
|
|
116
116
|
<TouchableOpacity
|
|
117
117
|
onPress={onPressTrailingAction}
|
|
118
|
-
style={styles.iconLeftView}
|
|
118
|
+
style={styles.iconLeftView}
|
|
119
|
+
hitSlop={{top: 10, bottom: 10, left: 50, right: 10}}>
|
|
119
120
|
{showTrailingAction && !showRightAction && (
|
|
120
121
|
<View
|
|
121
122
|
style={[
|