@momo-kits/foundation 0.103.1-beta.3 → 0.103.1-optimize.0
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.
|
@@ -149,7 +149,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
149
149
|
const goBackSafe = () => {
|
|
150
150
|
const goBack = () => {
|
|
151
151
|
const canGoBack = navigator?.ref?.current?.canGoBack?.();
|
|
152
|
-
const currentRoute
|
|
152
|
+
const currentRoute = navigator?.ref?.current?.getCurrentRoute?.();
|
|
153
153
|
const params = {
|
|
154
154
|
appId: context.appId,
|
|
155
155
|
code: context.code,
|
|
@@ -337,6 +337,7 @@ const HeaderRight: React.FC<any> = ({type, children, onLayout, ...props}) => {
|
|
|
337
337
|
const HeaderToolkitAction: React.FC<any> = ({
|
|
338
338
|
tintColor,
|
|
339
339
|
pinnedTool,
|
|
340
|
+
runtimeTools = [],
|
|
340
341
|
preventClose,
|
|
341
342
|
}) => {
|
|
342
343
|
const {navigator} = useContext(ApplicationContext);
|
|
@@ -373,15 +374,13 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
373
374
|
const onMore = () => {
|
|
374
375
|
onAction?.('onMore');
|
|
375
376
|
navigator?.maxApi?.dispatchFunction?.(
|
|
376
|
-
'
|
|
377
|
-
{
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
},
|
|
384
|
-
() => {}
|
|
377
|
+
'showTools',
|
|
378
|
+
{runtimeTools},
|
|
379
|
+
(res: {item: {action?: string; key: string}}) => {
|
|
380
|
+
const {item} = res;
|
|
381
|
+
navigator?.toolkitCallback?.(item.key);
|
|
382
|
+
getToolkitConfig();
|
|
383
|
+
}
|
|
385
384
|
);
|
|
386
385
|
};
|
|
387
386
|
|
package/Application/Localize.ts
CHANGED
|
@@ -17,10 +17,6 @@ class Localize {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
get getCurrentLanguage() {
|
|
21
|
-
return this.currentLanguage;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
20
|
translate(key: string) {
|
|
25
21
|
return this.assets[this.currentLanguage]?.[key] || key;
|
|
26
22
|
}
|
|
@@ -30,10 +26,7 @@ class Localize {
|
|
|
30
26
|
}
|
|
31
27
|
|
|
32
28
|
addTranslations(translations: LocalizationObject) {
|
|
33
|
-
this.assets =
|
|
34
|
-
vi: {...translations?.vi, ...this.assets.vi},
|
|
35
|
-
en: {...translations?.en, ...this.assets.en},
|
|
36
|
-
};
|
|
29
|
+
this.assets = translations;
|
|
37
30
|
}
|
|
38
31
|
|
|
39
32
|
setLanguage(language: 'en' | 'vi') {
|
package/Application/Navigator.ts
CHANGED
|
@@ -58,79 +58,49 @@ class Navigator {
|
|
|
58
58
|
* push new stack screen
|
|
59
59
|
* @param params
|
|
60
60
|
*/
|
|
61
|
-
push = (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.validateRefAndRunAction({
|
|
66
|
-
action: navigationRef => {
|
|
67
|
-
navigationRef.dispatch(StackActions.push('Stack', params));
|
|
68
|
-
},
|
|
69
|
-
callback,
|
|
70
|
-
});
|
|
61
|
+
push = (params: ScreenParams) => {
|
|
62
|
+
if (this.isReady.current) {
|
|
63
|
+
this.ref.current?.dispatch?.(StackActions.push('Stack', params));
|
|
64
|
+
}
|
|
71
65
|
};
|
|
72
66
|
|
|
73
67
|
/**
|
|
74
68
|
* replace current screen with new screen
|
|
75
69
|
* @param params
|
|
76
70
|
*/
|
|
77
|
-
replace = (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this.validateRefAndRunAction({
|
|
82
|
-
action: navigationRef => {
|
|
83
|
-
navigationRef.dispatch(StackActions.replace('Stack', params));
|
|
84
|
-
},
|
|
85
|
-
callback,
|
|
86
|
-
});
|
|
71
|
+
replace = (params: ScreenParams) => {
|
|
72
|
+
if (this.isReady.current) {
|
|
73
|
+
this.ref.current?.dispatch?.(StackActions.replace('Stack', params));
|
|
74
|
+
}
|
|
87
75
|
};
|
|
88
76
|
/**
|
|
89
77
|
* pop to dismiss a screen
|
|
90
78
|
* @param count
|
|
91
79
|
*/
|
|
92
|
-
pop = (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
this.validateRefAndRunAction({
|
|
97
|
-
action: navigationRef => {
|
|
98
|
-
navigationRef.dispatch(StackActions.pop(count ?? 1));
|
|
99
|
-
},
|
|
100
|
-
callback,
|
|
101
|
-
});
|
|
80
|
+
pop = (count?: number) => {
|
|
81
|
+
if (this.isReady.current) {
|
|
82
|
+
this.ref.current?.dispatch?.(StackActions.pop(count ?? 1));
|
|
83
|
+
}
|
|
102
84
|
};
|
|
103
85
|
|
|
104
86
|
/**
|
|
105
87
|
* present a new screen, show from bottom iOS
|
|
106
88
|
* @param params
|
|
107
89
|
*/
|
|
108
|
-
present = (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
this.validateRefAndRunAction({
|
|
113
|
-
action: navigationRef => {
|
|
114
|
-
navigationRef.dispatch(StackActions.push('Dialog', params));
|
|
115
|
-
},
|
|
116
|
-
callback,
|
|
117
|
-
});
|
|
90
|
+
present = (params: ScreenParams) => {
|
|
91
|
+
if (this.isReady.current) {
|
|
92
|
+
this.ref.current?.dispatch?.(StackActions.push('Dialog', params));
|
|
93
|
+
}
|
|
118
94
|
};
|
|
119
95
|
|
|
120
96
|
/**
|
|
121
97
|
* show a modal popup
|
|
122
98
|
* @param params
|
|
123
99
|
*/
|
|
124
|
-
showModal = (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.validateRefAndRunAction({
|
|
129
|
-
action: navigationRef => {
|
|
130
|
-
navigationRef.dispatch(StackActions.push('Modal', params));
|
|
131
|
-
},
|
|
132
|
-
callback,
|
|
133
|
-
});
|
|
100
|
+
showModal = (params: ModalParams) => {
|
|
101
|
+
if (this.isReady.current) {
|
|
102
|
+
this.ref.current?.dispatch?.(StackActions.push('Modal', params));
|
|
103
|
+
}
|
|
134
104
|
};
|
|
135
105
|
|
|
136
106
|
/**
|
|
@@ -158,13 +128,10 @@ class Navigator {
|
|
|
158
128
|
/**
|
|
159
129
|
* pop all screen route
|
|
160
130
|
*/
|
|
161
|
-
popToTop = (
|
|
162
|
-
this.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
},
|
|
166
|
-
callback,
|
|
167
|
-
});
|
|
131
|
+
popToTop = () => {
|
|
132
|
+
if (this.isReady.current) {
|
|
133
|
+
this.ref.current?.dispatch?.(StackActions.popToTop());
|
|
134
|
+
}
|
|
168
135
|
};
|
|
169
136
|
|
|
170
137
|
/**
|
|
@@ -172,49 +139,36 @@ class Navigator {
|
|
|
172
139
|
* @param name
|
|
173
140
|
* @param params
|
|
174
141
|
*/
|
|
175
|
-
navigate = (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
name,
|
|
185
|
-
params,
|
|
186
|
-
})
|
|
187
|
-
);
|
|
188
|
-
},
|
|
189
|
-
callback,
|
|
190
|
-
});
|
|
142
|
+
navigate = (name: string, params: any) => {
|
|
143
|
+
if (this.isReady.current) {
|
|
144
|
+
this.ref.current?.dispatch?.(
|
|
145
|
+
CommonActions.navigate({
|
|
146
|
+
name,
|
|
147
|
+
params,
|
|
148
|
+
})
|
|
149
|
+
);
|
|
150
|
+
}
|
|
191
151
|
};
|
|
192
152
|
|
|
193
153
|
/**
|
|
194
154
|
* reset a navigation flow with new screen
|
|
195
155
|
* @param params
|
|
196
156
|
*/
|
|
197
|
-
reset = (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
],
|
|
213
|
-
})
|
|
214
|
-
);
|
|
215
|
-
},
|
|
216
|
-
callback,
|
|
217
|
-
});
|
|
157
|
+
reset = (params: ScreenParams) => {
|
|
158
|
+
if (this.isReady.current) {
|
|
159
|
+
this.ref.current?.dispatch?.(
|
|
160
|
+
CommonActions.reset({
|
|
161
|
+
index: 0,
|
|
162
|
+
routes: [
|
|
163
|
+
{
|
|
164
|
+
name: 'Stack',
|
|
165
|
+
key: `Stack_${new Date().getTime()}`,
|
|
166
|
+
params,
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
})
|
|
170
|
+
);
|
|
171
|
+
}
|
|
218
172
|
};
|
|
219
173
|
|
|
220
174
|
/**
|
package/Popup/PopupNotify.tsx
CHANGED
|
@@ -33,7 +33,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
33
33
|
* tracking
|
|
34
34
|
*/
|
|
35
35
|
useEffect(() => {
|
|
36
|
-
const routes
|
|
36
|
+
const routes = navigator?.ref.current?.getRootState()?.routes || [];
|
|
37
37
|
const routesLength = routes.length;
|
|
38
38
|
let screen_name = routes?.[0]?.params?.screen?.name;
|
|
39
39
|
if (routesLength > 1) {
|
package/Popup/PopupPromotion.tsx
CHANGED
|
@@ -19,7 +19,7 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
19
19
|
* tracking
|
|
20
20
|
*/
|
|
21
21
|
useEffect(() => {
|
|
22
|
-
const routes
|
|
22
|
+
const routes = navigator?.ref.current?.getRootState()?.routes || [];
|
|
23
23
|
const routesLength = routes.length;
|
|
24
24
|
let screen_name = routes?.[0]?.params?.screen?.name;
|
|
25
25
|
if (routesLength > 1) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.103.1-
|
|
3
|
+
"version": "0.103.1-optimize.0",
|
|
4
4
|
"description": "React Native Component Kits",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {},
|
|
@@ -39,8 +39,7 @@
|
|
|
39
39
|
"react-test-renderer": "17.0.1",
|
|
40
40
|
"typescript": "^4.0.3",
|
|
41
41
|
"@momo-platform/versions": "4.1.11",
|
|
42
|
-
"react-scanner": "^1.1.0"
|
|
43
|
-
"@types/color": "3.0.6"
|
|
42
|
+
"react-scanner": "^1.1.0"
|
|
44
43
|
},
|
|
45
44
|
"author": "@momo-kits/foundation",
|
|
46
45
|
"license": "ISC"
|