@momo-kits/foundation 0.168.1-beta.39 → 0.168.1-beta.40
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/BottomSheet.tsx +398 -86
- package/Application/BottomTab/BottomTabBar.tsx +275 -215
- package/Application/BottomTab/CustomBottomTabItem.tsx +107 -131
- package/Application/BottomTab/DuoBarCompression.tsx +28 -14
- package/Application/BottomTab/DuoTabBar.tsx +540 -32
- package/Application/BottomTab/TabBarIcon.tsx +72 -146
- package/Application/BottomTab/index.tsx +353 -89
- package/Application/BottomTab/useLiquidSelection.ts +374 -0
- package/Application/Components/BackgroundImageView.tsx +0 -4
- package/Application/Components/DuoGlassBackground.tsx +5 -7
- package/Application/Components/HeaderAnimated.tsx +13 -41
- package/Application/Components/HeaderBackground.tsx +3 -20
- package/Application/Components/HeaderExtendHeader.tsx +46 -66
- package/Application/Components/HeaderLeft.tsx +18 -5
- package/Application/Components/HeaderRight.tsx +529 -8
- package/Application/Components/HeaderTitle.tsx +579 -16
- package/Application/Components/NavigationButton.tsx +11 -18
- package/Application/Components/SearchHeader.tsx +18 -38
- package/Application/Localize.ts +0 -7
- package/Application/ModalScreen.tsx +18 -41
- package/Application/Navigation.ts +17 -15
- package/Application/NavigationContainer.tsx +21 -23
- package/Application/Navigator.ts +48 -20
- package/Application/ScaleSizeProvider.tsx +6 -13
- package/Application/StackScreen.tsx +172 -27
- package/Application/TooltipPortal.tsx +5 -12
- package/Application/WidgetContainer.tsx +7 -20
- package/Application/device.ts +52 -0
- package/Application/index.ts +1 -23
- package/Application/types.ts +242 -17
- package/Application/utils.tsx +493 -0
- package/Badge/Badge.tsx +0 -5
- package/Badge/BadgeDot.tsx +0 -1
- package/Badge/BadgeDotAnimation.tsx +7 -15
- package/Badge/BadgeRibbon.tsx +39 -47
- package/Badge/Shape.tsx +0 -2
- package/Badge/styles.ts +0 -2
- package/Badge/types.ts +2 -2
- package/Button/index.tsx +152 -21
- package/Button/styles.ts +1 -1
- package/CheckBox/index.tsx +6 -5
- package/Consts/theme.ts +10 -10
- package/Context/index.ts +1 -5
- package/Divider/DashDivider.tsx +11 -11
- package/Divider/index.tsx +7 -21
- package/FoundationList/index.tsx +0 -4
- package/Icon/index.tsx +6 -6
- package/Icon/types.ts +1 -1
- package/IconButton/index.tsx +12 -4
- package/Image/index.tsx +7 -9
- package/Input/Input.tsx +12 -10
- package/Input/InputDropDown.tsx +13 -10
- package/Input/InputMoney.tsx +152 -45
- package/Input/InputOTP.tsx +34 -36
- package/Input/InputPhoneNumber.tsx +5 -8
- package/Input/InputSearch.tsx +111 -19
- package/Input/InputTextArea.tsx +5 -5
- package/Input/SystemTextInput.tsx +2 -7
- package/Input/TextTyping.tsx +0 -4
- package/Input/common.tsx +17 -31
- package/Input/index.tsx +21 -24
- package/Input/styles.ts +5 -25
- package/Input/utils.ts +12 -14
- package/Layout/Card.tsx +4 -7
- package/Layout/FloatingButton.tsx +21 -26
- package/Layout/Item.tsx +2 -6
- package/Layout/ItemList.tsx +7 -9
- package/Layout/ItemSectionList.tsx +1 -2
- package/Layout/ReservedRegions.tsx +17 -34
- package/Layout/Screen.tsx +696 -122
- package/Layout/Section.tsx +7 -9
- package/Layout/TrackingScope.tsx +0 -1
- package/Layout/index.ts +4 -10
- package/Layout/styles.ts +0 -2
- package/Layout/types.ts +4 -2
- package/Layout/utils.ts +181 -40
- package/Loader/DotLoader.tsx +3 -11
- package/Loader/Loader.tsx +0 -4
- package/Loader/ProgressBar.tsx +6 -3
- package/Loader/Spinner.tsx +3 -11
- package/Loader/styles.ts +0 -4
- package/Loader/utils.ts +7 -11
- package/Pagination/Dot.tsx +0 -4
- package/Pagination/PaginationDot.tsx +0 -1
- package/Pagination/PaginationNumber.tsx +3 -5
- package/Pagination/PaginationScroll.tsx +0 -5
- package/Pagination/PaginationWhiteDot.tsx +0 -1
- package/Pagination/index.tsx +0 -4
- package/Pagination/types.ts +2 -2
- package/Popup/PopupNotify.tsx +102 -94
- package/Popup/PopupPromotion.tsx +11 -9
- package/Popup/types.ts +4 -11
- package/Popup/utils.ts +18 -50
- package/Radio/index.tsx +10 -6
- package/Radio/styles.ts +0 -6
- package/Skeleton/index.tsx +9 -9
- package/Skeleton/styles.ts +0 -1
- package/Switch/index.tsx +0 -1
- package/Tag/index.tsx +4 -8
- package/Tag/types.ts +3 -3
- package/Text/index.tsx +5 -25
- package/Text/styles.ts +1 -1
- package/Text/types.ts +6 -1
- package/Text/utils.ts +4 -20
- package/Title/index.tsx +40 -42
- package/Title/styles.ts +0 -6
- package/ViewBoundary/index.tsx +2 -4
- package/index.ts +6 -0
- package/package.json +1 -2
- package/Application/BottomSheet.hooks.ts +0 -195
- package/Application/BottomSheet.parts.tsx +0 -157
- package/Application/BottomSheet.styles.ts +0 -43
- package/Application/BottomTab/ActiveIndicator.tsx +0 -91
- package/Application/BottomTab/BottomTabBar.styles.ts +0 -65
- package/Application/BottomTab/BottomTabInset.tsx +0 -18
- package/Application/BottomTab/CurvedContainer.tsx +0 -155
- package/Application/BottomTab/DuoRailTabBar.tsx +0 -223
- package/Application/BottomTab/DuoTabBar.styles.ts +0 -81
- package/Application/BottomTab/TabScreen.tsx +0 -160
- package/Application/BottomTab/metrics.ts +0 -164
- package/Application/BottomTab/tabItems.ts +0 -46
- package/Application/BottomTab/usePressLift.ts +0 -32
- package/Application/Components/HeaderRight.styles.ts +0 -146
- package/Application/Components/HeaderTitle.shared.ts +0 -44
- package/Application/Components/HeaderTitle.styles.ts +0 -125
- package/Application/Components/HeaderToolkitAction.tsx +0 -180
- package/Application/Components/SwipeBackHaptic.tsx +0 -95
- package/Application/Components/TitleJourney.tsx +0 -110
- package/Application/Components/TitleLocation.tsx +0 -73
- package/Application/Components/TitleUser.tsx +0 -304
- package/Application/Components/useToolkitActions.tsx +0 -218
- package/Application/ModalIconButton.tsx +0 -66
- package/Application/StackScreen.tracking.ts +0 -143
- package/Application/headerLayout.ts +0 -158
- package/Application/hooks.ts +0 -137
- package/Application/modalLayout.ts +0 -176
- package/Application/navigationOptions.tsx +0 -212
- package/Application/types.header.ts +0 -121
- package/Application/types.tabs.ts +0 -48
- package/Application/types.theme.ts +0 -87
- package/Application/utils.ts +0 -107
- package/Button/utils.ts +0 -133
- package/Input/InputMoneyView.tsx +0 -194
- package/Input/SearchTextTyping.tsx +0 -108
- package/Input/moneyUtils.ts +0 -23
- package/Layout/layoutMetrics.ts +0 -58
- package/Layout/layoutTypes.ts +0 -86
- package/Layout/screenContent.tsx +0 -92
- package/Layout/screenFooter.tsx +0 -63
- package/Layout/screenHeader.tsx +0 -321
- package/Layout/screenQuickReturn.tsx +0 -64
- package/Layout/screenScroll.ts +0 -107
- package/Layout/screenTypes.ts +0 -143
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import React, { useContext, useEffect, useLayoutEffect, useRef } from 'react';
|
|
2
|
-
import { InteractionManager } from 'react-native';
|
|
2
|
+
import { Alert, InteractionManager } from 'react-native';
|
|
3
3
|
import { useHeaderHeight } from '@react-navigation/elements';
|
|
4
4
|
import { ScreenTrackingParams } from './types';
|
|
5
5
|
import Navigation from './Navigation';
|
|
6
6
|
import { ApplicationContext, MiniAppContext, ScreenContext } from '../Context';
|
|
7
|
-
import {
|
|
8
|
-
import { useAppState } from './
|
|
9
|
-
import { createScreenTracking } from './StackScreen.tracking';
|
|
7
|
+
import { version } from '../package.json';
|
|
8
|
+
import { SwipeBackHaptic, useAppState } from './utils';
|
|
10
9
|
import { TooltipPortalHost, TooltipPortalProvider } from './TooltipPortal';
|
|
11
|
-
import { useHeaderFrameOptions } from './headerLayout';
|
|
12
10
|
|
|
13
11
|
const runAfterInteractions = InteractionManager.runAfterInteractions;
|
|
14
12
|
|
|
15
13
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* container for stack screen
|
|
15
|
+
* @param props
|
|
16
|
+
* @constructor
|
|
18
17
|
*/
|
|
19
18
|
const StackScreen: React.FC<any> = props => {
|
|
20
19
|
const { navigator } = useContext(ApplicationContext);
|
|
@@ -52,7 +51,6 @@ const StackScreen: React.FC<any> = props => {
|
|
|
52
51
|
const navigation = useRef(new Navigation(props.navigation, context)).current;
|
|
53
52
|
const heightHeader = useHeaderHeight();
|
|
54
53
|
const { isBackgroundToForeground } = useAppState();
|
|
55
|
-
const headerFrameOptions = useHeaderFrameOptions(options?.contentLayout);
|
|
56
54
|
|
|
57
55
|
const data = {
|
|
58
56
|
...initialParams,
|
|
@@ -65,19 +63,18 @@ const StackScreen: React.FC<any> = props => {
|
|
|
65
63
|
|
|
66
64
|
const screenName = Component?.name || Component?.type?.name || 'Invalid';
|
|
67
65
|
|
|
66
|
+
/**
|
|
67
|
+
* set options for screen
|
|
68
|
+
*/
|
|
68
69
|
useLayoutEffect(() => {
|
|
69
70
|
if (options) {
|
|
70
71
|
navigation.setOptions(options);
|
|
71
72
|
}
|
|
72
73
|
}, [navigation, options]);
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
navigation.instance.setOptions(headerFrameOptions);
|
|
78
|
-
}
|
|
79
|
-
}, [navigation, headerFrameOptions]);
|
|
80
|
-
|
|
75
|
+
/**
|
|
76
|
+
* tracking for screen
|
|
77
|
+
*/
|
|
81
78
|
useEffect(() => {
|
|
82
79
|
let focusScreen: any;
|
|
83
80
|
let onFocusApp: any;
|
|
@@ -151,7 +148,6 @@ const StackScreen: React.FC<any> = props => {
|
|
|
151
148
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
152
149
|
}, []);
|
|
153
150
|
|
|
154
|
-
/** Reports a navigation to this screen: `back` if it was shown before. */
|
|
155
151
|
const onScreenNavigated = (pre: string, current: string) => {
|
|
156
152
|
if (!isBackgroundToForeground) {
|
|
157
153
|
const item: any = {
|
|
@@ -169,6 +165,9 @@ const StackScreen: React.FC<any> = props => {
|
|
|
169
165
|
|
|
170
166
|
tracking.current.mounted = true;
|
|
171
167
|
|
|
168
|
+
/**
|
|
169
|
+
* debug toast
|
|
170
|
+
*/
|
|
172
171
|
navigator?.maxApi?.showToastDebug?.({
|
|
173
172
|
appId: context.appId,
|
|
174
173
|
message: `${screenName} screen_navigated`,
|
|
@@ -177,12 +176,140 @@ const StackScreen: React.FC<any> = props => {
|
|
|
177
176
|
}
|
|
178
177
|
};
|
|
179
178
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
179
|
+
/**
|
|
180
|
+
* tracking for screen load
|
|
181
|
+
*/
|
|
182
|
+
const onScreenLoad = () => {
|
|
183
|
+
if (!tracking.current?.releaseLoad) {
|
|
184
|
+
let timeLoad = tracking.current.timeLoad;
|
|
185
|
+
if (timeLoad === 0) {
|
|
186
|
+
timeLoad = tracking.current.endTime - tracking.current.startTime;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
context?.autoTracking?.({
|
|
190
|
+
...context,
|
|
191
|
+
screenName,
|
|
192
|
+
componentName: 'Screen',
|
|
193
|
+
state: 'load',
|
|
194
|
+
duration: timeLoad,
|
|
195
|
+
widgets: tracking.current.widgets,
|
|
196
|
+
params: tracking.current.params,
|
|
197
|
+
version: version,
|
|
198
|
+
lastElement: tracking.current.lastElement,
|
|
199
|
+
});
|
|
200
|
+
navigator?.maxApi?.stopTrace?.(
|
|
201
|
+
tracking.current.traceIdLoad,
|
|
202
|
+
{ value: timeLoad / 1000 },
|
|
203
|
+
null,
|
|
204
|
+
);
|
|
205
|
+
tracking.current.releaseLoad = true;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* debug
|
|
209
|
+
*/
|
|
210
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
211
|
+
appId: context.appId,
|
|
212
|
+
message: `${screenName} screen_load_time ${timeLoad}`,
|
|
213
|
+
type: 'ERROR',
|
|
214
|
+
});
|
|
215
|
+
if (
|
|
216
|
+
__DEV__ &&
|
|
217
|
+
tracking.current.lastElement?.children?.current?.length > 0
|
|
218
|
+
) {
|
|
219
|
+
Alert.alert(
|
|
220
|
+
`${screenName}- load ${timeLoad}ms`,
|
|
221
|
+
JSON.stringify(tracking.current.lastElement?.children?.current),
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* tracking for screen load
|
|
229
|
+
*/
|
|
230
|
+
const onScreenInteraction = () => {
|
|
231
|
+
if (!tracking.current?.releaseInteraction) {
|
|
232
|
+
let timeLoad = tracking.current.timeLoad;
|
|
233
|
+
if (timeLoad === 0) {
|
|
234
|
+
timeLoad = tracking.current.endTime - tracking.current.startTime;
|
|
235
|
+
}
|
|
236
|
+
if (tracking.current.timeInteraction === 0) {
|
|
237
|
+
tracking.current.timeInteraction = timeLoad;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
context?.autoTracking?.({
|
|
241
|
+
...context,
|
|
242
|
+
screenName,
|
|
243
|
+
componentName: 'Screen',
|
|
244
|
+
state: 'interaction',
|
|
245
|
+
duration: tracking.current.timeInteraction - timeLoad,
|
|
246
|
+
totalDuration: tracking.current.timeInteraction,
|
|
247
|
+
params: tracking.current.params,
|
|
248
|
+
version: version,
|
|
249
|
+
});
|
|
250
|
+
navigator?.maxApi?.stopTrace?.(
|
|
251
|
+
tracking.current.traceIdInteraction,
|
|
252
|
+
{ value: tracking.current.timeInteraction / 1000 },
|
|
253
|
+
null,
|
|
254
|
+
);
|
|
255
|
+
tracking.current.releaseInteraction = true;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* debug toast
|
|
259
|
+
*/
|
|
260
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
261
|
+
appId: context.appId,
|
|
262
|
+
message: `${screenName} screen_interaction_time ${tracking.current.timeInteraction}`,
|
|
263
|
+
type: 'ERROR',
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* tracking for first interaction by user
|
|
270
|
+
*/
|
|
271
|
+
const onFirstInteraction = (action: string) => {
|
|
272
|
+
if (!tracking.current?.releaseUserInteraction) {
|
|
273
|
+
const timeLoad = tracking.current.endTime - tracking.current.startTime;
|
|
274
|
+
context?.autoTracking?.({
|
|
275
|
+
...context,
|
|
276
|
+
screenName,
|
|
277
|
+
componentName: 'Screen',
|
|
278
|
+
state: 'interaction',
|
|
279
|
+
duration: timeLoad,
|
|
280
|
+
action,
|
|
281
|
+
});
|
|
282
|
+
tracking.current.releaseUserInteraction = true;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* debug
|
|
286
|
+
*/
|
|
287
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
288
|
+
appId: context.appId,
|
|
289
|
+
message: `${screenName} user_interaction ${timeLoad}`,
|
|
290
|
+
type: 'ERROR',
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* tracking for loading screen
|
|
297
|
+
*/
|
|
298
|
+
const onScreenLoading = () => {
|
|
299
|
+
const start = tracking.current.timeStartLoading;
|
|
300
|
+
const end = tracking.current.timeEndLoading;
|
|
301
|
+
if (!tracking.current?.releaseLoading && start && end && end > start) {
|
|
302
|
+
context?.autoTracking?.({
|
|
303
|
+
...context,
|
|
304
|
+
screenName,
|
|
305
|
+
componentName: 'Screen',
|
|
306
|
+
state: 'loading',
|
|
307
|
+
duration: end - start,
|
|
308
|
+
loadingType: 'skeleton',
|
|
309
|
+
});
|
|
310
|
+
tracking.current.releaseLoading = true;
|
|
311
|
+
}
|
|
312
|
+
};
|
|
186
313
|
|
|
187
314
|
return (
|
|
188
315
|
<ScreenContext.Provider
|
|
@@ -190,7 +317,9 @@ const StackScreen: React.FC<any> = props => {
|
|
|
190
317
|
screenName,
|
|
191
318
|
bottomTab: !!bottomTab,
|
|
192
319
|
onElementLoad: (item: any) => {
|
|
193
|
-
|
|
320
|
+
/**
|
|
321
|
+
* widget handle
|
|
322
|
+
*/
|
|
194
323
|
if (item?.componentName === 'Widget') {
|
|
195
324
|
const index = widgets.current.findIndex(
|
|
196
325
|
(element: any) => element.componentId === item.componentId,
|
|
@@ -214,25 +343,35 @@ const StackScreen: React.FC<any> = props => {
|
|
|
214
343
|
return;
|
|
215
344
|
}
|
|
216
345
|
|
|
346
|
+
/**
|
|
347
|
+
* tracking for element screen load
|
|
348
|
+
*/
|
|
217
349
|
clearTimeout(tracking.current.timeoutLoad);
|
|
218
350
|
tracking.current.endTime = Date.now();
|
|
219
351
|
tracking.current.timeoutInteraction?.cancel?.();
|
|
220
352
|
tracking.current.timeoutInteraction = runAfterInteractions(() => {
|
|
221
|
-
|
|
222
|
-
|
|
353
|
+
tracking.current.timeInteraction =
|
|
354
|
+
Date.now() - tracking.current.startTime;
|
|
223
355
|
});
|
|
224
356
|
|
|
357
|
+
/**
|
|
358
|
+
* support for debug last element
|
|
359
|
+
*/
|
|
225
360
|
if (item?.componentName) {
|
|
226
361
|
tracking.current.lastElement = item;
|
|
227
362
|
}
|
|
228
363
|
|
|
229
|
-
|
|
364
|
+
/**
|
|
365
|
+
* for stop tracking when user interaction
|
|
366
|
+
*/
|
|
230
367
|
if (item?.interaction) {
|
|
231
368
|
onScreenLoad();
|
|
232
369
|
onScreenInteraction();
|
|
233
370
|
onFirstInteraction(item?.action);
|
|
234
371
|
}
|
|
235
|
-
|
|
372
|
+
/**
|
|
373
|
+
* timeout for handle tracking screen
|
|
374
|
+
*/
|
|
236
375
|
tracking.current.timeoutLoad = setTimeout(() => {
|
|
237
376
|
const time = tracking.current.endTime - tracking.current.startTime;
|
|
238
377
|
tracking.current.widgets = widgets.current;
|
|
@@ -250,10 +389,16 @@ const StackScreen: React.FC<any> = props => {
|
|
|
250
389
|
tracking.current.timeStartLoading = Date.now();
|
|
251
390
|
}
|
|
252
391
|
|
|
392
|
+
/**
|
|
393
|
+
* tracking for loading screen
|
|
394
|
+
*/
|
|
253
395
|
if (!loading) {
|
|
254
396
|
tracking.current.timeEndLoading = Date.now();
|
|
255
397
|
}
|
|
256
398
|
|
|
399
|
+
/**
|
|
400
|
+
* timeout for handle tracking screen
|
|
401
|
+
*/
|
|
257
402
|
clearTimeout(tracking.current.timeoutLoading);
|
|
258
403
|
tracking.current.timeoutLoading = setTimeout(() => {
|
|
259
404
|
onScreenLoading();
|
|
@@ -21,14 +21,10 @@ const TooltipPortalContext = createContext<TooltipPortalContextValue | null>(
|
|
|
21
21
|
null,
|
|
22
22
|
);
|
|
23
23
|
|
|
24
|
-
/**
|
|
25
|
-
* Registry of tooltip contents that `TooltipPortalHost` renders in one layer
|
|
26
|
-
* above the screen, so tooltips aren't clipped by their anchor's parents.
|
|
27
|
-
*/
|
|
28
24
|
export const TooltipPortalProvider: React.FC<{ children: ReactNode }> = ({
|
|
29
25
|
children,
|
|
30
26
|
}) => {
|
|
31
|
-
//
|
|
27
|
+
// Use ref for synchronous updates + reducer for manual re-renders
|
|
32
28
|
const portalsRef = useRef<Map<string, ReactNode>>(new Map());
|
|
33
29
|
const hostRef = useRef<View>(null);
|
|
34
30
|
const [updateCounter, forceUpdate] = useReducer((x: number) => x + 1, 0);
|
|
@@ -36,15 +32,16 @@ export const TooltipPortalProvider: React.FC<{ children: ReactNode }> = ({
|
|
|
36
32
|
|
|
37
33
|
const register = useCallback((id: string, content: ReactNode) => {
|
|
38
34
|
portalsRef.current.set(id, content);
|
|
39
|
-
forceUpdate();
|
|
35
|
+
forceUpdate(); // Trigger re-render to show new content
|
|
40
36
|
}, []);
|
|
41
37
|
|
|
42
38
|
const unregister = useCallback((id: string, immediate = false) => {
|
|
43
39
|
const hasItem = portalsRef.current.has(id);
|
|
44
|
-
if (!hasItem) return;
|
|
40
|
+
if (!hasItem) return; // Already removed
|
|
45
41
|
|
|
46
42
|
portalsRef.current.delete(id);
|
|
47
43
|
|
|
44
|
+
// Clear any pending updates
|
|
48
45
|
if (pendingUpdateRef.current) {
|
|
49
46
|
clearTimeout(pendingUpdateRef.current);
|
|
50
47
|
pendingUpdateRef.current = null;
|
|
@@ -75,7 +72,6 @@ export const TooltipPortalProvider: React.FC<{ children: ReactNode }> = ({
|
|
|
75
72
|
);
|
|
76
73
|
};
|
|
77
74
|
|
|
78
|
-
/** Full-screen, touch-through layer that renders every registered tooltip. */
|
|
79
75
|
export const TooltipPortalHost: React.FC = () => {
|
|
80
76
|
const context = useContext(TooltipPortalContext);
|
|
81
77
|
|
|
@@ -99,10 +95,6 @@ export const TooltipPortalHost: React.FC = () => {
|
|
|
99
95
|
);
|
|
100
96
|
};
|
|
101
97
|
|
|
102
|
-
/**
|
|
103
|
-
* Tooltip portal API. Outside a provider it returns no-ops (and warns in dev)
|
|
104
|
-
* so a tooltip degrades instead of crashing.
|
|
105
|
-
*/
|
|
106
98
|
export const useTooltipPortal = () => {
|
|
107
99
|
const context = useContext(TooltipPortalContext);
|
|
108
100
|
|
|
@@ -112,6 +104,7 @@ export const useTooltipPortal = () => {
|
|
|
112
104
|
'useTooltipPortal must be used within TooltipPortalProvider. Tooltips may not appear correctly.',
|
|
113
105
|
);
|
|
114
106
|
}
|
|
107
|
+
// Return no-op functions if context is missing
|
|
115
108
|
return {
|
|
116
109
|
register: () => { },
|
|
117
110
|
unregister: () => { },
|
|
@@ -10,15 +10,13 @@ import {
|
|
|
10
10
|
NavigationContainerRef,
|
|
11
11
|
NavigationIndependentTree,
|
|
12
12
|
} from '@react-navigation/native';
|
|
13
|
-
import { getModalOptions } from './
|
|
14
|
-
import { isWhiteListDesignSystem } from './utils';
|
|
13
|
+
import { getModalOptions, isWhiteListDesignSystem } from './utils';
|
|
15
14
|
import { createStackNavigator } from '@react-navigation/stack';
|
|
16
15
|
import ModalScreen from './ModalScreen';
|
|
17
|
-
import {
|
|
16
|
+
import { View } from 'react-native';
|
|
18
17
|
|
|
19
18
|
const Stack = createStackNavigator();
|
|
20
19
|
|
|
21
|
-
/** Widget screen that reports its laid-out height to size the container. */
|
|
22
20
|
const WidgetContent: React.FC = ({ route }: any) => {
|
|
23
21
|
const Component = route?.params?.screen;
|
|
24
22
|
return (
|
|
@@ -32,10 +30,6 @@ const WidgetContent: React.FC = ({ route }: any) => {
|
|
|
32
30
|
);
|
|
33
31
|
};
|
|
34
32
|
|
|
35
|
-
/**
|
|
36
|
-
* Root of an embedded widget: its own navigator with the widget screen and the
|
|
37
|
-
* `Modal` route, sized to the widget's content height.
|
|
38
|
-
*/
|
|
39
33
|
const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
40
34
|
widget,
|
|
41
35
|
theme = defaultTheme,
|
|
@@ -66,9 +60,11 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
66
60
|
headerGradient = context?.designConfig?.headerGradient;
|
|
67
61
|
}
|
|
68
62
|
|
|
63
|
+
/**
|
|
64
|
+
* inject data for navigator
|
|
65
|
+
*/
|
|
69
66
|
navigator.current.maxApi = maxApi;
|
|
70
67
|
|
|
71
|
-
/** Text for a localization key, or the current-language side of `{ vi, en }`. */
|
|
72
68
|
const translate = (data?: string | { vi: string; en: string }) => {
|
|
73
69
|
if (data && typeof data !== 'string') {
|
|
74
70
|
return localize?.translateData(data);
|
|
@@ -84,13 +80,10 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
84
80
|
};
|
|
85
81
|
const isWhiteList = isWhiteListDesignSystem(mergedContext);
|
|
86
82
|
const fontFamily = isWhiteList ? 'MomoTrustSans' : 'SFProText';
|
|
87
|
-
|
|
88
|
-
if (isWhiteList) {
|
|
89
|
-
navigationFontFamily = 'MomoTrustSans-Regular';
|
|
90
|
-
}
|
|
83
|
+
const navigationFontFamily = isWhiteList ? 'MomoTrustSans-Regular' : 'SFProText';
|
|
91
84
|
|
|
92
85
|
return (
|
|
93
|
-
<View style={
|
|
86
|
+
<View style={{ height: height ?? '100%', minHeight: 1 }}>
|
|
94
87
|
<SafeAreaProvider>
|
|
95
88
|
<MiniAppContext.Provider value={mergedContext}>
|
|
96
89
|
<ApplicationContext.Provider
|
|
@@ -177,10 +170,4 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
177
170
|
);
|
|
178
171
|
};
|
|
179
172
|
|
|
180
|
-
const styles = StyleSheet.create({
|
|
181
|
-
container: {
|
|
182
|
-
minHeight: 1,
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
|
-
|
|
186
173
|
export { WidgetContainer };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Dimensions, Platform, ScaledSize } from 'react-native';
|
|
2
|
+
import type { EdgeInsets } from 'react-native-safe-area-context';
|
|
3
|
+
import { Spacing } from '../Consts';
|
|
4
|
+
|
|
5
|
+
// widest short side of any single-display iPhone
|
|
6
|
+
const IPHONE_MAX_SHORT_SIDE = 440;
|
|
7
|
+
|
|
8
|
+
const DUO_MODAL_MAX_WIDTH = 440;
|
|
9
|
+
const DUO_MODAL_MAX_HEIGHT = 640;
|
|
10
|
+
|
|
11
|
+
// iPhone Duo reports idiom "phone"; 'screen' stays on the outer display, so it
|
|
12
|
+
// still matches when Split View narrows the window
|
|
13
|
+
const isIPhoneDuo = () => {
|
|
14
|
+
if (Platform.OS !== 'ios' || Platform.isPad) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const shortSide = (size: ScaledSize) => Math.min(size.width, size.height);
|
|
18
|
+
return (
|
|
19
|
+
Math.max(
|
|
20
|
+
shortSide(Dimensions.get('screen')),
|
|
21
|
+
shortSide(Dimensions.get('window')),
|
|
22
|
+
) > IPHONE_MAX_SHORT_SIDE
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// portrait side status bar is about twice as tall as its inset is wide
|
|
27
|
+
const getDuoTopInset = (insets: EdgeInsets, width: number, height: number) =>
|
|
28
|
+
Math.max(
|
|
29
|
+
insets.top,
|
|
30
|
+
height > width ? Math.max(insets.left, insets.right) * 2 : 0,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Max modal size on iPhone Duo: inside the safe area, so clear of the side
|
|
35
|
+
* toolbar strip, and capped so it stays a dialog on the inner display.
|
|
36
|
+
*/
|
|
37
|
+
const getDuoModalBounds = (
|
|
38
|
+
insets: EdgeInsets,
|
|
39
|
+
width: number,
|
|
40
|
+
height: number,
|
|
41
|
+
) => ({
|
|
42
|
+
maxWidth: Math.min(
|
|
43
|
+
width - insets.left - insets.right - Spacing.XL * 2,
|
|
44
|
+
DUO_MODAL_MAX_WIDTH,
|
|
45
|
+
),
|
|
46
|
+
maxHeight: Math.min(
|
|
47
|
+
height - insets.top - insets.bottom - Spacing.XL * 2,
|
|
48
|
+
DUO_MODAL_MAX_HEIGHT,
|
|
49
|
+
),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export { isIPhoneDuo, getDuoTopInset, getDuoModalBounds };
|
package/Application/index.ts
CHANGED
|
@@ -13,26 +13,11 @@ export * from './Components/HeaderTitle';
|
|
|
13
13
|
export * from './Components/NavigationButton';
|
|
14
14
|
export * from './Components/SearchHeader';
|
|
15
15
|
|
|
16
|
-
import { exportHeaderTitle } from './
|
|
17
|
-
import { setAutomationID } from './utils';
|
|
18
|
-
import { useComponentId } from './hooks';
|
|
16
|
+
import { exportHeaderTitle, setAutomationID, useComponentId } from './utils';
|
|
19
17
|
import Navigation from './Navigation';
|
|
20
18
|
import Navigator from './Navigator';
|
|
21
19
|
import ScaleSizeProvider from './ScaleSizeProvider';
|
|
22
20
|
import { useTooltipPortal } from './TooltipPortal';
|
|
23
|
-
import {
|
|
24
|
-
getModalLayout,
|
|
25
|
-
useModalLayout,
|
|
26
|
-
type ModalLayout,
|
|
27
|
-
type ModalRect,
|
|
28
|
-
} from './modalLayout';
|
|
29
|
-
import {
|
|
30
|
-
HeaderBarMetrics,
|
|
31
|
-
getHeaderLayout,
|
|
32
|
-
useHeaderLayout,
|
|
33
|
-
type HeaderContentLayout,
|
|
34
|
-
type HeaderLayout,
|
|
35
|
-
} from './headerLayout';
|
|
36
21
|
|
|
37
22
|
export {
|
|
38
23
|
NavigationContainer,
|
|
@@ -46,11 +31,4 @@ export {
|
|
|
46
31
|
exportHeaderTitle,
|
|
47
32
|
ScaleSizeProvider,
|
|
48
33
|
useTooltipPortal,
|
|
49
|
-
getModalLayout,
|
|
50
|
-
useModalLayout,
|
|
51
|
-
HeaderBarMetrics,
|
|
52
|
-
getHeaderLayout,
|
|
53
|
-
useHeaderLayout,
|
|
54
34
|
};
|
|
55
|
-
|
|
56
|
-
export type { ModalLayout, ModalRect, HeaderContentLayout, HeaderLayout };
|