@momo-kits/foundation 0.81.38-api.2 → 0.81.38-api.3
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 +42 -38
- package/Application/Navigator.ts +14 -0
- package/Input/InputMoney.tsx +3 -1
- package/package.json +4 -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
|
/>
|
package/Application/Navigator.ts
CHANGED
|
@@ -77,6 +77,20 @@ class Navigator {
|
|
|
77
77
|
this.ref.current.dispatch(StackActions.popToTop());
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* navigate
|
|
82
|
+
* @param name
|
|
83
|
+
* @param params
|
|
84
|
+
*/
|
|
85
|
+
navigate = (name: string, params: any) => {
|
|
86
|
+
this.ref.current.dispatch(
|
|
87
|
+
CommonActions.navigate({
|
|
88
|
+
name,
|
|
89
|
+
params,
|
|
90
|
+
}),
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
80
94
|
/**
|
|
81
95
|
* reset a navigation flow with new screen
|
|
82
96
|
* @param params
|
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();
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.81.38-api.
|
|
3
|
+
"version": "0.81.38-api.3",
|
|
4
4
|
"description": "React Native Component Kits",
|
|
5
5
|
"main": "index.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"postinstall": "node verify.js"
|
|
8
|
+
},
|
|
6
9
|
"keywords": [
|
|
7
10
|
"@momo-kits/foundation"
|
|
8
11
|
],
|