@momo-kits/foundation 0.81.41-beta.8 → 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 +65 -41
- package/Application/Navigator.ts +14 -0
- package/Application/utils.tsx +1 -1
- 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 ?? {};
|
|
@@ -427,8 +435,24 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor, pinnedTool}) => {
|
|
|
427
435
|
};
|
|
428
436
|
|
|
429
437
|
const onClose = () => {
|
|
430
|
-
|
|
431
|
-
|
|
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
|
+
}
|
|
432
456
|
};
|
|
433
457
|
|
|
434
458
|
const renderPinnedTool = () => {
|
package/Application/Navigator.ts
CHANGED
|
@@ -78,6 +78,20 @@ class Navigator {
|
|
|
78
78
|
this.ref.current.dispatch(StackActions.popToTop());
|
|
79
79
|
};
|
|
80
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
|
+
|
|
81
95
|
/**
|
|
82
96
|
* reset a navigation flow with new screen
|
|
83
97
|
* @param params
|
package/Application/utils.tsx
CHANGED
|
@@ -132,7 +132,7 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
132
132
|
headerRight: (props: any) => {
|
|
133
133
|
return (
|
|
134
134
|
<HeaderToolkitAction
|
|
135
|
-
preventBack={params.preventBack
|
|
135
|
+
preventBack={params.preventBack}
|
|
136
136
|
pinnedTool={params.pinnedTool}
|
|
137
137
|
{...props}
|
|
138
138
|
/>
|
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();
|