@momo-kits/foundation 0.89.6 → 0.92.1-rc.1
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/BottomTab/BottomTabBar.tsx +507 -0
- package/Application/BottomTab/CurvedView.tsx +27 -0
- package/Application/{BottomTab.tsx → BottomTab/index.tsx} +17 -9
- package/Application/BottomTab/path.ts +202 -0
- package/Application/Components.tsx +26 -10
- package/Application/NavigationContainer.tsx +15 -3
- package/Application/StackScreen.tsx +73 -14
- package/Application/types.ts +11 -2
- package/Application/utils.tsx +62 -2
- package/Badge/Badge.tsx +1 -1
- package/Button/index.tsx +48 -14
- package/CheckBox/index.tsx +47 -20
- package/CheckBox/types.ts +4 -0
- package/Consts/colors+spacing+radius.ts +13 -0
- package/IconButton/index.tsx +30 -7
- package/Image/index.tsx +3 -1
- package/Input/Input.tsx +60 -5
- package/Input/InputDropDown.tsx +38 -4
- package/Input/InputMoney.tsx +45 -4
- package/Input/InputOTP.tsx +33 -7
- package/Input/InputSearch.tsx +61 -25
- package/Input/InputTextArea.tsx +21 -0
- package/Input/index.tsx +29 -2
- package/Popup/PopupNotify.tsx +13 -2
- package/Popup/PopupPromotion.tsx +11 -4
- package/Radio/index.tsx +46 -19
- package/Radio/types.ts +5 -0
- package/Switch/index.tsx +39 -14
- package/Switch/types.ts +4 -0
- package/Text/index.tsx +1 -0
- package/Title/index.tsx +119 -102
- package/Title/styles.ts +26 -6
- package/Title/types.ts +11 -48
- package/index.ts +2 -1
- package/package.json +4 -1
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import * as shape from 'd3-shape';
|
|
2
|
+
import {Platform} from 'react-native';
|
|
3
|
+
|
|
4
|
+
export const TABBAR_ITEM_TOP = Platform.OS === 'ios' ? 8 : 4;
|
|
5
|
+
export const CIRCLE_SIZE = 50;
|
|
6
|
+
export const TABBAR_ITEM_ICON_SIZE = 28;
|
|
7
|
+
export const CIRCLE_POSITION_TOP =
|
|
8
|
+
CIRCLE_SIZE - TABBAR_ITEM_ICON_SIZE - TABBAR_ITEM_TOP;
|
|
9
|
+
export const CIRCLE_OVER_SIZE = 10;
|
|
10
|
+
export const CIRCLE_OVER_TOP = CIRCLE_POSITION_TOP + CIRCLE_OVER_SIZE;
|
|
11
|
+
|
|
12
|
+
export const scale = (number: number) => {
|
|
13
|
+
return number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const line = (width: number, height: number) => {
|
|
17
|
+
const path = (shape as any)
|
|
18
|
+
.line()
|
|
19
|
+
.x((d: {x: any}) => d.x)
|
|
20
|
+
.y((d: {y: any}) => d.y)([
|
|
21
|
+
{x: width / 2, y: scale(CIRCLE_OVER_TOP)},
|
|
22
|
+
{x: 0, y: scale(CIRCLE_OVER_TOP)},
|
|
23
|
+
{x: 0, y: height},
|
|
24
|
+
{x: width, y: height},
|
|
25
|
+
{x: width, y: scale(CIRCLE_OVER_TOP)},
|
|
26
|
+
{x: width / 2, y: scale(CIRCLE_OVER_TOP)},
|
|
27
|
+
]);
|
|
28
|
+
//M195,30L0,30L0,106L390,106L390,30L195,30
|
|
29
|
+
// MaxApi.copyToClipboard(path, 'copied');
|
|
30
|
+
return path;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//** Path Line Border Left Right Up */
|
|
34
|
+
const lineBorder = (width: number, height: number) => {
|
|
35
|
+
const border = (shape as any)
|
|
36
|
+
.line()
|
|
37
|
+
.x((d: {x: any}) => d.x)
|
|
38
|
+
.y((d: {y: any}) => d.y)
|
|
39
|
+
.curve(shape.curveBasis)([
|
|
40
|
+
// right
|
|
41
|
+
{x: width / 2, y: scale(30)},
|
|
42
|
+
{x: width - scale(20), y: scale(30)},
|
|
43
|
+
{x: width - scale(10), y: scale(32)},
|
|
44
|
+
{x: width - scale(2), y: scale(40)},
|
|
45
|
+
{x: width, y: scale(50)},
|
|
46
|
+
{x: width, y: height},
|
|
47
|
+
{x: width, y: height},
|
|
48
|
+
// bottom
|
|
49
|
+
{x: width, y: height},
|
|
50
|
+
{x: 0, y: height},
|
|
51
|
+
// left
|
|
52
|
+
{x: 0, y: height},
|
|
53
|
+
{x: 0, y: height},
|
|
54
|
+
{x: 0, y: scale(50)},
|
|
55
|
+
{x: 0 + scale(2), y: scale(40)},
|
|
56
|
+
{x: 0 + scale(10), y: scale(32)},
|
|
57
|
+
{x: 0 + scale(20), y: scale(30)},
|
|
58
|
+
{x: width / 2, y: scale(30)},
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
return border;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
//** Path Line Border Left Right Down */
|
|
65
|
+
const lineBorderLeft = (width: number, height: number) => {
|
|
66
|
+
const border = (shape as any)
|
|
67
|
+
.line()
|
|
68
|
+
.x((d: {x: any}) => d.x)
|
|
69
|
+
.y((d: {y: any}) => d.y)
|
|
70
|
+
.curve(shape.curveBasis)([
|
|
71
|
+
// right
|
|
72
|
+
{x: width, y: scale(30)},
|
|
73
|
+
{x: width, y: height},
|
|
74
|
+
{x: width, y: height},
|
|
75
|
+
// bottom
|
|
76
|
+
{x: width, y: height},
|
|
77
|
+
{x: 0, y: height},
|
|
78
|
+
// left
|
|
79
|
+
{x: 0, y: height},
|
|
80
|
+
{x: 0, y: height},
|
|
81
|
+
{x: 0, y: scale(50)},
|
|
82
|
+
{x: 0 + scale(2), y: scale(40)},
|
|
83
|
+
{x: 0 + scale(10), y: scale(32)},
|
|
84
|
+
{x: 0 + scale(20), y: scale(30)},
|
|
85
|
+
{x: width / 2, y: scale(30)},
|
|
86
|
+
]);
|
|
87
|
+
|
|
88
|
+
return border;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
//** Path Line Border Left Right Down */
|
|
92
|
+
const lineBorderRight = (width: number, height: number) => {
|
|
93
|
+
const border = (shape as any)
|
|
94
|
+
.line()
|
|
95
|
+
.x((d: {x: any}) => d.x)
|
|
96
|
+
.y((d: {y: any}) => d.y)
|
|
97
|
+
.curve(shape.curveBasis)([
|
|
98
|
+
// right
|
|
99
|
+
{x: width / 2, y: scale(30)},
|
|
100
|
+
{x: width - scale(20), y: scale(30)},
|
|
101
|
+
{x: width - scale(10), y: scale(32)},
|
|
102
|
+
{x: width - scale(2), y: scale(40)},
|
|
103
|
+
{x: width, y: scale(50)},
|
|
104
|
+
{x: width, y: height},
|
|
105
|
+
{x: width, y: height},
|
|
106
|
+
// bottom
|
|
107
|
+
{x: width, y: height},
|
|
108
|
+
{x: 0, y: height},
|
|
109
|
+
// left
|
|
110
|
+
{x: 0, y: height},
|
|
111
|
+
{x: 0, y: height},
|
|
112
|
+
{x: 0, y: scale(30)},
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
return border;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
//** Path Curved Up */
|
|
119
|
+
const lineCurved = (position: number, circle: number) => {
|
|
120
|
+
const circleR = circle / 2;
|
|
121
|
+
const circleRightPos = circle + position;
|
|
122
|
+
const circleOverR = circle / 2 + CIRCLE_OVER_SIZE;
|
|
123
|
+
const centerX = (position + circleRightPos) / 2; //195
|
|
124
|
+
const centerY = CIRCLE_OVER_SIZE + circleR; //33
|
|
125
|
+
// {"circle":50,"position":170,"centerX":195,"circleWidth":220}
|
|
126
|
+
// WIDTH_SCREEN: 390
|
|
127
|
+
|
|
128
|
+
const curved = (shape as any)
|
|
129
|
+
.line()
|
|
130
|
+
.x((d: {x: any}) => d.x)
|
|
131
|
+
.y((d: {y: any}) => d.y)
|
|
132
|
+
.curve(shape.curveBundle.beta(1))([
|
|
133
|
+
{x: centerX - circleOverR - scale(50), y: CIRCLE_OVER_TOP},
|
|
134
|
+
{x: centerX - circleOverR, y: CIRCLE_OVER_TOP}, //y 20
|
|
135
|
+
{
|
|
136
|
+
x: centerX + circleOverR * Math.cos(-Math.PI / 2 - Math.PI / 4),
|
|
137
|
+
y: centerY + circleOverR * Math.sin(-Math.PI / 2 - Math.PI / 4),
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
{x: centerX, y: 0},
|
|
141
|
+
|
|
142
|
+
{
|
|
143
|
+
x: centerX + circleOverR * Math.cos(-Math.PI / 2 + Math.PI / 4),
|
|
144
|
+
y: centerY + circleOverR * Math.sin(-Math.PI / 2 + Math.PI / 4),
|
|
145
|
+
},
|
|
146
|
+
{x: centerX + circleOverR, y: CIRCLE_OVER_TOP}, //y 20
|
|
147
|
+
{x: centerX + circleOverR + scale(50), y: CIRCLE_OVER_TOP},
|
|
148
|
+
]);
|
|
149
|
+
|
|
150
|
+
return curved;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export const getPathUp = (
|
|
154
|
+
width: number,
|
|
155
|
+
iHeight: number,
|
|
156
|
+
centerWidth = 50,
|
|
157
|
+
borderTopLeftRight = false,
|
|
158
|
+
position: 'CENTER' | 'LEFT' | 'RIGHT',
|
|
159
|
+
) => {
|
|
160
|
+
const height = scale(iHeight);
|
|
161
|
+
const circleWidth = scale(centerWidth);
|
|
162
|
+
|
|
163
|
+
if (borderTopLeftRight && position === 'LEFT') {
|
|
164
|
+
return `${lineBorderRight(width, height)} ${lineCurved(
|
|
165
|
+
circleWidth / 1.7,
|
|
166
|
+
circleWidth,
|
|
167
|
+
)}`;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (borderTopLeftRight && position === 'RIGHT') {
|
|
171
|
+
return `${lineBorderLeft(width, height)} ${lineCurved(
|
|
172
|
+
width - circleWidth * 1.6,
|
|
173
|
+
circleWidth,
|
|
174
|
+
)}`;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (borderTopLeftRight && position === 'CENTER') {
|
|
178
|
+
return `${lineBorder(width, height)} ${lineCurved(
|
|
179
|
+
width / 2 - circleWidth / 2,
|
|
180
|
+
circleWidth,
|
|
181
|
+
)}`;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (position === 'LEFT') {
|
|
185
|
+
return `${line(width, height)} ${lineCurved(
|
|
186
|
+
circleWidth / 1.7,
|
|
187
|
+
circleWidth,
|
|
188
|
+
)}`;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (position === 'RIGHT') {
|
|
192
|
+
return `${line(width, height)} ${lineCurved(
|
|
193
|
+
width - circleWidth * 1.6,
|
|
194
|
+
circleWidth,
|
|
195
|
+
)}`;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return `${line(width, height)} ${lineCurved(
|
|
199
|
+
width / 2 - circleWidth / 2,
|
|
200
|
+
circleWidth,
|
|
201
|
+
)}`;
|
|
202
|
+
};
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
View,
|
|
16
16
|
ViewStyle,
|
|
17
17
|
} from 'react-native';
|
|
18
|
-
import {ApplicationContext
|
|
18
|
+
import {ApplicationContext} from './index';
|
|
19
19
|
import {Colors, Radius, Spacing, Styles} from '../Consts';
|
|
20
20
|
import {Image} from '../Image';
|
|
21
21
|
import {
|
|
@@ -29,6 +29,11 @@ import {scaleSize, Text} from '../Text';
|
|
|
29
29
|
import {Icon} from '../Icon';
|
|
30
30
|
import {PopupNotify} from '../Popup';
|
|
31
31
|
import {Badge, BadgeDot} from '../Badge';
|
|
32
|
+
import {getAccessibilityID} from './utils';
|
|
33
|
+
|
|
34
|
+
const {
|
|
35
|
+
MiniAppContext,
|
|
36
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
32
37
|
|
|
33
38
|
const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
34
39
|
icon,
|
|
@@ -37,6 +42,7 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
37
42
|
useBorder = true,
|
|
38
43
|
badgeType,
|
|
39
44
|
badgeValue,
|
|
45
|
+
accessibilityID = '',
|
|
40
46
|
}) => {
|
|
41
47
|
const {theme} = useContext(ApplicationContext);
|
|
42
48
|
let buttonStyle: ViewStyle = {backgroundColor: '#00000066'};
|
|
@@ -64,7 +70,9 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
64
70
|
}, [badgeType, badgeValue]);
|
|
65
71
|
|
|
66
72
|
return (
|
|
67
|
-
<View
|
|
73
|
+
<View
|
|
74
|
+
{...getAccessibilityID(accessibilityID)}
|
|
75
|
+
style={{width: scaleSize(28)}}>
|
|
68
76
|
<TouchableOpacity
|
|
69
77
|
style={[styles.navigationButton, buttonStyle]}
|
|
70
78
|
onPress={onPress}>
|
|
@@ -90,6 +98,7 @@ const HeaderTitle: React.FC<any> = props => {
|
|
|
90
98
|
return (
|
|
91
99
|
<Animated.Text
|
|
92
100
|
{...props}
|
|
101
|
+
{...getAccessibilityID('title_navigation_header')}
|
|
93
102
|
style={[
|
|
94
103
|
styles.title,
|
|
95
104
|
{fontFamily: `${theme.font}-Bold`, opacity, color: props.tintColor},
|
|
@@ -104,7 +113,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
104
113
|
onPressLeftHeader,
|
|
105
114
|
useBorder,
|
|
106
115
|
}) => {
|
|
107
|
-
const context = useContext(MiniAppContext);
|
|
116
|
+
const context = useContext<any>(MiniAppContext);
|
|
108
117
|
const {navigator} = useContext(ApplicationContext);
|
|
109
118
|
|
|
110
119
|
useEffect(() => {
|
|
@@ -128,7 +137,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
128
137
|
icon_name: 'back',
|
|
129
138
|
};
|
|
130
139
|
navigator?.maxApi?.showToastDebug?.({
|
|
131
|
-
appId: context.appId
|
|
140
|
+
appId: `auto - ${context.appId}`,
|
|
132
141
|
message: 'service_icon_clicked',
|
|
133
142
|
params,
|
|
134
143
|
});
|
|
@@ -166,10 +175,10 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
166
175
|
}
|
|
167
176
|
return true;
|
|
168
177
|
};
|
|
169
|
-
|
|
170
178
|
return (
|
|
171
179
|
<View style={styles.headerLeft}>
|
|
172
180
|
<NavigationButton
|
|
181
|
+
accessibilityID="btn_navigation_back"
|
|
173
182
|
icon="ic_back"
|
|
174
183
|
tintColor={tintColor}
|
|
175
184
|
onPress={goBackSafe}
|
|
@@ -243,7 +252,10 @@ const HeaderCustom: React.FC<TitleCustomProps> = ({
|
|
|
243
252
|
)}
|
|
244
253
|
</View>
|
|
245
254
|
<View style={[Styles.flex, {paddingHorizontal: 8}]}>
|
|
246
|
-
<Text
|
|
255
|
+
<Text
|
|
256
|
+
{...getAccessibilityID('title_navigation_header')}
|
|
257
|
+
typography="header_default_bold"
|
|
258
|
+
color={tintColor}>
|
|
247
259
|
{title}
|
|
248
260
|
</Text>
|
|
249
261
|
<Text typography="description_default_regular" color={tintColor}>
|
|
@@ -293,7 +305,7 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
293
305
|
preventClose,
|
|
294
306
|
}) => {
|
|
295
307
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
296
|
-
const miniContext = useContext(MiniAppContext);
|
|
308
|
+
const miniContext = useContext<any>(MiniAppContext);
|
|
297
309
|
const [toolConfig, setToolConfig] = useState<any>();
|
|
298
310
|
const {onAction} = toolConfig ?? {};
|
|
299
311
|
|
|
@@ -369,6 +381,7 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
369
381
|
if (pinTool)
|
|
370
382
|
return (
|
|
371
383
|
<NavigationButton
|
|
384
|
+
accessibilityID="btn_navigation_pin"
|
|
372
385
|
icon={pinTool.icon as string}
|
|
373
386
|
tintColor={tintColor}
|
|
374
387
|
badgeValue={badgeValue}
|
|
@@ -386,7 +399,6 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
386
399
|
/>
|
|
387
400
|
);
|
|
388
401
|
};
|
|
389
|
-
|
|
390
402
|
if (toolConfig) {
|
|
391
403
|
return (
|
|
392
404
|
<View style={styles.headerRightButton}>
|
|
@@ -399,11 +411,15 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
399
411
|
borderWidth: backgroundColor ? 0.5 : 0,
|
|
400
412
|
},
|
|
401
413
|
]}>
|
|
402
|
-
<TouchableOpacity
|
|
414
|
+
<TouchableOpacity
|
|
415
|
+
{...getAccessibilityID('btn_navigation_more')}
|
|
416
|
+
onPress={onMore}>
|
|
403
417
|
<Icon color={tintColor} source="navigation_more_horiz" size={20} />
|
|
404
418
|
</TouchableOpacity>
|
|
405
419
|
<View style={[styles.divider, {backgroundColor: tintColor}]} />
|
|
406
|
-
<TouchableOpacity
|
|
420
|
+
<TouchableOpacity
|
|
421
|
+
{...getAccessibilityID('btn_navigation_close')}
|
|
422
|
+
onPress={onClose}>
|
|
407
423
|
<Icon
|
|
408
424
|
color={tintColor}
|
|
409
425
|
source="16_navigation_close_circle"
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
NavigationContainer as ReactNavigationContainer,
|
|
5
5
|
NavigationContainerRef,
|
|
6
6
|
} from '@react-navigation/native';
|
|
7
|
+
import {BottomSheetModalProvider} from '@gorhom/bottom-sheet';
|
|
7
8
|
import {createStackNavigator} from '@react-navigation/stack';
|
|
8
9
|
import {DeviceEventEmitter} from 'react-native';
|
|
9
10
|
import StackScreen from './StackScreen';
|
|
@@ -11,9 +12,19 @@ import ModalScreen from './ModalScreen';
|
|
|
11
12
|
import Navigator from './Navigator';
|
|
12
13
|
import {getDialogOptions, getModalOptions, getStackOptions} from './utils';
|
|
13
14
|
import {LocalizationObject, NavigationContainerProps} from './types';
|
|
14
|
-
import {ApplicationContext
|
|
15
|
+
import {ApplicationContext} from './index';
|
|
15
16
|
import kitLocalization from '../Assets/language.json';
|
|
16
17
|
|
|
18
|
+
const {
|
|
19
|
+
MiniAppContext,
|
|
20
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* link for deprecated
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
console.log(typeof BottomSheetModalProvider);
|
|
27
|
+
|
|
17
28
|
const Stack = createStackNavigator();
|
|
18
29
|
|
|
19
30
|
const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
@@ -22,8 +33,9 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
22
33
|
options,
|
|
23
34
|
maxApi,
|
|
24
35
|
localization,
|
|
36
|
+
initialParams,
|
|
25
37
|
}) => {
|
|
26
|
-
const context = useContext(MiniAppContext);
|
|
38
|
+
const context = useContext<any>(MiniAppContext);
|
|
27
39
|
const navigationRef = useRef<NavigationContainerRef>(null);
|
|
28
40
|
const isReady = useRef(false);
|
|
29
41
|
const navigator = useRef(new Navigator(navigationRef, isReady));
|
|
@@ -96,7 +108,7 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
96
108
|
<Stack.Screen
|
|
97
109
|
name="Stack"
|
|
98
110
|
component={StackScreen}
|
|
99
|
-
initialParams={{screen}}
|
|
111
|
+
initialParams={{screen, initialParams}}
|
|
100
112
|
options={{...getStackOptions(), ...options}}
|
|
101
113
|
/>
|
|
102
114
|
<Stack.Screen
|
|
@@ -1,29 +1,54 @@
|
|
|
1
|
-
import React, {useContext, useEffect, useLayoutEffect} from 'react';
|
|
1
|
+
import React, {useContext, useEffect, useLayoutEffect, useRef} from 'react';
|
|
2
2
|
import {ScreenParams} from './types';
|
|
3
3
|
import Navigation from './Navigation';
|
|
4
|
-
import {ApplicationContext
|
|
4
|
+
import {ApplicationContext} from './index';
|
|
5
5
|
import {GridSystem} from '../Layout';
|
|
6
6
|
import {useHeaderHeight} from '@react-navigation/stack';
|
|
7
|
+
import {Alert, InteractionManager} from 'react-native';
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
ScreenContext,
|
|
11
|
+
MiniAppContext,
|
|
12
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
7
13
|
|
|
8
14
|
const StackScreen: React.FC<ScreenParams> = props => {
|
|
9
15
|
const {theme, showGrid, navigator} = useContext(ApplicationContext);
|
|
10
|
-
const
|
|
16
|
+
const startTime = useRef(Date.now());
|
|
17
|
+
const endTime = useRef(Date.now());
|
|
18
|
+
const timeLoad = useRef(0);
|
|
19
|
+
const timeout = useRef<any>();
|
|
20
|
+
|
|
21
|
+
const context = useContext<any>(MiniAppContext);
|
|
11
22
|
|
|
12
|
-
const {screen: Component, options}
|
|
23
|
+
const {screen: Component, options, initialParams} = props.route.params;
|
|
13
24
|
const navigation = new Navigation(props.navigation, theme);
|
|
14
25
|
const heightHeader = useHeaderHeight();
|
|
15
26
|
|
|
16
|
-
const
|
|
27
|
+
const data = {
|
|
17
28
|
...props.route.params,
|
|
29
|
+
...initialParams,
|
|
18
30
|
navigation,
|
|
19
31
|
};
|
|
20
32
|
|
|
21
|
-
delete
|
|
33
|
+
delete data.screen;
|
|
34
|
+
delete data.initialParams;
|
|
35
|
+
|
|
36
|
+
const screenName = Component?.name || Component?.type?.name || '';
|
|
22
37
|
|
|
23
38
|
/**
|
|
24
39
|
* set options for screen
|
|
25
40
|
*/
|
|
26
41
|
useLayoutEffect(() => {
|
|
42
|
+
const host = (global as any).miniAppApi?.currentHost || {};
|
|
43
|
+
host.screenName = screenName;
|
|
44
|
+
InteractionManager.runAfterInteractions(() => {
|
|
45
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
46
|
+
appId: `auto - ${context.appId}`,
|
|
47
|
+
message: `${screenName} screen_interaction_time ${
|
|
48
|
+
Date.now() - startTime.current
|
|
49
|
+
}`,
|
|
50
|
+
});
|
|
51
|
+
});
|
|
27
52
|
if (options) {
|
|
28
53
|
navigation.setOptions(options);
|
|
29
54
|
}
|
|
@@ -33,9 +58,18 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
33
58
|
* tracking for screen
|
|
34
59
|
*/
|
|
35
60
|
useEffect(() => {
|
|
61
|
+
if (__DEV__) {
|
|
62
|
+
if (!screenName || screenName === 'screen') {
|
|
63
|
+
Alert.alert(
|
|
64
|
+
'Design system',
|
|
65
|
+
`Unvalidated screen name "${screenName}" !`,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
36
70
|
const tracking = {
|
|
37
71
|
...context,
|
|
38
|
-
screen_name:
|
|
72
|
+
screen_name: screenName,
|
|
39
73
|
};
|
|
40
74
|
|
|
41
75
|
const routes = props.navigation.getState()?.routes || [];
|
|
@@ -52,8 +86,8 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
52
86
|
};
|
|
53
87
|
navigator?.maxApi?.trackEvent?.('service_frame_displayed', params);
|
|
54
88
|
navigator?.maxApi?.showToastDebug?.({
|
|
55
|
-
appId: context.appId
|
|
56
|
-
message: `${
|
|
89
|
+
appId: `auto - ${context.appId}`,
|
|
90
|
+
message: `${screenName} service_frame_displayed`,
|
|
57
91
|
params,
|
|
58
92
|
});
|
|
59
93
|
|
|
@@ -65,18 +99,43 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
65
99
|
};
|
|
66
100
|
navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
|
|
67
101
|
navigator?.maxApi?.showToastDebug?.({
|
|
68
|
-
appId: context.appId
|
|
69
|
-
message: `${
|
|
102
|
+
appId: `auto - ${context.appId}`,
|
|
103
|
+
message: `${screenName} service_icon_clicked`,
|
|
70
104
|
params,
|
|
71
105
|
});
|
|
72
106
|
});
|
|
73
107
|
}, []);
|
|
74
108
|
|
|
75
109
|
return (
|
|
76
|
-
|
|
77
|
-
|
|
110
|
+
<ScreenContext.Provider
|
|
111
|
+
value={{
|
|
112
|
+
appId: context.appId,
|
|
113
|
+
code: context.code,
|
|
114
|
+
screenName,
|
|
115
|
+
autoTracking: (data: any) => {
|
|
116
|
+
navigator?.maxApi?.dispatchFunction?.('autoTracking', data);
|
|
117
|
+
},
|
|
118
|
+
onElementLoad: () => {
|
|
119
|
+
endTime.current = Date.now();
|
|
120
|
+
clearTimeout(timeout.current);
|
|
121
|
+
timeout.current = setTimeout(() => {
|
|
122
|
+
if (timeLoad.current === 0) {
|
|
123
|
+
timeLoad.current = endTime.current - startTime.current;
|
|
124
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
125
|
+
appId: `auto - ${context.appId}`,
|
|
126
|
+
message: `${screenName} screen_load_time ${timeLoad.current}`,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}, 2000);
|
|
130
|
+
},
|
|
131
|
+
}}>
|
|
132
|
+
<Component
|
|
133
|
+
heightHeader={heightHeader}
|
|
134
|
+
{...data}
|
|
135
|
+
onScreenLoad={() => {}}
|
|
136
|
+
/>
|
|
78
137
|
{showGrid && <GridSystem />}
|
|
79
|
-
|
|
138
|
+
</ScreenContext.Provider>
|
|
80
139
|
);
|
|
81
140
|
};
|
|
82
141
|
|
package/Application/types.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {Animated, FlatListProps, ViewProps} from 'react-native';
|
|
2
1
|
import {StackNavigationOptions} from '@react-navigation/stack';
|
|
3
2
|
import React from 'react';
|
|
4
|
-
import
|
|
3
|
+
import {Animated, FlatListProps, ViewProps} from 'react-native';
|
|
5
4
|
import {PopupNotifyProps} from '../Popup/types';
|
|
6
5
|
import Navigation from './Navigation';
|
|
6
|
+
import Navigator from './Navigator';
|
|
7
7
|
|
|
8
8
|
type Screen = React.ComponentType<NavigationScreenProps>;
|
|
9
9
|
|
|
@@ -95,6 +95,7 @@ export type NavigationContainerProps = {
|
|
|
95
95
|
theme: Theme;
|
|
96
96
|
maxApi: any;
|
|
97
97
|
localization?: LocalizationObject;
|
|
98
|
+
initialParams?: any;
|
|
98
99
|
};
|
|
99
100
|
|
|
100
101
|
export type NavigationScreenProps = {
|
|
@@ -129,6 +130,7 @@ export type NavigationButtonProps = {
|
|
|
129
130
|
onPress: () => void;
|
|
130
131
|
badgeType?: 'dot' | 'number';
|
|
131
132
|
badgeValue?: number;
|
|
133
|
+
accessibilityID?: string;
|
|
132
134
|
};
|
|
133
135
|
|
|
134
136
|
export type PinnedToolType = {
|
|
@@ -208,6 +210,13 @@ export type BottomTabProps = {
|
|
|
208
210
|
tabPress?: any;
|
|
209
211
|
focus?: any;
|
|
210
212
|
};
|
|
213
|
+
floatingButton?: FloatingButtonProps;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export type FloatingButtonProps = {
|
|
217
|
+
icon: string | React.ReactNode;
|
|
218
|
+
label: string;
|
|
219
|
+
onPress: () => void;
|
|
211
220
|
};
|
|
212
221
|
|
|
213
222
|
export type AnimatedHeader = {
|
package/Application/utils.tsx
CHANGED
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
} from './Components';
|
|
13
13
|
import {NavigationOptions, Theme} from './types';
|
|
14
14
|
import {Colors} from '../Consts';
|
|
15
|
-
|
|
15
|
+
import {Platform} from 'react-native';
|
|
16
|
+
const isIOS = Platform.OS === 'ios';
|
|
16
17
|
/**
|
|
17
18
|
* default options for stack screen
|
|
18
19
|
*/
|
|
@@ -141,4 +142,63 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
141
142
|
};
|
|
142
143
|
};
|
|
143
144
|
|
|
144
|
-
|
|
145
|
+
const getAccessibilityID = (
|
|
146
|
+
key = '',
|
|
147
|
+
override: string | undefined = undefined,
|
|
148
|
+
) => {
|
|
149
|
+
if (isIOS) {
|
|
150
|
+
return {
|
|
151
|
+
accessible: true,
|
|
152
|
+
testID: override || key,
|
|
153
|
+
};
|
|
154
|
+
} else {
|
|
155
|
+
return {
|
|
156
|
+
accessibilityLabel: override || key,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const formatComponentName = (word = '') => {
|
|
162
|
+
const accentsMap = {
|
|
163
|
+
a: 'á|à|ả|ã|ạ|â|ấ|ầ|ẩ|ẫ|ậ|ă|ắ|ằ|ẳ|ẵ|ặ',
|
|
164
|
+
A: 'Á|À|Ả|Ã|Ạ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|Ă|Ắ|Ằ|Ẳ|Ẵ|Ặ',
|
|
165
|
+
e: 'é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ',
|
|
166
|
+
E: 'É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ',
|
|
167
|
+
i: 'í|ì|ỉ|ĩ|ị',
|
|
168
|
+
I: 'Í|Ì|Ỉ|Ĩ|Ị',
|
|
169
|
+
o: 'ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ',
|
|
170
|
+
O: 'Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ỗ|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ',
|
|
171
|
+
u: 'ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự',
|
|
172
|
+
U: 'Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự',
|
|
173
|
+
y: 'ý|ỳ|ỷ|ỹ|ỵ',
|
|
174
|
+
Y: 'Ý|Ỳ|Ỷ|Ỹ|Ỵ',
|
|
175
|
+
d: 'đ',
|
|
176
|
+
D: 'Đ',
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
for (const [nonAccent, accentGroup] of Object.entries(accentsMap)) {
|
|
180
|
+
const accents = new RegExp(accentGroup, 'g');
|
|
181
|
+
word = word.replace(accents, nonAccent);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
word = word.replace(/\s+/g, '_').toLowerCase();
|
|
185
|
+
|
|
186
|
+
return word;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const formatNameLength = (name = '') => {
|
|
190
|
+
let formattedName = name;
|
|
191
|
+
if (formattedName.length > 100) {
|
|
192
|
+
formattedName = formattedName.substring(0, 100);
|
|
193
|
+
}
|
|
194
|
+
return formattedName;
|
|
195
|
+
};
|
|
196
|
+
export {
|
|
197
|
+
getStackOptions,
|
|
198
|
+
getDialogOptions,
|
|
199
|
+
getModalOptions,
|
|
200
|
+
getOptions,
|
|
201
|
+
formatComponentName,
|
|
202
|
+
formatNameLength,
|
|
203
|
+
getAccessibilityID,
|
|
204
|
+
};
|
package/Badge/Badge.tsx
CHANGED
|
@@ -46,7 +46,7 @@ const Badge: FC<BadgeProps> = ({label = 'Label', style, backgroundColor}) => {
|
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
48
|
<View style={[style, styles.badge, {backgroundColor: badgeColor}]}>
|
|
49
|
-
<Text color={Colors.black_01} typography={'
|
|
49
|
+
<Text color={Colors.black_01} typography={'action_xxs_bold'}>
|
|
50
50
|
{formatTitle()}
|
|
51
51
|
</Text>
|
|
52
52
|
</View>
|