@momo-kits/foundation 0.168.1-rn862.1 → 0.169.2
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.hooks.ts +195 -0
- package/Application/BottomSheet.parts.tsx +147 -0
- package/Application/BottomSheet.styles.ts +43 -0
- package/Application/BottomSheet.tsx +76 -279
- package/Application/BottomTab/ActiveIndicator.tsx +90 -0
- package/Application/BottomTab/BottomTabBar.styles.ts +65 -0
- package/Application/BottomTab/BottomTabBar.tsx +229 -276
- package/Application/BottomTab/BottomTabInset.tsx +14 -0
- package/Application/BottomTab/CurvedContainer.tsx +153 -0
- package/Application/BottomTab/CustomBottomTabItem.tsx +132 -108
- package/Application/BottomTab/DuoBarCompression.tsx +4 -12
- package/Application/BottomTab/DuoRailTabBar.tsx +227 -0
- package/Application/BottomTab/DuoTabBar.styles.ts +81 -0
- package/Application/BottomTab/DuoTabBar.tsx +29 -495
- package/Application/BottomTab/TabBarIcon.tsx +160 -72
- package/Application/BottomTab/TabScreen.tsx +164 -0
- package/Application/BottomTab/index.tsx +84 -351
- package/Application/BottomTab/metrics.ts +164 -0
- package/Application/BottomTab/tabItems.ts +46 -0
- package/Application/BottomTab/usePressLift.ts +32 -0
- package/Application/Components/DuoGlassBackground.tsx +7 -9
- package/Application/Components/HeaderAnimated.tsx +1 -1
- package/Application/Components/HeaderBackground.tsx +1 -1
- package/Application/Components/HeaderExtendHeader.tsx +17 -11
- package/Application/Components/HeaderRight.styles.ts +144 -0
- package/Application/Components/HeaderRight.tsx +6 -528
- package/Application/Components/HeaderTitle.shared.ts +43 -0
- package/Application/Components/HeaderTitle.styles.ts +125 -0
- package/Application/Components/HeaderTitle.tsx +12 -576
- package/Application/Components/HeaderToolkitAction.tsx +208 -0
- package/Application/Components/NavigationButton.tsx +9 -6
- package/Application/Components/SearchHeader.tsx +1 -1
- package/Application/Components/SwipeBackHaptic.tsx +95 -0
- package/Application/Components/TitleJourney.tsx +110 -0
- package/Application/Components/TitleLocation.tsx +73 -0
- package/Application/Components/TitleUser.tsx +304 -0
- package/Application/Components/useToolkitActions.tsx +233 -0
- package/Application/ModalIconButton.tsx +66 -0
- package/Application/ModalScreen.tsx +39 -18
- package/Application/Navigation.ts +1 -1
- package/Application/NavigationContainer.tsx +7 -8
- package/Application/StackScreen.tracking.ts +158 -0
- package/Application/StackScreen.tsx +10 -137
- package/Application/WidgetContainer.tsx +10 -3
- package/Application/__tests__/modalLayout.test.ts +128 -0
- package/Application/hooks.ts +137 -0
- package/Application/index.ts +13 -1
- package/Application/modalLayout.ts +177 -0
- package/Application/navigationOptions.tsx +217 -0
- package/Application/types.header.ts +116 -0
- package/Application/types.tabs.ts +48 -0
- package/Application/types.theme.ts +87 -0
- package/Application/types.ts +12 -244
- package/Application/utils.ts +107 -0
- package/Badge/BadgeRibbon.tsx +3 -3
- package/Badge/styles.ts +2 -0
- package/Button/index.tsx +16 -136
- package/Button/styles.ts +1 -1
- package/Button/utils.ts +139 -0
- package/CheckBox/index.tsx +1 -6
- package/Divider/DashDivider.tsx +10 -11
- package/Divider/index.tsx +18 -8
- package/Image/index.tsx +1 -46
- package/Input/Input.tsx +7 -8
- package/Input/InputDropDown.tsx +3 -4
- package/Input/InputMoney.tsx +38 -164
- package/Input/InputMoneyView.tsx +187 -0
- package/Input/InputOTP.tsx +1 -1
- package/Input/InputPhoneNumber.tsx +5 -1
- package/Input/InputSearch.tsx +2 -108
- package/Input/InputTextArea.tsx +1 -5
- package/Input/SearchTextTyping.tsx +104 -0
- package/Input/common.tsx +4 -4
- package/Input/moneyUtils.ts +17 -0
- package/Input/styles.ts +26 -2
- package/Layout/FloatingButton.tsx +22 -21
- package/Layout/ReservedRegions.tsx +21 -4
- package/Layout/Screen.tsx +74 -670
- package/Layout/Section.tsx +1 -2
- package/Layout/index.ts +10 -4
- package/Layout/layoutMetrics.ts +58 -0
- package/Layout/layoutTypes.ts +86 -0
- package/Layout/screenContent.tsx +90 -0
- package/Layout/screenFooter.tsx +53 -0
- package/Layout/screenHeader.tsx +315 -0
- package/Layout/screenQuickReturn.tsx +67 -0
- package/Layout/screenScroll.ts +110 -0
- package/Layout/screenTypes.ts +134 -0
- package/Layout/styles.ts +2 -0
- package/Layout/utils.ts +10 -144
- package/Loader/DotLoader.tsx +7 -3
- package/Loader/ProgressBar.tsx +2 -6
- package/Loader/Spinner.tsx +7 -3
- package/Loader/styles.ts +4 -0
- package/Popup/PopupNotify.tsx +70 -64
- package/Popup/PopupPromotion.tsx +5 -4
- package/Popup/types.ts +7 -0
- package/Popup/utils.ts +46 -24
- package/Radio/index.tsx +2 -10
- package/Radio/styles.ts +6 -0
- package/Skeleton/index.tsx +1 -9
- package/Skeleton/styles.ts +1 -0
- package/Tag/index.tsx +3 -3
- package/Text/index.tsx +11 -2
- package/Title/index.tsx +2 -9
- package/Title/styles.ts +6 -0
- package/package.json +21 -22
- package/Application/device.ts +0 -29
- package/Application/utils.tsx +0 -497
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useCallback,
|
|
3
|
+
useContext,
|
|
4
|
+
useEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
} from 'react';
|
|
2
8
|
import {
|
|
3
9
|
Animated,
|
|
4
10
|
BackHandler,
|
|
@@ -11,14 +17,14 @@ import {
|
|
|
11
17
|
useWindowDimensions,
|
|
12
18
|
View,
|
|
13
19
|
} from 'react-native';
|
|
14
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
15
20
|
|
|
16
21
|
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
17
|
-
import { Styles } from '../Consts';
|
|
22
|
+
import { Colors, Styles } from '../Consts';
|
|
18
23
|
import Navigation from './Navigation';
|
|
19
24
|
import { ModalParams } from './types';
|
|
20
25
|
import BottomSheet from './BottomSheet';
|
|
21
|
-
import {
|
|
26
|
+
import { isIPhoneDuo } from './utils';
|
|
27
|
+
import { useModalLayout } from './modalLayout';
|
|
22
28
|
import { scheduleOnRN } from 'react-native-worklets';
|
|
23
29
|
|
|
24
30
|
const ModalScreen: React.FC<any> = props => {
|
|
@@ -40,8 +46,9 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
40
46
|
title,
|
|
41
47
|
} = props.route.params;
|
|
42
48
|
const Component = useRef(screen).current;
|
|
43
|
-
const
|
|
44
|
-
const
|
|
49
|
+
const { width, height } = useWindowDimensions();
|
|
50
|
+
const isDuo = isIPhoneDuo();
|
|
51
|
+
const { isFoldable, placement, popup, scrimOpacity } = useModalLayout();
|
|
45
52
|
|
|
46
53
|
/**
|
|
47
54
|
* Fire auto_popup_displayed tracking event on mount
|
|
@@ -60,6 +67,15 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
60
67
|
|
|
61
68
|
const opacity = useRef(new Animated.Value(0)).current;
|
|
62
69
|
const scale = useRef(new Animated.Value(0.8)).current;
|
|
70
|
+
const scrimStyle = useMemo(
|
|
71
|
+
() => ({
|
|
72
|
+
opacity: opacity.interpolate({
|
|
73
|
+
inputRange: [0, 1],
|
|
74
|
+
outputRange: [0, scrimOpacity],
|
|
75
|
+
}),
|
|
76
|
+
}),
|
|
77
|
+
[opacity, scrimOpacity],
|
|
78
|
+
);
|
|
63
79
|
|
|
64
80
|
const navigation = new Navigation(props.navigation);
|
|
65
81
|
const params = {
|
|
@@ -133,18 +149,19 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
133
149
|
transparent
|
|
134
150
|
visible={true}
|
|
135
151
|
onRequestClose={onDismiss}
|
|
136
|
-
style={StyleSheet.
|
|
152
|
+
style={StyleSheet.absoluteFillObject}
|
|
137
153
|
isModalKit={true}
|
|
154
|
+
supportedOrientations={isDuo ? DUO_ORIENTATIONS : undefined}
|
|
138
155
|
>
|
|
139
156
|
<KeyboardAvoidingView
|
|
140
157
|
style={Styles.flexCenter}
|
|
141
158
|
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
|
|
142
159
|
>
|
|
143
160
|
<Pressable
|
|
144
|
-
style={StyleSheet.
|
|
161
|
+
style={StyleSheet.absoluteFillObject}
|
|
145
162
|
onPress={() => onDismiss(undefined, barrierDismissible)}
|
|
146
163
|
>
|
|
147
|
-
<Animated.View style={[styles.overlayContent,
|
|
164
|
+
<Animated.View style={[styles.overlayContent, scrimStyle]} />
|
|
148
165
|
</Pressable>
|
|
149
166
|
<Animated.View
|
|
150
167
|
style={[
|
|
@@ -152,14 +169,15 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
152
169
|
opacity,
|
|
153
170
|
transform: [{ scale }],
|
|
154
171
|
},
|
|
155
|
-
//
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
172
|
+
// centered in the placement area, at most a popup wide
|
|
173
|
+
isFoldable && styles.shrink,
|
|
174
|
+
isFoldable && {
|
|
175
|
+
marginTop: placement.y,
|
|
176
|
+
marginBottom: height - placement.y - placement.height,
|
|
177
|
+
marginLeft: placement.x,
|
|
178
|
+
marginRight: width - placement.x - placement.width,
|
|
179
|
+
maxWidth: popup.width,
|
|
180
|
+
maxHeight: popup.maxHeight,
|
|
163
181
|
},
|
|
164
182
|
modalStyle,
|
|
165
183
|
]}
|
|
@@ -171,11 +189,14 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
171
189
|
);
|
|
172
190
|
};
|
|
173
191
|
|
|
192
|
+
const DUO_ORIENTATIONS = ['portrait', 'landscape'];
|
|
193
|
+
|
|
174
194
|
const styles = StyleSheet.create({
|
|
175
195
|
overlayContent: {
|
|
176
196
|
flex: 1,
|
|
177
|
-
backgroundColor:
|
|
197
|
+
backgroundColor: Colors.black_20,
|
|
178
198
|
},
|
|
199
|
+
shrink: { flexShrink: 1 },
|
|
179
200
|
});
|
|
180
201
|
|
|
181
202
|
export default ModalScreen;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {NavigationProp} from '@react-navigation/native';
|
|
2
2
|
import {NavigationOptions} from './types';
|
|
3
|
-
import {getOptions} from './
|
|
3
|
+
import {getOptions} from './navigationOptions';
|
|
4
4
|
import {StackNavigationOptions} from '@react-navigation/stack';
|
|
5
5
|
|
|
6
6
|
export const WHITE_LIST = [
|
|
@@ -2,6 +2,7 @@ import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
SafeAreaInsetsContext,
|
|
4
4
|
SafeAreaProvider,
|
|
5
|
+
type EdgeInsets,
|
|
5
6
|
} from 'react-native-safe-area-context';
|
|
6
7
|
import {
|
|
7
8
|
NavigationContainer as ReactNavigationContainer,
|
|
@@ -15,12 +16,9 @@ import {
|
|
|
15
16
|
import StackScreen from './StackScreen';
|
|
16
17
|
import ModalScreen from './ModalScreen';
|
|
17
18
|
import Navigator from './Navigator';
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
isWhiteListDesignSystem,
|
|
22
|
-
useNativeCanGoBack,
|
|
23
|
-
} from './utils';
|
|
19
|
+
import { getModalOptions, getStackOptions } from './navigationOptions';
|
|
20
|
+
import { isWhiteListDesignSystem } from './utils';
|
|
21
|
+
import { useNativeCanGoBack } from './hooks';
|
|
24
22
|
import { NavigationContainerProps } from './types';
|
|
25
23
|
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
26
24
|
import Localize from './Localize';
|
|
@@ -29,7 +27,6 @@ import { HeaderLeft } from './Components/HeaderLeft';
|
|
|
29
27
|
import { HeaderRight } from './Components/HeaderRight';
|
|
30
28
|
import { HeaderTitle } from './Components/HeaderTitle';
|
|
31
29
|
import { HeaderBackground } from './Components/HeaderBackground';
|
|
32
|
-
import { type EdgeInsets } from 'react-native-safe-area-context';
|
|
33
30
|
import { useScreenLayout } from '../Layout';
|
|
34
31
|
import { getHeaderRowOptions } from '../Layout/utils';
|
|
35
32
|
import { ReservedRegionsProvider } from '../Layout/ReservedRegions';
|
|
@@ -112,7 +109,9 @@ const Navigation: React.FC<any> = ({
|
|
|
112
109
|
const syncCanGoBack = useNativeCanGoBack();
|
|
113
110
|
const isWhiteList = isWhiteListDesignSystem(context);
|
|
114
111
|
const fontFamily = isWhiteList ? 'MomoTrustSans' : 'SFProText';
|
|
115
|
-
const navigationFontFamily = isWhiteList
|
|
112
|
+
const navigationFontFamily = isWhiteList
|
|
113
|
+
? 'MomoTrustSans-Regular'
|
|
114
|
+
: 'SFProText';
|
|
116
115
|
let headerBackground = context?.designSystemConfig?.config?.headerBar;
|
|
117
116
|
let headerGradient = theme.colors?.gradient;
|
|
118
117
|
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { Alert } from 'react-native';
|
|
2
|
+
import { version } from '../package.json';
|
|
3
|
+
|
|
4
|
+
type ScreenTrackingDeps = {
|
|
5
|
+
tracking: { current: any };
|
|
6
|
+
context: any;
|
|
7
|
+
navigator: any;
|
|
8
|
+
screenName: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const createScreenTracking = ({
|
|
12
|
+
tracking,
|
|
13
|
+
context,
|
|
14
|
+
navigator,
|
|
15
|
+
screenName,
|
|
16
|
+
}: ScreenTrackingDeps) => {
|
|
17
|
+
/**
|
|
18
|
+
* tracking for screen load
|
|
19
|
+
*/
|
|
20
|
+
const onScreenLoad = () => {
|
|
21
|
+
if (!tracking.current?.releaseLoad) {
|
|
22
|
+
let timeLoad = tracking.current.timeLoad;
|
|
23
|
+
if (timeLoad === 0) {
|
|
24
|
+
timeLoad = tracking.current.endTime - tracking.current.startTime;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
context?.autoTracking?.({
|
|
28
|
+
...context,
|
|
29
|
+
screenName,
|
|
30
|
+
componentName: 'Screen',
|
|
31
|
+
state: 'load',
|
|
32
|
+
duration: timeLoad,
|
|
33
|
+
widgets: tracking.current.widgets,
|
|
34
|
+
params: tracking.current.params,
|
|
35
|
+
version: version,
|
|
36
|
+
lastElement: tracking.current.lastElement,
|
|
37
|
+
});
|
|
38
|
+
navigator?.maxApi?.stopTrace?.(
|
|
39
|
+
tracking.current.traceIdLoad,
|
|
40
|
+
{ value: timeLoad / 1000 },
|
|
41
|
+
null,
|
|
42
|
+
);
|
|
43
|
+
tracking.current.releaseLoad = true;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* debug
|
|
47
|
+
*/
|
|
48
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
49
|
+
appId: context.appId,
|
|
50
|
+
message: `${screenName} screen_load_time ${timeLoad}`,
|
|
51
|
+
type: 'ERROR',
|
|
52
|
+
});
|
|
53
|
+
if (
|
|
54
|
+
__DEV__ &&
|
|
55
|
+
tracking.current.lastElement?.children?.current?.length > 0
|
|
56
|
+
) {
|
|
57
|
+
Alert.alert(
|
|
58
|
+
`${screenName}- load ${timeLoad}ms`,
|
|
59
|
+
JSON.stringify(tracking.current.lastElement?.children?.current),
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* tracking for screen load
|
|
67
|
+
*/
|
|
68
|
+
const onScreenInteraction = () => {
|
|
69
|
+
if (!tracking.current?.releaseInteraction) {
|
|
70
|
+
let timeLoad = tracking.current.timeLoad;
|
|
71
|
+
if (timeLoad === 0) {
|
|
72
|
+
timeLoad = tracking.current.endTime - tracking.current.startTime;
|
|
73
|
+
}
|
|
74
|
+
if (tracking.current.timeInteraction === 0) {
|
|
75
|
+
tracking.current.timeInteraction = timeLoad;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
context?.autoTracking?.({
|
|
79
|
+
...context,
|
|
80
|
+
screenName,
|
|
81
|
+
componentName: 'Screen',
|
|
82
|
+
state: 'interaction',
|
|
83
|
+
duration: tracking.current.timeInteraction - timeLoad,
|
|
84
|
+
totalDuration: tracking.current.timeInteraction,
|
|
85
|
+
params: tracking.current.params,
|
|
86
|
+
version: version,
|
|
87
|
+
});
|
|
88
|
+
navigator?.maxApi?.stopTrace?.(
|
|
89
|
+
tracking.current.traceIdInteraction,
|
|
90
|
+
{ value: tracking.current.timeInteraction / 1000 },
|
|
91
|
+
null,
|
|
92
|
+
);
|
|
93
|
+
tracking.current.releaseInteraction = true;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* debug toast
|
|
97
|
+
*/
|
|
98
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
99
|
+
appId: context.appId,
|
|
100
|
+
message: `${screenName} screen_interaction_time ${tracking.current.timeInteraction}`,
|
|
101
|
+
type: 'ERROR',
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* tracking for first interaction by user
|
|
108
|
+
*/
|
|
109
|
+
const onFirstInteraction = (action: string) => {
|
|
110
|
+
if (!tracking.current?.releaseUserInteraction) {
|
|
111
|
+
const timeLoad = tracking.current.endTime - tracking.current.startTime;
|
|
112
|
+
context?.autoTracking?.({
|
|
113
|
+
...context,
|
|
114
|
+
screenName,
|
|
115
|
+
componentName: 'Screen',
|
|
116
|
+
state: 'interaction',
|
|
117
|
+
duration: timeLoad,
|
|
118
|
+
action,
|
|
119
|
+
});
|
|
120
|
+
tracking.current.releaseUserInteraction = true;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* debug
|
|
124
|
+
*/
|
|
125
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
126
|
+
appId: context.appId,
|
|
127
|
+
message: `${screenName} user_interaction ${timeLoad}`,
|
|
128
|
+
type: 'ERROR',
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* tracking for loading screen
|
|
135
|
+
*/
|
|
136
|
+
const onScreenLoading = () => {
|
|
137
|
+
const start = tracking.current.timeStartLoading;
|
|
138
|
+
const end = tracking.current.timeEndLoading;
|
|
139
|
+
if (!tracking.current?.releaseLoading && start && end && end > start) {
|
|
140
|
+
context?.autoTracking?.({
|
|
141
|
+
...context,
|
|
142
|
+
screenName,
|
|
143
|
+
componentName: 'Screen',
|
|
144
|
+
state: 'loading',
|
|
145
|
+
duration: end - start,
|
|
146
|
+
loadingType: 'skeleton',
|
|
147
|
+
});
|
|
148
|
+
tracking.current.releaseLoading = true;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
onScreenLoad,
|
|
154
|
+
onScreenInteraction,
|
|
155
|
+
onFirstInteraction,
|
|
156
|
+
onScreenLoading,
|
|
157
|
+
};
|
|
158
|
+
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { useContext, useEffect, useLayoutEffect, useRef } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { 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 {
|
|
7
|
+
import { SwipeBackHaptic } from './Components/SwipeBackHaptic';
|
|
8
|
+
import { useAppState } from './hooks';
|
|
9
|
+
import { createScreenTracking } from './StackScreen.tracking';
|
|
9
10
|
import { TooltipPortalHost, TooltipPortalProvider } from './TooltipPortal';
|
|
10
11
|
|
|
11
12
|
const runAfterInteractions = InteractionManager.runAfterInteractions;
|
|
@@ -176,140 +177,12 @@ const StackScreen: React.FC<any> = props => {
|
|
|
176
177
|
}
|
|
177
178
|
};
|
|
178
179
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
};
|
|
180
|
+
const {
|
|
181
|
+
onScreenLoad,
|
|
182
|
+
onScreenInteraction,
|
|
183
|
+
onFirstInteraction,
|
|
184
|
+
onScreenLoading,
|
|
185
|
+
} = createScreenTracking({ tracking, context, navigator, screenName });
|
|
313
186
|
|
|
314
187
|
return (
|
|
315
188
|
<ScreenContext.Provider
|
|
@@ -10,10 +10,11 @@ import {
|
|
|
10
10
|
NavigationContainerRef,
|
|
11
11
|
NavigationIndependentTree,
|
|
12
12
|
} from '@react-navigation/native';
|
|
13
|
-
import { getModalOptions
|
|
13
|
+
import { getModalOptions } from './navigationOptions';
|
|
14
|
+
import { isWhiteListDesignSystem } from './utils';
|
|
14
15
|
import { createStackNavigator } from '@react-navigation/stack';
|
|
15
16
|
import ModalScreen from './ModalScreen';
|
|
16
|
-
import { View } from 'react-native';
|
|
17
|
+
import { StyleSheet, View } from 'react-native';
|
|
17
18
|
|
|
18
19
|
const Stack = createStackNavigator();
|
|
19
20
|
|
|
@@ -83,7 +84,7 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
83
84
|
const navigationFontFamily = isWhiteList ? 'MomoTrustSans-Regular' : 'SFProText';
|
|
84
85
|
|
|
85
86
|
return (
|
|
86
|
-
<View style={{ height: height ?? '100%'
|
|
87
|
+
<View style={[styles.container, { height: height ?? '100%' }]}>
|
|
87
88
|
<SafeAreaProvider>
|
|
88
89
|
<MiniAppContext.Provider value={mergedContext}>
|
|
89
90
|
<ApplicationContext.Provider
|
|
@@ -170,4 +171,10 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
170
171
|
);
|
|
171
172
|
};
|
|
172
173
|
|
|
174
|
+
const styles = StyleSheet.create({
|
|
175
|
+
container: {
|
|
176
|
+
minHeight: 1,
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
|
|
173
180
|
export { WidgetContainer };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// document/__mocks__ shadows react-native with react-native-web for the doc site
|
|
2
|
+
jest.mock('react-native', () => jest.requireActual('react-native'));
|
|
3
|
+
|
|
4
|
+
import { getModalLayout } from '../modalLayout';
|
|
5
|
+
|
|
6
|
+
const NO_INSETS = { top: 0, right: 0, bottom: 0, left: 0 };
|
|
7
|
+
|
|
8
|
+
describe('getModalLayout', () => {
|
|
9
|
+
it('keeps the phone look', () => {
|
|
10
|
+
const layout = getModalLayout({
|
|
11
|
+
width: 390,
|
|
12
|
+
height: 844,
|
|
13
|
+
insets: { top: 47, right: 0, bottom: 34, left: 0 },
|
|
14
|
+
isDuo: false,
|
|
15
|
+
});
|
|
16
|
+
expect(layout.isFoldable).toBe(false);
|
|
17
|
+
expect(layout.popup.width).toBe(342);
|
|
18
|
+
expect(layout.popup.maxHeight).toBeUndefined();
|
|
19
|
+
expect(layout.popup.radius).toBe(16);
|
|
20
|
+
expect(layout.sheet.width).toBeUndefined();
|
|
21
|
+
expect(layout.sheet.maxHeight).toBeUndefined();
|
|
22
|
+
expect(layout.sheet.radius).toBe(12);
|
|
23
|
+
expect(layout.scrimOpacity).toBe(0.6);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('keeps the phone look in landscape', () => {
|
|
27
|
+
const layout = getModalLayout({
|
|
28
|
+
width: 844,
|
|
29
|
+
height: 390,
|
|
30
|
+
insets: { top: 0, right: 47, bottom: 21, left: 47 },
|
|
31
|
+
isDuo: false,
|
|
32
|
+
});
|
|
33
|
+
expect(layout.isFoldable).toBe(false);
|
|
34
|
+
expect(layout.popup.width).toBe(844 - 48);
|
|
35
|
+
expect(layout.popup.maxHeight).toBeUndefined();
|
|
36
|
+
expect(layout.popup.radius).toBe(16);
|
|
37
|
+
expect(layout.sheet.width).toBeUndefined();
|
|
38
|
+
expect(layout.scrimOpacity).toBe(0.6);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('caps popup and sheet on a wide foldable window', () => {
|
|
42
|
+
const layout = getModalLayout({
|
|
43
|
+
width: 884,
|
|
44
|
+
height: 1104,
|
|
45
|
+
insets: { top: 24, right: 0, bottom: 20, left: 0 },
|
|
46
|
+
isDuo: false,
|
|
47
|
+
});
|
|
48
|
+
expect(layout.isFoldable).toBe(true);
|
|
49
|
+
expect(layout.popup).toMatchObject({
|
|
50
|
+
width: 450,
|
|
51
|
+
minWidth: 280,
|
|
52
|
+
maxWidth: 450,
|
|
53
|
+
maxHeight: 600,
|
|
54
|
+
margin: 24,
|
|
55
|
+
radius: 24,
|
|
56
|
+
});
|
|
57
|
+
expect(layout.sheet).toMatchObject({
|
|
58
|
+
width: 653,
|
|
59
|
+
maxHeight: 1104 - 24 - 12,
|
|
60
|
+
minHeight: 230,
|
|
61
|
+
margin: 12,
|
|
62
|
+
radius: 24,
|
|
63
|
+
});
|
|
64
|
+
expect(layout.scrimOpacity).toBe(0.2);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('limits popup height to the safe area minus 48', () => {
|
|
68
|
+
const layout = getModalLayout({
|
|
69
|
+
width: 900,
|
|
70
|
+
height: 600,
|
|
71
|
+
insets: { top: 24, right: 0, bottom: 20, left: 0 },
|
|
72
|
+
isDuo: false,
|
|
73
|
+
});
|
|
74
|
+
expect(layout.popup.maxHeight).toBe(600 - 24 - 20 - 48);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('places modals left of the control column on the iPhone Duo outer display', () => {
|
|
78
|
+
const layout = getModalLayout({
|
|
79
|
+
width: 420,
|
|
80
|
+
height: 760,
|
|
81
|
+
insets: { top: 0, right: 64, bottom: 20, left: 0 },
|
|
82
|
+
isDuo: true,
|
|
83
|
+
});
|
|
84
|
+
expect(layout.isFoldable).toBe(true);
|
|
85
|
+
expect(layout.placement).toEqual({ x: 0, y: 0, width: 356, height: 740 });
|
|
86
|
+
expect(layout.popup.margin).toBe(12);
|
|
87
|
+
expect(layout.popup.width).toBe(356 - 24);
|
|
88
|
+
expect(layout.sheet.width).toBe(356 - 24);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('never grows past the margins when the space is under the min width', () => {
|
|
92
|
+
const layout = getModalLayout({
|
|
93
|
+
width: 300,
|
|
94
|
+
height: 600,
|
|
95
|
+
insets: NO_INSETS,
|
|
96
|
+
isDuo: true,
|
|
97
|
+
});
|
|
98
|
+
expect(layout.popup.width).toBe(300 - 24);
|
|
99
|
+
expect(layout.popup.minWidth).toBe(300 - 24);
|
|
100
|
+
expect(layout.sheet.width).toBe(300 - 24);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('moves to the right half when iPhone Duo is half folded', () => {
|
|
104
|
+
const layout = getModalLayout({
|
|
105
|
+
width: 1000,
|
|
106
|
+
height: 800,
|
|
107
|
+
insets: NO_INSETS,
|
|
108
|
+
isDuo: true,
|
|
109
|
+
hinge: { x: 495, y: 0, width: 10, height: 800 },
|
|
110
|
+
});
|
|
111
|
+
expect(layout.placement).toEqual({ x: 505, y: 0, width: 495, height: 800 });
|
|
112
|
+
expect(layout.popup.margin).toBe(12);
|
|
113
|
+
expect(layout.popup.width).toBe(450);
|
|
114
|
+
expect(layout.sheet.width).toBe(495 - 24);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('ignores a division off the iPhone Duo', () => {
|
|
118
|
+
const layout = getModalLayout({
|
|
119
|
+
width: 1000,
|
|
120
|
+
height: 800,
|
|
121
|
+
insets: NO_INSETS,
|
|
122
|
+
isDuo: false,
|
|
123
|
+
hinge: { x: 495, y: 0, width: 10, height: 800 },
|
|
124
|
+
});
|
|
125
|
+
expect(layout.placement.x).toBe(0);
|
|
126
|
+
expect(layout.popup.margin).toBe(24);
|
|
127
|
+
});
|
|
128
|
+
});
|