@momo-kits/foundation 0.81.51-beta.0 → 0.81.51
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/{BottomTab/index.tsx → BottomTab.tsx} +18 -42
- package/Application/Components.tsx +91 -356
- package/Application/ModalScreen.tsx +185 -14
- package/Application/Navigation.ts +19 -5
- package/Application/NavigationContainer.tsx +72 -62
- package/Application/Navigator.ts +48 -154
- package/Application/StackScreen.tsx +32 -289
- package/Application/index.ts +15 -13
- package/Application/types.ts +35 -81
- package/Application/utils.tsx +30 -76
- package/Assets/icon_bank.json +1 -1
- package/Badge/Badge.tsx +1 -1
- package/Badge/index.tsx +1 -2
- package/Badge/styles.ts +6 -50
- package/Button/index.tsx +26 -44
- package/CheckBox/index.tsx +26 -37
- package/CheckBox/types.ts +3 -5
- package/Consts/colors+spacing+radius.ts +0 -14
- package/Icon/index.tsx +8 -9
- package/Icon/types.ts +2 -2
- package/IconButton/index.tsx +14 -24
- package/Image/index.tsx +8 -23
- package/Image/types.ts +0 -2
- package/Input/Input.tsx +26 -116
- package/Input/InputDropDown.tsx +51 -66
- package/Input/InputMoney.tsx +15 -106
- package/Input/InputOTP.tsx +26 -49
- package/Input/InputSearch.tsx +99 -252
- package/Input/InputTextArea.tsx +6 -26
- package/Input/common.tsx +22 -48
- package/Input/index.tsx +77 -112
- package/Input/styles.ts +11 -48
- package/Input/utils.ts +1 -1
- package/Layout/Card.tsx +3 -4
- package/Layout/GridSystem.tsx +1 -1
- package/Layout/ItemList.tsx +2 -3
- package/Layout/Screen.tsx +121 -242
- package/Layout/Section.tsx +3 -4
- package/Layout/styles.ts +13 -11
- package/Layout/types.ts +1 -1
- package/Layout/utils.ts +4 -4
- package/Loader/index.tsx +0 -2
- package/Pagination/PaginationScroll.tsx +2 -2
- package/Pagination/styles.ts +1 -1
- package/Popup/PopupNotify.tsx +46 -57
- package/Popup/PopupPromotion.tsx +8 -6
- package/Popup/types.ts +7 -1
- package/Radio/index.tsx +20 -35
- package/Radio/types.ts +3 -5
- package/Switch/index.tsx +18 -32
- package/Switch/types.ts +3 -5
- package/Tag/index.tsx +2 -9
- package/Tag/styles.ts +2 -3
- package/Tag/types.ts +0 -12
- package/Text/index.tsx +5 -24
- package/Text/styles.ts +8 -8
- package/Title/index.tsx +103 -170
- package/Title/styles.ts +9 -36
- package/Title/types.ts +48 -16
- package/code-scanner.js +16 -125
- package/index.ts +0 -7
- package/package.json +9 -10
- package/publish.sh +21 -16
- package/tsconfig.json +1 -1
- package/Application/BottomSheet.tsx +0 -216
- package/Application/BottomTab/BottomTabBar.tsx +0 -278
- package/Application/Localize.ts +0 -44
- package/Application/constants.ts +0 -9
- package/Badge/BadgeDotAnimation.tsx +0 -95
- package/Input/TextTyping.tsx +0 -113
- package/Layout/FloatingButton.tsx +0 -168
package/Application/Navigator.ts
CHANGED
|
@@ -1,170 +1,79 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CommonActions,
|
|
3
|
-
NavigationContainerRef,
|
|
4
|
-
StackActions,
|
|
5
|
-
} from '@react-navigation/native';
|
|
1
|
+
import {CommonActions, StackActions} from '@react-navigation/native';
|
|
6
2
|
import {
|
|
7
3
|
BottomSheetParams,
|
|
8
4
|
HeaderToolkitProps,
|
|
9
5
|
ModalParams,
|
|
10
|
-
NavigatorCallbackParamsType,
|
|
11
6
|
ScreenParams,
|
|
12
7
|
} from './types';
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import {
|
|
15
|
-
NavigationActionCallbackErrorEnum,
|
|
16
|
-
NavigationActionCallbackStatusEnum,
|
|
17
|
-
} from './constants';
|
|
18
8
|
|
|
19
9
|
class Navigator {
|
|
20
|
-
ref
|
|
21
|
-
isReady: React.MutableRefObject<boolean>;
|
|
10
|
+
ref?: any;
|
|
22
11
|
toolkitConfig?: HeaderToolkitProps;
|
|
23
12
|
maxApi?: any;
|
|
24
|
-
dismissData?:
|
|
25
|
-
toolkitCallback?: (
|
|
13
|
+
dismissData?: any;
|
|
14
|
+
toolkitCallback?: (item: any) => void;
|
|
26
15
|
|
|
27
|
-
constructor(
|
|
28
|
-
navigation: React.RefObject<NavigationContainerRef>,
|
|
29
|
-
isReady: React.MutableRefObject<boolean>
|
|
30
|
-
) {
|
|
16
|
+
constructor(navigation: any) {
|
|
31
17
|
this.ref = navigation;
|
|
32
|
-
this.isReady = isReady;
|
|
33
18
|
}
|
|
34
19
|
|
|
35
|
-
private validateRefAndRunAction = (params: {
|
|
36
|
-
action: (navigationRef: NavigationContainerRef) => void;
|
|
37
|
-
callback?: (params: NavigatorCallbackParamsType) => void;
|
|
38
|
-
}) => {
|
|
39
|
-
try {
|
|
40
|
-
if (this.isReady.current && this.ref.current) {
|
|
41
|
-
params.action(this.ref.current);
|
|
42
|
-
params.callback?.({status: NavigationActionCallbackStatusEnum.Success});
|
|
43
|
-
} else {
|
|
44
|
-
params.callback?.({
|
|
45
|
-
status: NavigationActionCallbackStatusEnum.Failed,
|
|
46
|
-
type: NavigationActionCallbackErrorEnum.NotReady,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
} catch (error) {
|
|
50
|
-
params.callback?.({
|
|
51
|
-
status: NavigationActionCallbackStatusEnum.Failed,
|
|
52
|
-
type: NavigationActionCallbackErrorEnum.Error,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
20
|
/**
|
|
58
21
|
* push new stack screen
|
|
59
22
|
* @param params
|
|
60
23
|
*/
|
|
61
|
-
push = (
|
|
62
|
-
params
|
|
63
|
-
callback?: (params: NavigatorCallbackParamsType) => void
|
|
64
|
-
) => {
|
|
65
|
-
this.validateRefAndRunAction({
|
|
66
|
-
action: navigationRef => {
|
|
67
|
-
navigationRef.dispatch(StackActions.push('Stack', params));
|
|
68
|
-
},
|
|
69
|
-
callback,
|
|
70
|
-
});
|
|
24
|
+
push = (params: ScreenParams) => {
|
|
25
|
+
this.ref.current.dispatch(StackActions.push('Stack', params));
|
|
71
26
|
};
|
|
72
27
|
|
|
73
28
|
/**
|
|
74
29
|
* replace current screen with new screen
|
|
75
30
|
* @param params
|
|
76
31
|
*/
|
|
77
|
-
replace = (
|
|
78
|
-
params
|
|
79
|
-
callback?: (params: NavigatorCallbackParamsType) => void
|
|
80
|
-
) => {
|
|
81
|
-
this.validateRefAndRunAction({
|
|
82
|
-
action: navigationRef => {
|
|
83
|
-
navigationRef.dispatch(StackActions.replace('Stack', params));
|
|
84
|
-
},
|
|
85
|
-
callback,
|
|
86
|
-
});
|
|
32
|
+
replace = (params: ScreenParams) => {
|
|
33
|
+
this.ref.current.dispatch(StackActions.replace('Stack', params));
|
|
87
34
|
};
|
|
88
35
|
/**
|
|
89
36
|
* pop to dismiss a screen
|
|
90
37
|
* @param count
|
|
91
38
|
*/
|
|
92
|
-
pop = (
|
|
93
|
-
count
|
|
94
|
-
callback?: (params: NavigatorCallbackParamsType) => void
|
|
95
|
-
) => {
|
|
96
|
-
this.validateRefAndRunAction({
|
|
97
|
-
action: navigationRef => {
|
|
98
|
-
navigationRef.dispatch(StackActions.pop(count ?? 1));
|
|
99
|
-
},
|
|
100
|
-
callback,
|
|
101
|
-
});
|
|
39
|
+
pop = (count?: number) => {
|
|
40
|
+
this.ref.current.dispatch(StackActions.pop(count ?? 1));
|
|
102
41
|
};
|
|
103
42
|
|
|
104
43
|
/**
|
|
105
44
|
* present a new screen, show from bottom iOS
|
|
106
45
|
* @param params
|
|
107
46
|
*/
|
|
108
|
-
present = (
|
|
109
|
-
params
|
|
110
|
-
callback?: (params: NavigatorCallbackParamsType) => void
|
|
111
|
-
) => {
|
|
112
|
-
this.validateRefAndRunAction({
|
|
113
|
-
action: navigationRef => {
|
|
114
|
-
navigationRef.dispatch(StackActions.push('Dialog', params));
|
|
115
|
-
},
|
|
116
|
-
callback,
|
|
117
|
-
});
|
|
47
|
+
present = (params: ScreenParams) => {
|
|
48
|
+
this.ref.current.dispatch(StackActions.push('Dialog', params));
|
|
118
49
|
};
|
|
119
50
|
|
|
120
51
|
/**
|
|
121
52
|
* show a modal popup
|
|
122
53
|
* @param params
|
|
123
54
|
*/
|
|
124
|
-
showModal = (
|
|
125
|
-
params
|
|
126
|
-
callback?: (params: NavigatorCallbackParamsType) => void
|
|
127
|
-
) => {
|
|
128
|
-
this.validateRefAndRunAction({
|
|
129
|
-
action: navigationRef => {
|
|
130
|
-
navigationRef.dispatch(StackActions.push('Modal', params));
|
|
131
|
-
},
|
|
132
|
-
callback,
|
|
133
|
-
});
|
|
55
|
+
showModal = (params: ModalParams) => {
|
|
56
|
+
this.ref.current.dispatch(StackActions.push('Modal', params));
|
|
134
57
|
};
|
|
135
58
|
|
|
136
59
|
/**
|
|
137
60
|
* show a bottom sheet
|
|
138
61
|
* @param params
|
|
139
|
-
* @param callback
|
|
140
62
|
*/
|
|
141
|
-
showBottomSheet = (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
StackActions.push('Modal', {
|
|
149
|
-
...params,
|
|
150
|
-
isBottomSheet: true,
|
|
151
|
-
})
|
|
152
|
-
);
|
|
153
|
-
},
|
|
154
|
-
callback,
|
|
155
|
-
});
|
|
63
|
+
showBottomSheet = (params: BottomSheetParams) => {
|
|
64
|
+
this.ref.current.dispatch(
|
|
65
|
+
StackActions.push('Modal', {
|
|
66
|
+
...params,
|
|
67
|
+
isBottomSheet: true,
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
156
70
|
};
|
|
157
71
|
|
|
158
72
|
/**
|
|
159
73
|
* pop all screen route
|
|
160
74
|
*/
|
|
161
|
-
popToTop = (
|
|
162
|
-
this.
|
|
163
|
-
action: navigationRef => {
|
|
164
|
-
navigationRef.dispatch(StackActions.popToTop());
|
|
165
|
-
},
|
|
166
|
-
callback,
|
|
167
|
-
});
|
|
75
|
+
popToTop = () => {
|
|
76
|
+
this.ref.current.dispatch(StackActions.popToTop());
|
|
168
77
|
};
|
|
169
78
|
|
|
170
79
|
/**
|
|
@@ -172,56 +81,39 @@ class Navigator {
|
|
|
172
81
|
* @param name
|
|
173
82
|
* @param params
|
|
174
83
|
*/
|
|
175
|
-
navigate = (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
navigationRef.dispatch(
|
|
183
|
-
CommonActions.navigate({
|
|
184
|
-
name,
|
|
185
|
-
params,
|
|
186
|
-
})
|
|
187
|
-
);
|
|
188
|
-
},
|
|
189
|
-
callback,
|
|
190
|
-
});
|
|
84
|
+
navigate = (name: string, params: any) => {
|
|
85
|
+
this.ref.current.dispatch(
|
|
86
|
+
CommonActions.navigate({
|
|
87
|
+
name,
|
|
88
|
+
params,
|
|
89
|
+
}),
|
|
90
|
+
);
|
|
191
91
|
};
|
|
192
92
|
|
|
193
93
|
/**
|
|
194
94
|
* reset a navigation flow with new screen
|
|
195
95
|
* @param params
|
|
196
96
|
*/
|
|
197
|
-
reset = (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
params,
|
|
211
|
-
},
|
|
212
|
-
],
|
|
213
|
-
})
|
|
214
|
-
);
|
|
215
|
-
},
|
|
216
|
-
callback,
|
|
217
|
-
});
|
|
97
|
+
reset = (params: ScreenParams) => {
|
|
98
|
+
this.ref.current.dispatch(
|
|
99
|
+
CommonActions.reset({
|
|
100
|
+
index: 0,
|
|
101
|
+
routes: [
|
|
102
|
+
{
|
|
103
|
+
name: 'Stack',
|
|
104
|
+
key: `Stack_${new Date().getTime()}`,
|
|
105
|
+
params,
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
}),
|
|
109
|
+
);
|
|
218
110
|
};
|
|
219
111
|
|
|
220
112
|
/**
|
|
221
113
|
* dismiss a feature data
|
|
222
114
|
* @param data
|
|
223
115
|
*/
|
|
224
|
-
setDismissData = (data:
|
|
116
|
+
setDismissData = (data: any) => {
|
|
225
117
|
this.dismissData = data;
|
|
226
118
|
};
|
|
227
119
|
|
|
@@ -229,7 +121,9 @@ class Navigator {
|
|
|
229
121
|
* set callback function for toolkit
|
|
230
122
|
* @param callback
|
|
231
123
|
*/
|
|
232
|
-
setToolkitCallback = (
|
|
124
|
+
setToolkitCallback = (
|
|
125
|
+
callback: (item: {key: string; action: string}) => void,
|
|
126
|
+
) => {
|
|
233
127
|
this.toolkitCallback = callback;
|
|
234
128
|
};
|
|
235
129
|
}
|
|
@@ -1,327 +1,70 @@
|
|
|
1
|
-
import React, {useContext, useEffect, useLayoutEffect
|
|
2
|
-
import {useHeaderHeight} from '@react-navigation/stack';
|
|
3
|
-
import {Alert, InteractionManager, Linking, View} from 'react-native';
|
|
1
|
+
import React, {useContext, useEffect, useLayoutEffect} from 'react';
|
|
4
2
|
import {ScreenParams} from './types';
|
|
5
3
|
import Navigation from './Navigation';
|
|
6
|
-
import {ApplicationContext, MiniAppContext
|
|
4
|
+
import {ApplicationContext, MiniAppContext} from './index';
|
|
7
5
|
import {GridSystem} from '../Layout';
|
|
8
|
-
import {
|
|
9
|
-
import {Colors, Radius, Spacing} from '../Consts';
|
|
6
|
+
import {useHeaderHeight} from '@react-navigation/stack';
|
|
10
7
|
|
|
11
|
-
/**
|
|
12
|
-
* container for stack screen
|
|
13
|
-
* @param props
|
|
14
|
-
* @constructor
|
|
15
|
-
*/
|
|
16
8
|
const StackScreen: React.FC<ScreenParams> = props => {
|
|
17
|
-
const {showGrid, navigator} = useContext(ApplicationContext);
|
|
18
|
-
const
|
|
19
|
-
timeoutLoad: undefined,
|
|
20
|
-
timeoutInteraction: undefined,
|
|
21
|
-
timeoutTracking: undefined,
|
|
22
|
-
startTime: Date.now(),
|
|
23
|
-
endTime: Date.now(),
|
|
24
|
-
traceIdLoad: undefined,
|
|
25
|
-
traceIdInteraction: undefined,
|
|
26
|
-
releaseLoad: undefined,
|
|
27
|
-
releaseInteraction: undefined,
|
|
28
|
-
timeLoad: 0,
|
|
29
|
-
timeInteraction: 0,
|
|
30
|
-
});
|
|
9
|
+
const {theme, showGrid, navigator} = useContext(ApplicationContext);
|
|
10
|
+
const context = useContext(MiniAppContext);
|
|
31
11
|
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const navigation = new Navigation(props.navigation);
|
|
12
|
+
const {screen: Component, options}: ScreenParams = props.route.params;
|
|
13
|
+
const navigation = new Navigation(props.navigation, theme);
|
|
35
14
|
const heightHeader = useHeaderHeight();
|
|
36
15
|
|
|
37
|
-
const
|
|
38
|
-
...initialParams,
|
|
16
|
+
const params = {
|
|
39
17
|
...props.route.params,
|
|
40
18
|
navigation,
|
|
41
19
|
};
|
|
42
20
|
|
|
43
|
-
delete
|
|
44
|
-
delete data.initialParams;
|
|
45
|
-
|
|
46
|
-
const screenName = Component?.name || Component?.type?.name || 'Invalid';
|
|
47
|
-
const routes = props.navigation.getState()?.routes || [];
|
|
21
|
+
delete params.screen;
|
|
48
22
|
|
|
49
23
|
/**
|
|
50
24
|
* set options for screen
|
|
51
25
|
*/
|
|
52
26
|
useLayoutEffect(() => {
|
|
53
|
-
let defaultOptions = {
|
|
54
|
-
headerRight: {
|
|
55
|
-
type: 'toolkit',
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
27
|
if (options) {
|
|
59
|
-
|
|
60
|
-
...defaultOptions,
|
|
61
|
-
...options,
|
|
62
|
-
};
|
|
28
|
+
navigation.setOptions(options);
|
|
63
29
|
}
|
|
64
|
-
navigation.setOptions(defaultOptions);
|
|
65
30
|
}, [options]);
|
|
66
31
|
|
|
67
32
|
/**
|
|
68
33
|
* tracking for screen
|
|
69
34
|
*/
|
|
70
35
|
useEffect(() => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}, 300);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const subscription = props.navigation?.addListener?.('focus', () => {
|
|
78
|
-
navigator?.maxApi?.of?.({screenName});
|
|
79
|
-
navigator?.maxApi?.getDataObserver('CURRENT_SCREEN', (data: any) => {
|
|
80
|
-
let preScreenName = data?.screenName;
|
|
81
|
-
if (routes?.length > 1) {
|
|
82
|
-
const screen = routes?.[routes?.length - 2]?.params?.screen;
|
|
83
|
-
preScreenName = screen?.name || screen?.type?.name || 'Invalid';
|
|
84
|
-
}
|
|
85
|
-
onScreenNavigated(preScreenName);
|
|
86
|
-
navigator?.maxApi?.setObserver('CURRENT_SCREEN', {screenName});
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
navigator?.maxApi?.startTraceScreenLoad?.(screenName, (data: any) => {
|
|
90
|
-
tracking.current.traceIdLoad = data?.traceId;
|
|
91
|
-
});
|
|
92
|
-
navigator?.maxApi?.startTraceScreenInteraction?.(
|
|
93
|
-
screenName,
|
|
94
|
-
(data: any) => {
|
|
95
|
-
tracking.current.traceIdInteraction = data?.traceId;
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
tracking.current.timeoutTracking = setTimeout(() => {
|
|
100
|
-
onScreenLoad();
|
|
101
|
-
onScreenInteraction();
|
|
102
|
-
}, 5000);
|
|
103
|
-
|
|
104
|
-
return () => {
|
|
105
|
-
onScreenLoad();
|
|
106
|
-
onScreenInteraction();
|
|
107
|
-
clearTimeout(tracking.current.timeoutTracking);
|
|
108
|
-
subscription?.();
|
|
36
|
+
const tracking = {
|
|
37
|
+
...context,
|
|
38
|
+
screen_name: Component.name,
|
|
109
39
|
};
|
|
110
|
-
}, []);
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* tracking for screen load
|
|
114
|
-
*/
|
|
115
|
-
const onScreenLoad = () => {
|
|
116
|
-
if (!tracking.current?.releaseLoad) {
|
|
117
|
-
if (tracking.current.timeLoad === 0) {
|
|
118
|
-
tracking.current.timeLoad =
|
|
119
|
-
tracking.current.endTime - tracking.current.startTime;
|
|
120
|
-
}
|
|
121
40
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
componentName: 'Screen',
|
|
128
|
-
state: 'load',
|
|
129
|
-
duration: tracking.current.timeLoad,
|
|
130
|
-
});
|
|
131
|
-
navigator?.maxApi?.stopTrace?.(
|
|
132
|
-
tracking.current.traceIdLoad,
|
|
133
|
-
{value: tracking.current.timeLoad / 1000},
|
|
134
|
-
null
|
|
135
|
-
);
|
|
136
|
-
tracking.current.releaseLoad = true;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* debug
|
|
140
|
-
*/
|
|
141
|
-
navigator?.maxApi?.showToastDebug?.({
|
|
142
|
-
appId: context.appId,
|
|
143
|
-
message: `${screenName} screen_load_time ${tracking.current.timeLoad}`,
|
|
144
|
-
type: 'ERROR',
|
|
145
|
-
});
|
|
146
|
-
if (tracking.current.timeLoad <= 0 && context.enableAutoId) {
|
|
147
|
-
Alert.alert(screenName, "Can't get screen load time");
|
|
148
|
-
}
|
|
41
|
+
const routes = props.navigation.getState()?.routes || [];
|
|
42
|
+
const routesLength = routes.length;
|
|
43
|
+
let pre_screen_name = '';
|
|
44
|
+
if (routesLength > 1) {
|
|
45
|
+
pre_screen_name = routes[routesLength - 2]?.params?.screen?.name;
|
|
149
46
|
}
|
|
150
|
-
};
|
|
151
47
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (!tracking.current?.releaseInteraction) {
|
|
157
|
-
if (tracking.current.timeLoad === 0) {
|
|
158
|
-
tracking.current.timeLoad =
|
|
159
|
-
tracking.current.endTime - tracking.current.startTime;
|
|
160
|
-
}
|
|
161
|
-
if (tracking.current.timeInteraction === 0) {
|
|
162
|
-
tracking.current.timeInteraction = tracking.current.timeLoad;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
context.autoTracking?.({
|
|
166
|
-
appId: context.appId,
|
|
167
|
-
code: context.code,
|
|
168
|
-
buildNumber: context.buildNumber,
|
|
169
|
-
screenName,
|
|
170
|
-
componentName: 'Screen',
|
|
171
|
-
state: 'interaction',
|
|
172
|
-
duration: tracking.current.timeInteraction - tracking.current.timeLoad,
|
|
173
|
-
totalDuration: tracking.current.timeInteraction,
|
|
174
|
-
});
|
|
175
|
-
navigator?.maxApi?.stopTrace?.(
|
|
176
|
-
tracking.current.traceIdInteraction,
|
|
177
|
-
{value: tracking.current.timeInteraction / 1000},
|
|
178
|
-
null
|
|
179
|
-
);
|
|
180
|
-
tracking.current.releaseInteraction = true;
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* debug toast
|
|
184
|
-
*/
|
|
185
|
-
navigator?.maxApi?.showToastDebug?.({
|
|
186
|
-
appId: context.appId,
|
|
187
|
-
message: `${screenName} screen_interaction_time ${tracking.current.timeInteraction}`,
|
|
188
|
-
type: 'ERROR',
|
|
189
|
-
});
|
|
190
|
-
if (tracking.current.timeInteraction <= 0 && context.enableAutoId) {
|
|
191
|
-
Alert.alert(screenName, "Can't get screen interaction time");
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* tracking for screen navigated
|
|
198
|
-
*/
|
|
199
|
-
const onScreenNavigated = (preScreenName: string) => {
|
|
200
|
-
context.autoTracking?.({
|
|
201
|
-
appId: context.appId,
|
|
202
|
-
code: context.code,
|
|
203
|
-
buildNumber: context.buildNumber,
|
|
204
|
-
preScreenName,
|
|
205
|
-
screenName,
|
|
206
|
-
componentName: 'Screen',
|
|
207
|
-
state: 'navigated',
|
|
48
|
+
navigator?.maxApi?.trackEvent?.('service_frame_displayed', {
|
|
49
|
+
...tracking,
|
|
50
|
+
pre_screen_name,
|
|
51
|
+
trigger_id: '111378000000000000',
|
|
208
52
|
});
|
|
209
53
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
type: 'ERROR',
|
|
54
|
+
return props.navigation.addListener('beforeRemove', () => {
|
|
55
|
+
navigator?.maxApi?.trackEvent?.('service_icon_clicked', {
|
|
56
|
+
...tracking,
|
|
57
|
+
trigger_id: '111154000000000000',
|
|
58
|
+
icon_name: 'back',
|
|
59
|
+
});
|
|
217
60
|
});
|
|
218
|
-
};
|
|
61
|
+
}, []);
|
|
219
62
|
|
|
220
63
|
return (
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
screenName,
|
|
224
|
-
onElementLoad: () => {
|
|
225
|
-
clearTimeout(tracking.current.timeoutLoad);
|
|
226
|
-
tracking.current.endTime = Date.now();
|
|
227
|
-
tracking.current.timeoutInteraction?.cancel?.();
|
|
228
|
-
tracking.current.timeoutInteraction =
|
|
229
|
-
InteractionManager.runAfterInteractions(() => {
|
|
230
|
-
tracking.current.timeInteraction =
|
|
231
|
-
Date.now() - tracking.current.startTime;
|
|
232
|
-
});
|
|
233
|
-
tracking.current.timeoutLoad = setTimeout(() => {
|
|
234
|
-
if (tracking.current.timeLoad === 0) {
|
|
235
|
-
tracking.current.timeLoad =
|
|
236
|
-
tracking.current.endTime - tracking.current.startTime;
|
|
237
|
-
}
|
|
238
|
-
onScreenLoad();
|
|
239
|
-
onScreenInteraction();
|
|
240
|
-
}, 2000);
|
|
241
|
-
},
|
|
242
|
-
}}>
|
|
243
|
-
<Component
|
|
244
|
-
heightHeader={heightHeader}
|
|
245
|
-
{...data}
|
|
246
|
-
onScreenLoad={onScreenLoad}
|
|
247
|
-
onScreenInteraction={onScreenInteraction}
|
|
248
|
-
/>
|
|
64
|
+
<>
|
|
65
|
+
<Component heightHeader={heightHeader} {...params} />
|
|
249
66
|
{showGrid && <GridSystem />}
|
|
250
|
-
|
|
251
|
-
);
|
|
252
|
-
};
|
|
253
|
-
|
|
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>
|
|
67
|
+
</>
|
|
325
68
|
);
|
|
326
69
|
};
|
|
327
70
|
|
package/Application/index.ts
CHANGED
|
@@ -1,39 +1,41 @@
|
|
|
1
|
-
import {Platform} from 'react-native';
|
|
2
|
-
import {createContext} from 'react';
|
|
3
1
|
import {NavigationContainer} from './NavigationContainer';
|
|
4
|
-
import Localize from './Localize';
|
|
5
2
|
import Screen from '../Layout/Screen';
|
|
6
3
|
import {
|
|
7
4
|
HeaderAnimated,
|
|
8
5
|
HeaderBackground,
|
|
9
6
|
HeaderCustom,
|
|
7
|
+
HeaderLeft,
|
|
8
|
+
HeaderRightAction,
|
|
10
9
|
HeaderTitle,
|
|
10
|
+
HeaderToolkitAction,
|
|
11
11
|
NavigationButton,
|
|
12
|
-
HeaderRightAction,
|
|
13
12
|
} from './Components';
|
|
14
13
|
import BottomTab from './BottomTab';
|
|
14
|
+
import {createContext} from 'react';
|
|
15
15
|
import {defaultContext} from '../Consts';
|
|
16
|
+
import {MiniAppInfo} from './types';
|
|
16
17
|
|
|
17
|
-
const Context = createContext({});
|
|
18
18
|
const ApplicationContext = createContext(defaultContext);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
const MiniAppContext = createContext<MiniAppInfo>({
|
|
20
|
+
appId: '',
|
|
21
|
+
buildNumber: 0,
|
|
22
|
+
code: '',
|
|
23
|
+
toolkitConfig: {},
|
|
24
|
+
fromCode: '',
|
|
25
|
+
});
|
|
23
26
|
|
|
24
27
|
export {
|
|
25
28
|
ApplicationContext,
|
|
26
29
|
MiniAppContext,
|
|
27
|
-
ScreenContext,
|
|
28
|
-
ComponentContext,
|
|
29
30
|
NavigationContainer,
|
|
30
|
-
Localize,
|
|
31
31
|
Screen,
|
|
32
32
|
BottomTab,
|
|
33
33
|
NavigationButton,
|
|
34
|
-
HeaderRightAction,
|
|
35
34
|
HeaderTitle,
|
|
35
|
+
HeaderLeft,
|
|
36
36
|
HeaderBackground,
|
|
37
|
+
HeaderRightAction,
|
|
38
|
+
HeaderToolkitAction,
|
|
37
39
|
HeaderCustom,
|
|
38
40
|
HeaderAnimated,
|
|
39
41
|
};
|