@momo-kits/foundation 0.81.41-beta.5 → 0.81.41-beta.9
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 +83 -69
- package/Application/Navigator.ts +14 -5
- package/Application/types.ts +1 -0
- package/Application/utils.tsx +15 -0
- package/Input/InputMoney.tsx +3 -1
- package/package.json +1 -1
|
@@ -173,53 +173,57 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
173
173
|
useEffect(() => {
|
|
174
174
|
const backHandler = BackHandler.addEventListener(
|
|
175
175
|
'hardwareBackPress',
|
|
176
|
-
|
|
176
|
+
goBackSafe,
|
|
177
177
|
);
|
|
178
178
|
|
|
179
179
|
return () => backHandler.remove();
|
|
180
180
|
}, []);
|
|
181
181
|
|
|
182
|
-
const
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
if (canGoBack) {
|
|
197
|
-
if (preventBack) {
|
|
198
|
-
navigator?.showModal({
|
|
199
|
-
screen: () => (
|
|
200
|
-
<PopupNotify
|
|
201
|
-
{...preventBack}
|
|
202
|
-
primary={{
|
|
203
|
-
title: preventBack.primary.title,
|
|
204
|
-
onPress: () => {
|
|
205
|
-
preventBack?.primary.onPress();
|
|
206
|
-
navigator?.ref.current?.goBack();
|
|
207
|
-
},
|
|
208
|
-
}}
|
|
209
|
-
/>
|
|
210
|
-
),
|
|
182
|
+
const goBackSafe = () => {
|
|
183
|
+
const goBack = () => {
|
|
184
|
+
const canGoBack = navigator?.ref.current?.canGoBack();
|
|
185
|
+
if (!canGoBack && navigator?.trackingInfo) {
|
|
186
|
+
const currentRoute = navigator?.ref?.current.getCurrentRoute();
|
|
187
|
+
navigator?.maxApi?.trackEvent?.('service_icon_clicked', {
|
|
188
|
+
feature_code: navigator.trackingInfo.code,
|
|
189
|
+
app_id: navigator.trackingInfo.appId,
|
|
190
|
+
miniapp_version: navigator.trackingInfo.buildNumber,
|
|
191
|
+
flow_partner_id: navigator.trackingInfo.flowPartnerId,
|
|
192
|
+
screen_name: currentRoute?.params?.screen?.name ?? currentRoute?.name,
|
|
193
|
+
trigger_id: '111154000000000000',
|
|
194
|
+
icon_name: 'back',
|
|
211
195
|
});
|
|
212
|
-
}
|
|
196
|
+
}
|
|
197
|
+
if (canGoBack) {
|
|
213
198
|
navigator?.ref.current?.goBack();
|
|
199
|
+
} else if (navigator?.maxApi) {
|
|
200
|
+
navigator?.maxApi?.dismiss(navigator.dismissData);
|
|
201
|
+
} else {
|
|
202
|
+
const currentTime = new Date().getTime();
|
|
203
|
+
const requestId = `navigationBackPress#${currentTime}`;
|
|
204
|
+
DeviceEventEmitter.emit('dismiss', {requestId});
|
|
214
205
|
}
|
|
215
|
-
|
|
216
|
-
|
|
206
|
+
onPressLeftHeader?.();
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
if (preventBack) {
|
|
210
|
+
navigator?.showModal({
|
|
211
|
+
screen: () => (
|
|
212
|
+
<PopupNotify
|
|
213
|
+
{...preventBack}
|
|
214
|
+
primary={{
|
|
215
|
+
title: preventBack.primary.title,
|
|
216
|
+
onPress: () => {
|
|
217
|
+
preventBack?.primary.onPress();
|
|
218
|
+
goBack();
|
|
219
|
+
},
|
|
220
|
+
}}
|
|
221
|
+
/>
|
|
222
|
+
),
|
|
223
|
+
});
|
|
217
224
|
} else {
|
|
218
|
-
|
|
219
|
-
const requestId = `navigationBackPress#${currentTime}`;
|
|
220
|
-
DeviceEventEmitter.emit('dismiss', {requestId});
|
|
225
|
+
goBack();
|
|
221
226
|
}
|
|
222
|
-
onPressLeftHeader?.();
|
|
223
227
|
return true;
|
|
224
228
|
};
|
|
225
229
|
|
|
@@ -228,7 +232,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
228
232
|
<NavigationButton
|
|
229
233
|
icon="ic_back"
|
|
230
234
|
tintColor={tintColor}
|
|
231
|
-
onPress={
|
|
235
|
+
onPress={goBackSafe}
|
|
232
236
|
accessibilityLabel={`${accessibilityLabel}Back`}
|
|
233
237
|
useBorder={useBorder}
|
|
234
238
|
/>
|
|
@@ -343,7 +347,11 @@ const HeaderRightAction: React.FC<any> = ({children, ...restProps}) => {
|
|
|
343
347
|
return <View style={styles.headerRightButton}>{renderAction()}</View>;
|
|
344
348
|
};
|
|
345
349
|
|
|
346
|
-
const HeaderToolkitAction: React.FC<any> = ({
|
|
350
|
+
const HeaderToolkitAction: React.FC<any> = ({
|
|
351
|
+
tintColor,
|
|
352
|
+
pinnedTool,
|
|
353
|
+
preventBack,
|
|
354
|
+
}) => {
|
|
347
355
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
348
356
|
const [toolConfig, setToolConfig] = useState<any>();
|
|
349
357
|
const {appCode, onAction} = toolConfig ?? {};
|
|
@@ -357,29 +365,21 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
|
|
|
357
365
|
if (navigator?.toolkitConfig) {
|
|
358
366
|
setToolConfig(navigator?.toolkitConfig);
|
|
359
367
|
} else {
|
|
360
|
-
navigator?.requestApi('
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
...config?.toolkitConfig?.customTools,
|
|
376
|
-
...config?.toolkitFeatureConfig,
|
|
377
|
-
],
|
|
378
|
-
appCode: config?.appCode,
|
|
379
|
-
});
|
|
380
|
-
},
|
|
381
|
-
);
|
|
382
|
-
}
|
|
368
|
+
navigator?.requestApi('getToolkitConfig', [undefined], (config: any) => {
|
|
369
|
+
navigator.toolkitConfig = {
|
|
370
|
+
configs: [
|
|
371
|
+
...config?.miniappTools?.customTools,
|
|
372
|
+
...config?.defaultTools,
|
|
373
|
+
],
|
|
374
|
+
appCode: config?.appCode,
|
|
375
|
+
};
|
|
376
|
+
setToolConfig({
|
|
377
|
+
configs: [
|
|
378
|
+
...config?.miniappTools?.customTools,
|
|
379
|
+
...config?.defaultTools,
|
|
380
|
+
],
|
|
381
|
+
appCode: config?.appCode,
|
|
382
|
+
});
|
|
383
383
|
});
|
|
384
384
|
}
|
|
385
385
|
}, []);
|
|
@@ -435,23 +435,37 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
|
|
|
435
435
|
};
|
|
436
436
|
|
|
437
437
|
const onClose = () => {
|
|
438
|
-
|
|
439
|
-
|
|
438
|
+
if (preventBack) {
|
|
439
|
+
navigator?.showModal({
|
|
440
|
+
screen: () => (
|
|
441
|
+
<PopupNotify
|
|
442
|
+
{...preventBack}
|
|
443
|
+
primary={{
|
|
444
|
+
title: preventBack.primary.title,
|
|
445
|
+
onPress: () => {
|
|
446
|
+
preventBack?.primary.onPress();
|
|
447
|
+
navigator?.requestApi('dismiss', undefined, undefined);
|
|
448
|
+
},
|
|
449
|
+
}}
|
|
450
|
+
/>
|
|
451
|
+
),
|
|
452
|
+
});
|
|
453
|
+
} else {
|
|
454
|
+
navigator?.requestApi('dismiss', undefined, undefined);
|
|
455
|
+
}
|
|
440
456
|
};
|
|
441
457
|
|
|
442
458
|
const renderPinnedTool = () => {
|
|
443
|
-
const pinTool = toolConfig?.configs?.find(
|
|
444
|
-
(i: any) => i.key === navigator?.pinnedTool,
|
|
445
|
-
);
|
|
459
|
+
const pinTool = toolConfig?.configs?.find((i: any) => i.key === pinnedTool);
|
|
446
460
|
const {icon} = pinTool || '';
|
|
447
|
-
if (pinTool &&
|
|
461
|
+
if (pinTool && pinnedTool)
|
|
448
462
|
return (
|
|
449
463
|
<NavigationButton
|
|
450
464
|
accessibilityLabel={'UtilityTool'}
|
|
451
465
|
icon={icon as string}
|
|
452
466
|
tintColor={tintColor}
|
|
453
467
|
onPress={() => {
|
|
454
|
-
navigator?.toolkitCallback?.(
|
|
468
|
+
navigator?.toolkitCallback?.(pinnedTool);
|
|
455
469
|
}}
|
|
456
470
|
/>
|
|
457
471
|
);
|
package/Application/Navigator.ts
CHANGED
|
@@ -13,7 +13,6 @@ class Navigator {
|
|
|
13
13
|
maxApi?: any;
|
|
14
14
|
trackingInfo?: TrackingInfo;
|
|
15
15
|
dismissData?: any;
|
|
16
|
-
pinnedTool?: string;
|
|
17
16
|
toolkitCallback?: (item: any) => void;
|
|
18
17
|
|
|
19
18
|
constructor(navigation: any) {
|
|
@@ -79,6 +78,20 @@ class Navigator {
|
|
|
79
78
|
this.ref.current.dispatch(StackActions.popToTop());
|
|
80
79
|
};
|
|
81
80
|
|
|
81
|
+
/**
|
|
82
|
+
* navigate
|
|
83
|
+
* @param name
|
|
84
|
+
* @param params
|
|
85
|
+
*/
|
|
86
|
+
navigate = (name: string, params: any) => {
|
|
87
|
+
this.ref.current.dispatch(
|
|
88
|
+
CommonActions.navigate({
|
|
89
|
+
name,
|
|
90
|
+
params,
|
|
91
|
+
}),
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
82
95
|
/**
|
|
83
96
|
* reset a navigation flow with new screen
|
|
84
97
|
* @param params
|
|
@@ -110,10 +123,6 @@ class Navigator {
|
|
|
110
123
|
}
|
|
111
124
|
};
|
|
112
125
|
|
|
113
|
-
setPinnedTool = (key: string) => {
|
|
114
|
-
this.pinnedTool = key;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
126
|
setToolkitCallback = (
|
|
118
127
|
callback: (item: {key: string; action: string}) => void,
|
|
119
128
|
) => {
|
package/Application/types.ts
CHANGED
|
@@ -138,6 +138,7 @@ export interface NavigationOptions extends StackNavigationOptions {
|
|
|
138
138
|
surface?: boolean;
|
|
139
139
|
hiddenBack?: boolean;
|
|
140
140
|
customTitle?: TitleCustomProps;
|
|
141
|
+
pinnedTool?: string;
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
export interface HeaderBackProps extends NavigationButtonProps {
|
package/Application/utils.tsx
CHANGED
|
@@ -126,6 +126,21 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
if (params.pinnedTool) {
|
|
130
|
+
options = {
|
|
131
|
+
...options,
|
|
132
|
+
headerRight: (props: any) => {
|
|
133
|
+
return (
|
|
134
|
+
<HeaderToolkitAction
|
|
135
|
+
preventBack={params.preventBack}
|
|
136
|
+
pinnedTool={params.pinnedTool}
|
|
137
|
+
{...props}
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
129
144
|
return {
|
|
130
145
|
...params,
|
|
131
146
|
...options,
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -45,7 +45,9 @@ const InputMoney = forwardRef(
|
|
|
45
45
|
return formatNumberToMoney(valueFormat, 'đ');
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
const [value, setValue] = useState(
|
|
48
|
+
const [value, setValue] = useState(
|
|
49
|
+
defaultValue ? validateText(defaultValue) : '',
|
|
50
|
+
);
|
|
49
51
|
|
|
50
52
|
const onClearText = () => {
|
|
51
53
|
inputRef?.current?.clear();
|