@momo-kits/foundation 0.103.1-optimize.9 → 0.103.2
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/Components.tsx +9 -10
- package/Application/NavigationContainer.tsx +2 -1
- package/Application/Navigator.ts +63 -151
- package/Application/types.ts +0 -17
- package/Layout/styles.ts +0 -1
- package/Popup/PopupNotify.tsx +1 -1
- package/Popup/PopupPromotion.tsx +1 -1
- package/index.ts +7 -0
- package/package.json +3 -1
- package/Application/constants.ts +0 -9
|
@@ -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
|
|
|
@@ -13,12 +13,13 @@ import {getDialogOptions, getModalOptions, getStackOptions} from './utils';
|
|
|
13
13
|
import {NavigationContainerProps} from './types';
|
|
14
14
|
import {ApplicationContext} from './index';
|
|
15
15
|
import Localize from './Localize';
|
|
16
|
+
import {defaultTheme} from '../Consts';
|
|
16
17
|
|
|
17
18
|
const Stack = createStackNavigator();
|
|
18
19
|
|
|
19
20
|
const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
20
21
|
screen,
|
|
21
|
-
theme,
|
|
22
|
+
theme = defaultTheme,
|
|
22
23
|
options,
|
|
23
24
|
maxApi,
|
|
24
25
|
initialParams,
|
package/Application/Navigator.ts
CHANGED
|
@@ -1,170 +1,95 @@
|
|
|
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
|
|
10
|
+
ref?: any;
|
|
11
|
+
isReady?: any;
|
|
22
12
|
toolkitConfig?: HeaderToolkitProps;
|
|
23
13
|
maxApi?: any;
|
|
24
|
-
dismissData?:
|
|
14
|
+
dismissData?: any;
|
|
25
15
|
toolkitCallback?: (key: string) => void;
|
|
26
16
|
|
|
27
|
-
constructor(
|
|
28
|
-
navigation: React.RefObject<NavigationContainerRef>,
|
|
29
|
-
isReady: React.MutableRefObject<boolean>
|
|
30
|
-
) {
|
|
17
|
+
constructor(navigation: any, isReady: any) {
|
|
31
18
|
this.ref = navigation;
|
|
32
19
|
this.isReady = isReady;
|
|
33
20
|
}
|
|
34
21
|
|
|
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
22
|
/**
|
|
58
23
|
* push new stack screen
|
|
59
24
|
* @param params
|
|
60
25
|
*/
|
|
61
|
-
push = (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.validateRefAndRunAction({
|
|
66
|
-
action: navigationRef => {
|
|
67
|
-
navigationRef.dispatch(StackActions.push('Stack', params));
|
|
68
|
-
},
|
|
69
|
-
callback,
|
|
70
|
-
});
|
|
26
|
+
push = (params: ScreenParams) => {
|
|
27
|
+
if (this.isReady.current) {
|
|
28
|
+
this.ref.current?.dispatch?.(StackActions.push('Stack', params));
|
|
29
|
+
}
|
|
71
30
|
};
|
|
72
31
|
|
|
73
32
|
/**
|
|
74
33
|
* replace current screen with new screen
|
|
75
34
|
* @param params
|
|
76
35
|
*/
|
|
77
|
-
replace = (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this.validateRefAndRunAction({
|
|
82
|
-
action: navigationRef => {
|
|
83
|
-
navigationRef.dispatch(StackActions.replace('Stack', params));
|
|
84
|
-
},
|
|
85
|
-
callback,
|
|
86
|
-
});
|
|
36
|
+
replace = (params: ScreenParams) => {
|
|
37
|
+
if (this.isReady.current) {
|
|
38
|
+
this.ref.current?.dispatch?.(StackActions.replace('Stack', params));
|
|
39
|
+
}
|
|
87
40
|
};
|
|
88
41
|
/**
|
|
89
42
|
* pop to dismiss a screen
|
|
90
43
|
* @param count
|
|
91
44
|
*/
|
|
92
|
-
pop = (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
this.validateRefAndRunAction({
|
|
97
|
-
action: navigationRef => {
|
|
98
|
-
navigationRef.dispatch(StackActions.pop(count ?? 1));
|
|
99
|
-
},
|
|
100
|
-
callback,
|
|
101
|
-
});
|
|
45
|
+
pop = (count?: number) => {
|
|
46
|
+
if (this.isReady.current) {
|
|
47
|
+
this.ref.current?.dispatch?.(StackActions.pop(count ?? 1));
|
|
48
|
+
}
|
|
102
49
|
};
|
|
103
50
|
|
|
104
51
|
/**
|
|
105
52
|
* present a new screen, show from bottom iOS
|
|
106
53
|
* @param params
|
|
107
54
|
*/
|
|
108
|
-
present = (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
this.validateRefAndRunAction({
|
|
113
|
-
action: navigationRef => {
|
|
114
|
-
navigationRef.dispatch(StackActions.push('Dialog', params));
|
|
115
|
-
},
|
|
116
|
-
callback,
|
|
117
|
-
});
|
|
55
|
+
present = (params: ScreenParams) => {
|
|
56
|
+
if (this.isReady.current) {
|
|
57
|
+
this.ref.current?.dispatch?.(StackActions.push('Dialog', params));
|
|
58
|
+
}
|
|
118
59
|
};
|
|
119
60
|
|
|
120
61
|
/**
|
|
121
62
|
* show a modal popup
|
|
122
63
|
* @param params
|
|
123
64
|
*/
|
|
124
|
-
showModal = (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.validateRefAndRunAction({
|
|
129
|
-
action: navigationRef => {
|
|
130
|
-
navigationRef.dispatch(StackActions.push('Modal', params));
|
|
131
|
-
},
|
|
132
|
-
callback,
|
|
133
|
-
});
|
|
65
|
+
showModal = (params: ModalParams) => {
|
|
66
|
+
if (this.isReady.current) {
|
|
67
|
+
this.ref.current?.dispatch?.(StackActions.push('Modal', params));
|
|
68
|
+
}
|
|
134
69
|
};
|
|
135
70
|
|
|
136
71
|
/**
|
|
137
72
|
* show a bottom sheet
|
|
138
73
|
* @param params
|
|
139
|
-
* @param callback
|
|
140
74
|
*/
|
|
141
|
-
showBottomSheet = (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
isBottomSheet: true,
|
|
151
|
-
})
|
|
152
|
-
);
|
|
153
|
-
},
|
|
154
|
-
callback,
|
|
155
|
-
});
|
|
75
|
+
showBottomSheet = (params: BottomSheetParams) => {
|
|
76
|
+
if (this.isReady.current) {
|
|
77
|
+
this.ref.current?.dispatch?.(
|
|
78
|
+
StackActions.push('Modal', {
|
|
79
|
+
...params,
|
|
80
|
+
isBottomSheet: true,
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
}
|
|
156
84
|
};
|
|
157
85
|
|
|
158
86
|
/**
|
|
159
87
|
* pop all screen route
|
|
160
88
|
*/
|
|
161
|
-
popToTop = (
|
|
162
|
-
this.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
},
|
|
166
|
-
callback,
|
|
167
|
-
});
|
|
89
|
+
popToTop = () => {
|
|
90
|
+
if (this.isReady.current) {
|
|
91
|
+
this.ref.current?.dispatch?.(StackActions.popToTop());
|
|
92
|
+
}
|
|
168
93
|
};
|
|
169
94
|
|
|
170
95
|
/**
|
|
@@ -172,56 +97,43 @@ class Navigator {
|
|
|
172
97
|
* @param name
|
|
173
98
|
* @param params
|
|
174
99
|
*/
|
|
175
|
-
navigate = (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
name,
|
|
185
|
-
params,
|
|
186
|
-
})
|
|
187
|
-
);
|
|
188
|
-
},
|
|
189
|
-
callback,
|
|
190
|
-
});
|
|
100
|
+
navigate = (name: string, params: any) => {
|
|
101
|
+
if (this.isReady.current) {
|
|
102
|
+
this.ref.current?.dispatch?.(
|
|
103
|
+
CommonActions.navigate({
|
|
104
|
+
name,
|
|
105
|
+
params,
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
}
|
|
191
109
|
};
|
|
192
110
|
|
|
193
111
|
/**
|
|
194
112
|
* reset a navigation flow with new screen
|
|
195
113
|
* @param params
|
|
196
114
|
*/
|
|
197
|
-
reset = (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
],
|
|
213
|
-
})
|
|
214
|
-
);
|
|
215
|
-
},
|
|
216
|
-
callback,
|
|
217
|
-
});
|
|
115
|
+
reset = (params: ScreenParams) => {
|
|
116
|
+
if (this.isReady.current) {
|
|
117
|
+
this.ref.current?.dispatch?.(
|
|
118
|
+
CommonActions.reset({
|
|
119
|
+
index: 0,
|
|
120
|
+
routes: [
|
|
121
|
+
{
|
|
122
|
+
name: 'Stack',
|
|
123
|
+
key: `Stack_${new Date().getTime()}`,
|
|
124
|
+
params,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
})
|
|
128
|
+
);
|
|
129
|
+
}
|
|
218
130
|
};
|
|
219
131
|
|
|
220
132
|
/**
|
|
221
133
|
* dismiss a feature data
|
|
222
134
|
* @param data
|
|
223
135
|
*/
|
|
224
|
-
setDismissData = (data:
|
|
136
|
+
setDismissData = (data: any) => {
|
|
225
137
|
this.dismissData = data;
|
|
226
138
|
};
|
|
227
139
|
|
package/Application/types.ts
CHANGED
|
@@ -6,10 +6,6 @@ import {PopupNotifyProps} from '../Popup/types';
|
|
|
6
6
|
import Localize from './Localize';
|
|
7
7
|
import Navigation from './Navigation';
|
|
8
8
|
import Navigator from './Navigator';
|
|
9
|
-
import {
|
|
10
|
-
NavigationActionCallbackErrorEnum,
|
|
11
|
-
NavigationActionCallbackStatusEnum,
|
|
12
|
-
} from './constants';
|
|
13
9
|
|
|
14
10
|
type Screen = React.ComponentType<NavigationScreenProps>;
|
|
15
11
|
|
|
@@ -247,16 +243,3 @@ export type AnimatedHeader = {
|
|
|
247
243
|
component?: (props?: any) => React.ReactElement;
|
|
248
244
|
headerTitle?: (props?: any) => React.ReactElement;
|
|
249
245
|
};
|
|
250
|
-
|
|
251
|
-
type NavigatorActionSuccessCallbackType = {
|
|
252
|
-
status: NavigationActionCallbackStatusEnum.Success;
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
type NavigatorActionFailCallbackType = {
|
|
256
|
-
status: NavigationActionCallbackStatusEnum.Failed;
|
|
257
|
-
type: NavigationActionCallbackErrorEnum;
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
export type NavigatorCallbackParamsType =
|
|
261
|
-
| NavigatorActionSuccessCallbackType
|
|
262
|
-
| NavigatorActionFailCallbackType;
|
package/Layout/styles.ts
CHANGED
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/index.ts
CHANGED
|
@@ -49,3 +49,10 @@ export * from './Title';
|
|
|
49
49
|
export * from './Title/types';
|
|
50
50
|
export * from './Badge';
|
|
51
51
|
export * from './Badge/types';
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* export trick for keep old mini app working
|
|
55
|
+
* @deprecated
|
|
56
|
+
*/
|
|
57
|
+
export * from 'react-native-modalize';
|
|
58
|
+
export * from '@gorhom/bottom-sheet';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.103.
|
|
3
|
+
"version": "0.103.2",
|
|
4
4
|
"description": "React Native Component Kits",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {},
|
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
"@momo-kits/foundation"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
+
"@gorhom/bottom-sheet": "2.4.1",
|
|
11
12
|
"react-native-safe-area-context": "3.1.4",
|
|
12
13
|
"react-native-linear-gradient": "2.8.3",
|
|
13
14
|
"react-native-gesture-handler": "1.10.3",
|
|
15
|
+
"react-native-modalize": "2.1.1",
|
|
14
16
|
"react-native-fast-image": "8.1.5",
|
|
15
17
|
"@react-navigation/bottom-tabs": "https://gitlab.mservice.com.vn/momo-platform/react-native-bottom-tabs.git",
|
|
16
18
|
"@react-navigation/core": "5.16.1",
|