@momo-kits/foundation 0.103.1-beta.0 → 0.103.1-beta.1
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 -8
- package/Application/Navigator.ts +63 -151
- package/Application/types.ts +0 -17
- package/package.json +1 -1
- package/Application/constants.ts +0 -9
|
@@ -337,7 +337,6 @@ const HeaderRight: React.FC<any> = ({type, children, onLayout, ...props}) => {
|
|
|
337
337
|
const HeaderToolkitAction: React.FC<any> = ({
|
|
338
338
|
tintColor,
|
|
339
339
|
pinnedTool,
|
|
340
|
-
runtimeTools = [],
|
|
341
340
|
preventClose,
|
|
342
341
|
}) => {
|
|
343
342
|
const {navigator} = useContext(ApplicationContext);
|
|
@@ -374,13 +373,15 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
374
373
|
const onMore = () => {
|
|
375
374
|
onAction?.('onMore');
|
|
376
375
|
navigator?.maxApi?.dispatchFunction?.(
|
|
377
|
-
'
|
|
378
|
-
{
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
376
|
+
'showToolkit',
|
|
377
|
+
{
|
|
378
|
+
tools: miniContext?.toolkitConfig?.oldTools ?? [
|
|
379
|
+
'addFavorite',
|
|
380
|
+
'addShortcut',
|
|
381
|
+
'share',
|
|
382
|
+
],
|
|
383
|
+
},
|
|
384
|
+
() => {}
|
|
384
385
|
);
|
|
385
386
|
};
|
|
386
387
|
|
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/package.json
CHANGED