@momo-kits/foundation 0.81.1-beta.6 → 0.81.1-optimize.11
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 +238 -0
- package/Application/BottomTab/BottomTabBar.tsx +291 -0
- package/Application/BottomTab/index.tsx +138 -0
- package/Application/Components.tsx +274 -211
- package/Application/ModalScreen.tsx +10 -226
- package/Application/Navigation.ts +17 -6
- package/Application/NavigationContainer.tsx +66 -65
- package/Application/Navigator.ts +106 -53
- package/Application/StackScreen.tsx +123 -28
- package/Application/index.ts +15 -9
- package/Application/types.ts +56 -31
- package/Application/utils.tsx +36 -6
- package/Assets/icon.json +83 -5
- package/Assets/icon_bank.json +506 -0
- package/Assets/language.json +3 -1
- package/Badge/Badge.tsx +56 -0
- package/Badge/BadgeDot.tsx +11 -0
- package/Badge/BadgeRibbon.tsx +125 -0
- package/Badge/Shape.tsx +29 -0
- package/Badge/index.tsx +7 -0
- package/Badge/styles.ts +58 -0
- package/Badge/types.ts +63 -0
- package/Button/index.tsx +60 -24
- package/Button/styles.ts +19 -0
- package/CheckBox/index.tsx +37 -27
- package/CheckBox/types.ts +5 -3
- package/Consts/colors+spacing+radius.ts +17 -3
- package/Icon/index.tsx +14 -9
- package/Icon/types.ts +4 -3
- package/IconButton/index.tsx +24 -15
- package/Image/index.tsx +61 -55
- package/Image/styles.ts +1 -9
- package/Image/types.ts +5 -1
- package/Input/Input.tsx +102 -25
- package/Input/InputDropDown.tsx +32 -23
- package/Input/InputMoney.tsx +67 -18
- package/Input/InputOTP.tsx +194 -148
- package/Input/InputSearch.tsx +72 -36
- package/Input/InputTextArea.tsx +33 -18
- package/Input/common.tsx +25 -16
- package/Input/index.tsx +62 -16
- package/Input/styles.ts +5 -8
- package/Layout/Card.tsx +20 -11
- package/Layout/FloatingButton.tsx +168 -0
- package/Layout/GridSystem.tsx +1 -2
- package/Layout/Item.tsx +0 -1
- package/Layout/ItemList.tsx +39 -40
- package/Layout/ItemSectionList.tsx +39 -0
- package/Layout/Screen.tsx +151 -65
- package/Layout/Section.tsx +17 -19
- package/Layout/index.ts +2 -1
- package/Layout/styles.ts +20 -15
- package/Layout/types.ts +2 -5
- package/Layout/utils.ts +2 -2
- package/Pagination/PaginationNumber.tsx +1 -1
- package/Pagination/PaginationScroll.tsx +0 -1
- package/Popup/PopupNotify.tsx +105 -37
- package/Popup/PopupPromotion.tsx +44 -9
- package/Popup/types.ts +12 -9
- package/Radio/index.tsx +35 -21
- package/Radio/types.ts +5 -3
- package/Skeleton/index.tsx +1 -1
- package/Switch/index.tsx +32 -19
- package/Switch/types.ts +5 -3
- package/Tag/index.tsx +2 -4
- package/Text/index.tsx +26 -6
- package/Text/styles.ts +38 -0
- package/Text/types.ts +25 -13
- package/Title/index.tsx +172 -63
- package/Title/styles.ts +48 -15
- package/Title/types.ts +16 -47
- package/code-scanner.js +131 -39
- package/index.ts +9 -0
- package/migrate_typo.js +56 -0
- package/package.json +8 -8
- package/verify.js +24 -6
- package/Application/BottomTab.tsx +0 -65
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
Fragment,
|
|
3
|
+
useCallback,
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
2
8
|
import {
|
|
3
9
|
Animated,
|
|
4
10
|
BackHandler,
|
|
@@ -7,123 +13,75 @@ import {
|
|
|
7
13
|
StyleSheet,
|
|
8
14
|
TouchableOpacity,
|
|
9
15
|
View,
|
|
16
|
+
ViewStyle,
|
|
10
17
|
} from 'react-native';
|
|
11
|
-
import {ApplicationContext} from './index';
|
|
18
|
+
import {ApplicationContext, MiniAppContext} from './index';
|
|
12
19
|
import {Colors, Radius, Spacing, Styles} from '../Consts';
|
|
13
20
|
import {Image} from '../Image';
|
|
14
21
|
import {
|
|
15
22
|
HeaderAnimatedProps,
|
|
16
23
|
HeaderBackgroundProps,
|
|
17
24
|
HeaderBackProps,
|
|
18
|
-
HeaderToolkitProps,
|
|
19
25
|
NavigationButtonProps,
|
|
20
26
|
TitleCustomProps,
|
|
21
27
|
} from './types';
|
|
22
28
|
import {scaleSize, Text} from '../Text';
|
|
23
29
|
import {Icon} from '../Icon';
|
|
24
30
|
import {PopupNotify} from '../Popup';
|
|
25
|
-
|
|
26
|
-
const TRIGGER_ID = "'111154000000000000";
|
|
27
|
-
|
|
28
|
-
const styles = StyleSheet.create({
|
|
29
|
-
navigationButton: {
|
|
30
|
-
height: 28,
|
|
31
|
-
width: 28,
|
|
32
|
-
borderRadius: 14,
|
|
33
|
-
borderColor: '#00000066',
|
|
34
|
-
justifyContent: 'center',
|
|
35
|
-
alignItems: 'center',
|
|
36
|
-
},
|
|
37
|
-
headerBackground: {
|
|
38
|
-
width: '100%',
|
|
39
|
-
height: undefined,
|
|
40
|
-
position: 'absolute',
|
|
41
|
-
aspectRatio: 375 / 154,
|
|
42
|
-
},
|
|
43
|
-
headerTitleContainer: {
|
|
44
|
-
alignItems: 'center',
|
|
45
|
-
justifyContent: 'center',
|
|
46
|
-
width: '100%',
|
|
47
|
-
},
|
|
48
|
-
circle: {width: 36, height: 36, borderRadius: 18},
|
|
49
|
-
square: {width: 36, height: 36, borderRadius: Radius.XS},
|
|
50
|
-
dotAvatar: {
|
|
51
|
-
position: 'absolute',
|
|
52
|
-
width: 12,
|
|
53
|
-
height: 12,
|
|
54
|
-
borderRadius: 6,
|
|
55
|
-
bottom: 0,
|
|
56
|
-
right: 0,
|
|
57
|
-
borderWidth: 1,
|
|
58
|
-
borderColor: Colors.black_01,
|
|
59
|
-
},
|
|
60
|
-
headerButton: {paddingHorizontal: 4},
|
|
61
|
-
headerRightButton: {
|
|
62
|
-
flexDirection: 'row',
|
|
63
|
-
overflow: 'hidden',
|
|
64
|
-
justifyContent: 'center',
|
|
65
|
-
alignItems: 'center',
|
|
66
|
-
paddingRight: Spacing.S,
|
|
67
|
-
},
|
|
68
|
-
toolkitContainer: {
|
|
69
|
-
marginLeft: Spacing.S,
|
|
70
|
-
padding: Spacing.XS,
|
|
71
|
-
height: 28,
|
|
72
|
-
borderRadius: 14,
|
|
73
|
-
borderColor: '#00000066',
|
|
74
|
-
justifyContent: 'center',
|
|
75
|
-
alignItems: 'center',
|
|
76
|
-
flexDirection: 'row',
|
|
77
|
-
},
|
|
78
|
-
divider: {
|
|
79
|
-
width: 1,
|
|
80
|
-
height: 12,
|
|
81
|
-
marginHorizontal: 4,
|
|
82
|
-
},
|
|
83
|
-
headerLeft: {
|
|
84
|
-
marginLeft: 12,
|
|
85
|
-
},
|
|
86
|
-
title: {
|
|
87
|
-
fontSize: scaleSize(15),
|
|
88
|
-
lineHeight: scaleSize(22),
|
|
89
|
-
fontWeight: 'bold',
|
|
90
|
-
},
|
|
91
|
-
});
|
|
31
|
+
import {Badge, BadgeDot} from '../Badge';
|
|
92
32
|
|
|
93
33
|
const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
94
34
|
icon,
|
|
95
35
|
tintColor,
|
|
96
36
|
onPress,
|
|
97
|
-
backgroundColor,
|
|
98
37
|
useBorder = true,
|
|
99
|
-
|
|
38
|
+
badgeType,
|
|
39
|
+
badgeValue,
|
|
40
|
+
accessibilityLabel = '',
|
|
100
41
|
}) => {
|
|
101
42
|
const {theme} = useContext(ApplicationContext);
|
|
102
|
-
|
|
103
|
-
|
|
43
|
+
let buttonStyle: ViewStyle = {backgroundColor: '#00000066'};
|
|
44
|
+
if (tintColor != Colors.black_01) {
|
|
45
|
+
buttonStyle = {
|
|
46
|
+
backgroundColor: 'transparent',
|
|
47
|
+
borderColor: '#00000066',
|
|
48
|
+
borderWidth: useBorder ? 0.5 : 0,
|
|
49
|
+
};
|
|
104
50
|
}
|
|
105
51
|
|
|
52
|
+
const isNumber = (label: any) => {
|
|
53
|
+
const numberRegex = /^\d+$/;
|
|
54
|
+
return numberRegex.test(String(label));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const renderBadge = useCallback(() => {
|
|
58
|
+
if (badgeType === 'dot') {
|
|
59
|
+
return <BadgeDot size="small" style={styles.badgeDot} />;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (isNumber(badgeValue)) {
|
|
63
|
+
return <Badge label={badgeValue} style={styles.badge} />;
|
|
64
|
+
}
|
|
65
|
+
}, [badgeType, badgeValue]);
|
|
66
|
+
|
|
106
67
|
return (
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
styles.navigationButton,
|
|
111
|
-
{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
size={20}
|
|
121
|
-
/>
|
|
122
|
-
</TouchableOpacity>
|
|
68
|
+
<View style={{width: scaleSize(28)}}>
|
|
69
|
+
<TouchableOpacity
|
|
70
|
+
accessibilityLabel={accessibilityLabel}
|
|
71
|
+
style={[styles.navigationButton, buttonStyle]}
|
|
72
|
+
onPress={onPress}>
|
|
73
|
+
<Icon
|
|
74
|
+
source={icon}
|
|
75
|
+
color={tintColor ?? theme.colors.text.default}
|
|
76
|
+
size={20}
|
|
77
|
+
/>
|
|
78
|
+
</TouchableOpacity>
|
|
79
|
+
{renderBadge()}
|
|
80
|
+
</View>
|
|
123
81
|
);
|
|
124
82
|
};
|
|
125
83
|
|
|
126
|
-
const HeaderTitle: React.FC<any> =
|
|
84
|
+
const HeaderTitle: React.FC<any> = props => {
|
|
127
85
|
const {theme} = useContext(ApplicationContext);
|
|
128
86
|
const opacity = props.animatedValue?.interpolate({
|
|
129
87
|
inputRange: [0, 200],
|
|
@@ -134,7 +92,7 @@ const HeaderTitle: React.FC<any> = ({accessibilityLabel = '', ...props}) => {
|
|
|
134
92
|
return (
|
|
135
93
|
<Animated.Text
|
|
136
94
|
{...props}
|
|
137
|
-
accessibilityLabel={
|
|
95
|
+
accessibilityLabel={'title_navigation_header'}
|
|
138
96
|
style={[
|
|
139
97
|
styles.title,
|
|
140
98
|
{fontFamily: `${theme.font}-Bold`, opacity, color: props.tintColor},
|
|
@@ -148,70 +106,76 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
148
106
|
preventBack,
|
|
149
107
|
onPressLeftHeader,
|
|
150
108
|
useBorder,
|
|
151
|
-
backgroundColor,
|
|
152
|
-
accessibilityLabel = '',
|
|
153
109
|
}) => {
|
|
154
|
-
const
|
|
155
|
-
const
|
|
110
|
+
const context = useContext<any>(MiniAppContext);
|
|
111
|
+
const {navigator} = useContext(ApplicationContext);
|
|
156
112
|
|
|
157
113
|
useEffect(() => {
|
|
158
114
|
const backHandler = BackHandler.addEventListener(
|
|
159
115
|
'hardwareBackPress',
|
|
160
|
-
|
|
116
|
+
goBackSafe,
|
|
161
117
|
);
|
|
162
118
|
|
|
163
119
|
return () => backHandler.remove();
|
|
164
120
|
}, []);
|
|
165
121
|
|
|
166
|
-
const
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
122
|
+
const goBackSafe = () => {
|
|
123
|
+
const goBack = () => {
|
|
124
|
+
const canGoBack = navigator?.ref?.current?.canGoBack?.();
|
|
125
|
+
const currentRoute = navigator?.ref?.current?.getCurrentRoute?.();
|
|
126
|
+
const params = {
|
|
127
|
+
appId: context.appId,
|
|
128
|
+
code: context.code,
|
|
129
|
+
screen_name: currentRoute?.params?.screen?.name ?? currentRoute?.name,
|
|
130
|
+
trigger_id: '111154000000000000',
|
|
174
131
|
icon_name: 'back',
|
|
132
|
+
};
|
|
133
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
134
|
+
appId: `auto - ${context.appId}`,
|
|
135
|
+
message: 'service_icon_clicked',
|
|
136
|
+
params,
|
|
175
137
|
});
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (
|
|
180
|
-
navigator?.
|
|
181
|
-
screen: () => (
|
|
182
|
-
<PopupNotify
|
|
183
|
-
{...preventBack}
|
|
184
|
-
primary={{
|
|
185
|
-
title: preventBack.primary.title,
|
|
186
|
-
onPress: () => {
|
|
187
|
-
preventBack?.primary.onPress();
|
|
188
|
-
navigator?.ref.current?.goBack();
|
|
189
|
-
},
|
|
190
|
-
}}
|
|
191
|
-
/>
|
|
192
|
-
),
|
|
193
|
-
});
|
|
138
|
+
navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
|
|
139
|
+
if (canGoBack) {
|
|
140
|
+
navigator?.ref?.current?.goBack?.();
|
|
141
|
+
} else if (navigator?.maxApi) {
|
|
142
|
+
navigator?.maxApi?.dismiss?.(navigator?.dismissData);
|
|
194
143
|
} else {
|
|
195
|
-
|
|
144
|
+
const currentTime = new Date().getTime();
|
|
145
|
+
const requestId = `navigationBackPress#${currentTime}`;
|
|
146
|
+
DeviceEventEmitter.emit('dismiss', {requestId});
|
|
196
147
|
}
|
|
148
|
+
onPressLeftHeader?.();
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
if (preventBack) {
|
|
152
|
+
navigator?.showModal({
|
|
153
|
+
screen: () => (
|
|
154
|
+
<PopupNotify
|
|
155
|
+
{...preventBack}
|
|
156
|
+
primary={{
|
|
157
|
+
title: preventBack.primary.title,
|
|
158
|
+
onPress: () => {
|
|
159
|
+
preventBack?.primary.onPress();
|
|
160
|
+
goBack();
|
|
161
|
+
},
|
|
162
|
+
}}
|
|
163
|
+
/>
|
|
164
|
+
),
|
|
165
|
+
});
|
|
197
166
|
} else {
|
|
198
|
-
|
|
199
|
-
const requestId = `navigationBackPress#${currentTime}`;
|
|
200
|
-
DeviceEventEmitter.emit('dismiss', {requestId});
|
|
167
|
+
goBack();
|
|
201
168
|
}
|
|
202
|
-
onPressLeftHeader?.();
|
|
203
169
|
return true;
|
|
204
170
|
};
|
|
205
|
-
|
|
206
171
|
return (
|
|
207
172
|
<View style={styles.headerLeft}>
|
|
208
173
|
<NavigationButton
|
|
174
|
+
accessibilityLabel="btn_navigation_back"
|
|
209
175
|
icon="ic_back"
|
|
210
176
|
tintColor={tintColor}
|
|
211
|
-
onPress={
|
|
212
|
-
accessibilityLabel={`${accessibilityLabel}Back`}
|
|
177
|
+
onPress={goBackSafe}
|
|
213
178
|
useBorder={useBorder}
|
|
214
|
-
backgroundColor={backgroundColor}
|
|
215
179
|
/>
|
|
216
180
|
</View>
|
|
217
181
|
);
|
|
@@ -219,15 +183,18 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
219
183
|
|
|
220
184
|
const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
221
185
|
image,
|
|
222
|
-
backgroundColor,
|
|
223
186
|
animatedValue,
|
|
224
|
-
|
|
187
|
+
useSurface = false,
|
|
225
188
|
}) => {
|
|
226
189
|
const {theme} = useContext(ApplicationContext);
|
|
227
190
|
let headerImage = theme.assets?.headerBackground;
|
|
191
|
+
let backgroundColor;
|
|
228
192
|
if (image === null) {
|
|
229
193
|
headerImage = undefined;
|
|
230
194
|
}
|
|
195
|
+
if (useSurface) {
|
|
196
|
+
backgroundColor = theme.colors.background.surface;
|
|
197
|
+
}
|
|
231
198
|
const opacity = animatedValue?.interpolate({
|
|
232
199
|
inputRange: [0, 114],
|
|
233
200
|
outputRange: [0, 1],
|
|
@@ -239,15 +206,17 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
|
239
206
|
style={[
|
|
240
207
|
Styles.flex,
|
|
241
208
|
{
|
|
242
|
-
backgroundColor
|
|
209
|
+
backgroundColor,
|
|
243
210
|
overflow: 'hidden',
|
|
244
|
-
borderBottomWidth:
|
|
211
|
+
borderBottomWidth: useSurface ? 1 : 0,
|
|
245
212
|
borderColor: theme.colors.border.default,
|
|
246
213
|
opacity,
|
|
247
214
|
},
|
|
248
215
|
]}>
|
|
249
216
|
<StatusBar
|
|
250
217
|
barStyle={headerImage || theme.dark ? 'light-content' : 'dark-content'}
|
|
218
|
+
translucent={true}
|
|
219
|
+
backgroundColor={'transparent'}
|
|
251
220
|
/>
|
|
252
221
|
{!!headerImage && (
|
|
253
222
|
<Image
|
|
@@ -279,10 +248,13 @@ const HeaderCustom: React.FC<TitleCustomProps> = ({
|
|
|
279
248
|
)}
|
|
280
249
|
</View>
|
|
281
250
|
<View style={[Styles.flex, {paddingHorizontal: 8}]}>
|
|
282
|
-
<Text
|
|
251
|
+
<Text
|
|
252
|
+
accessibilityLabel={'title_navigation_header'}
|
|
253
|
+
typography="header_default_bold"
|
|
254
|
+
color={tintColor}>
|
|
283
255
|
{title}
|
|
284
256
|
</Text>
|
|
285
|
-
<Text typography="
|
|
257
|
+
<Text typography="description_default_regular" color={tintColor}>
|
|
286
258
|
{subTitle}
|
|
287
259
|
</Text>
|
|
288
260
|
</View>
|
|
@@ -322,93 +294,111 @@ const HeaderRightAction: React.FC<any> = ({children, ...restProps}) => {
|
|
|
322
294
|
return <View style={styles.headerRightButton}>{renderAction()}</View>;
|
|
323
295
|
};
|
|
324
296
|
|
|
325
|
-
const HeaderToolkitAction: React.FC<any> = ({
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
297
|
+
const HeaderToolkitAction: React.FC<any> = ({
|
|
298
|
+
tintColor,
|
|
299
|
+
pinnedTool,
|
|
300
|
+
runtimeTools = [],
|
|
301
|
+
preventClose,
|
|
302
|
+
}) => {
|
|
303
|
+
const {navigator} = useContext(ApplicationContext);
|
|
304
|
+
const miniContext = useContext<any>(MiniAppContext);
|
|
305
|
+
const [toolConfig, setToolConfig] = useState<any>();
|
|
306
|
+
const {onAction} = toolConfig ?? {};
|
|
329
307
|
|
|
330
308
|
let backgroundColor;
|
|
331
309
|
if (tintColor != Colors.black_01) {
|
|
332
|
-
backgroundColor =
|
|
310
|
+
backgroundColor = 'transparent';
|
|
333
311
|
}
|
|
334
312
|
|
|
335
313
|
useEffect(() => {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
let addFavorite: any;
|
|
343
|
-
let removeFavorite: any;
|
|
344
|
-
if (appCode) {
|
|
345
|
-
const addSchema = `observerToolkit_addFavorite_${appCode}`;
|
|
346
|
-
const removeSchema = `observerToolkit_removeFavorite_${appCode}`;
|
|
347
|
-
addFavorite = navigator?.requestApi(
|
|
348
|
-
'observer',
|
|
349
|
-
[addSchema],
|
|
350
|
-
(data: any) => {
|
|
351
|
-
if (data?.status) {
|
|
352
|
-
setToolConfig({
|
|
353
|
-
...(toolConfig as HeaderToolkitProps),
|
|
354
|
-
hidden: true,
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
},
|
|
358
|
-
);
|
|
359
|
-
addFavorite = navigator?.requestApi(
|
|
360
|
-
'observer',
|
|
361
|
-
[removeSchema],
|
|
362
|
-
(data: any) => {
|
|
363
|
-
if (data?.status) {
|
|
364
|
-
setToolConfig({
|
|
365
|
-
...(toolConfig as HeaderToolkitProps),
|
|
366
|
-
hidden: false,
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
},
|
|
370
|
-
);
|
|
314
|
+
if (miniContext?.toolkitConfig?.hidden === false) {
|
|
315
|
+
if (navigator?.toolkitConfig) {
|
|
316
|
+
setToolConfig(navigator?.toolkitConfig);
|
|
317
|
+
} else {
|
|
318
|
+
getToolkitConfig();
|
|
319
|
+
}
|
|
371
320
|
}
|
|
321
|
+
}, []);
|
|
372
322
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
323
|
+
const getToolkitConfig = () => {
|
|
324
|
+
navigator?.maxApi?.dispatchFunction?.(
|
|
325
|
+
'getToolsConfig',
|
|
326
|
+
[undefined],
|
|
327
|
+
(config: any) => {
|
|
328
|
+
navigator.toolkitConfig = config;
|
|
329
|
+
setToolConfig(navigator?.toolkitConfig);
|
|
330
|
+
},
|
|
331
|
+
);
|
|
382
332
|
};
|
|
383
333
|
|
|
384
334
|
const onMore = () => {
|
|
385
335
|
onAction?.('onMore');
|
|
386
|
-
navigator?.
|
|
336
|
+
navigator?.maxApi?.dispatchFunction?.(
|
|
337
|
+
'showTools',
|
|
338
|
+
{runtimeTools},
|
|
339
|
+
(res: {item: {action?: string; key: string}}) => {
|
|
340
|
+
const {item} = res;
|
|
341
|
+
navigator?.toolkitCallback?.(item);
|
|
342
|
+
getToolkitConfig();
|
|
343
|
+
},
|
|
344
|
+
);
|
|
387
345
|
};
|
|
388
346
|
|
|
389
347
|
const onClose = () => {
|
|
390
|
-
|
|
391
|
-
|
|
348
|
+
if (preventClose) {
|
|
349
|
+
navigator?.showModal({
|
|
350
|
+
screen: () => (
|
|
351
|
+
<PopupNotify
|
|
352
|
+
{...preventClose}
|
|
353
|
+
primary={{
|
|
354
|
+
title: preventClose.primary.title,
|
|
355
|
+
onPress: () => {
|
|
356
|
+
preventClose?.primary.onPress();
|
|
357
|
+
navigator?.maxApi?.dispatchFunction?.(
|
|
358
|
+
'dismiss',
|
|
359
|
+
undefined,
|
|
360
|
+
undefined,
|
|
361
|
+
);
|
|
362
|
+
},
|
|
363
|
+
}}
|
|
364
|
+
/>
|
|
365
|
+
),
|
|
366
|
+
});
|
|
367
|
+
} else {
|
|
368
|
+
navigator?.maxApi?.dispatchFunction?.('dismiss', undefined, undefined);
|
|
369
|
+
}
|
|
392
370
|
};
|
|
393
371
|
|
|
394
|
-
const
|
|
395
|
-
|
|
372
|
+
const renderPinnedTool = () => {
|
|
373
|
+
const pinKey = pinnedTool?.key || toolConfig?.pinnedTool?.key;
|
|
374
|
+
const pinTool = toolConfig?.tools?.find((i: any) => i.key === pinKey);
|
|
375
|
+
const {badgeValue, badgeType} = pinnedTool ?? {};
|
|
376
|
+
|
|
377
|
+
if (pinTool)
|
|
396
378
|
return (
|
|
397
379
|
<NavigationButton
|
|
398
|
-
accessibilityLabel=
|
|
399
|
-
icon={
|
|
380
|
+
accessibilityLabel="btn_navigation_pin"
|
|
381
|
+
icon={pinTool.icon as string}
|
|
400
382
|
tintColor={tintColor}
|
|
401
|
-
|
|
383
|
+
badgeValue={badgeValue}
|
|
384
|
+
badgeType={badgeType}
|
|
385
|
+
onPress={() => {
|
|
386
|
+
navigator?.maxApi?.dispatchFunction?.(
|
|
387
|
+
'onToolAction',
|
|
388
|
+
[pinTool?.key],
|
|
389
|
+
() => {
|
|
390
|
+
getToolkitConfig();
|
|
391
|
+
},
|
|
392
|
+
);
|
|
393
|
+
navigator?.toolkitCallback?.(pinTool.key);
|
|
394
|
+
}}
|
|
402
395
|
/>
|
|
403
396
|
);
|
|
404
|
-
}
|
|
405
|
-
return null;
|
|
406
397
|
};
|
|
407
|
-
|
|
408
398
|
if (toolConfig) {
|
|
409
399
|
return (
|
|
410
400
|
<View style={styles.headerRightButton}>
|
|
411
|
-
{
|
|
401
|
+
{renderPinnedTool()}
|
|
412
402
|
<View
|
|
413
403
|
style={[
|
|
414
404
|
styles.toolkitContainer,
|
|
@@ -418,13 +408,13 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
|
|
|
418
408
|
},
|
|
419
409
|
]}>
|
|
420
410
|
<TouchableOpacity
|
|
421
|
-
accessibilityLabel={'
|
|
411
|
+
accessibilityLabel={'btn_navigation_more'}
|
|
422
412
|
onPress={onMore}>
|
|
423
413
|
<Icon color={tintColor} source="navigation_more_horiz" size={20} />
|
|
424
414
|
</TouchableOpacity>
|
|
425
415
|
<View style={[styles.divider, {backgroundColor: tintColor}]} />
|
|
426
416
|
<TouchableOpacity
|
|
427
|
-
accessibilityLabel={
|
|
417
|
+
accessibilityLabel={'btn_navigation_close'}
|
|
428
418
|
onPress={onClose}>
|
|
429
419
|
<Icon
|
|
430
420
|
color={tintColor}
|
|
@@ -443,7 +433,7 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
|
|
|
443
433
|
const HeaderAnimated: React.FC<HeaderAnimatedProps> = ({
|
|
444
434
|
animatedValue,
|
|
445
435
|
image,
|
|
446
|
-
|
|
436
|
+
children,
|
|
447
437
|
}) => {
|
|
448
438
|
const scale = animatedValue.interpolate({
|
|
449
439
|
inputRange: [-300, 0, 300],
|
|
@@ -462,24 +452,97 @@ const HeaderAnimated: React.FC<HeaderAnimatedProps> = ({
|
|
|
462
452
|
});
|
|
463
453
|
|
|
464
454
|
return (
|
|
465
|
-
<
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
455
|
+
<Animated.View
|
|
456
|
+
style={{
|
|
457
|
+
height: 210,
|
|
458
|
+
opacity: opacity,
|
|
459
|
+
transform: [{scale}, {translateY}],
|
|
460
|
+
}}>
|
|
461
|
+
{children ?? (
|
|
472
462
|
<Image
|
|
473
463
|
source={{
|
|
474
464
|
uri: image,
|
|
475
465
|
}}
|
|
476
466
|
style={{width: '100%', height: '100%'}}
|
|
477
467
|
/>
|
|
478
|
-
|
|
479
|
-
</
|
|
468
|
+
)}
|
|
469
|
+
</Animated.View>
|
|
480
470
|
);
|
|
481
471
|
};
|
|
482
472
|
|
|
473
|
+
const styles = StyleSheet.create({
|
|
474
|
+
navigationButton: {
|
|
475
|
+
height: 28,
|
|
476
|
+
width: 28,
|
|
477
|
+
borderRadius: 14,
|
|
478
|
+
justifyContent: 'center',
|
|
479
|
+
alignItems: 'center',
|
|
480
|
+
},
|
|
481
|
+
headerBackground: {
|
|
482
|
+
width: '100%',
|
|
483
|
+
height: undefined,
|
|
484
|
+
position: 'absolute',
|
|
485
|
+
aspectRatio: 375 / 154,
|
|
486
|
+
},
|
|
487
|
+
headerTitleContainer: {
|
|
488
|
+
alignItems: 'center',
|
|
489
|
+
justifyContent: 'center',
|
|
490
|
+
width: '100%',
|
|
491
|
+
},
|
|
492
|
+
circle: {width: 36, height: 36, borderRadius: 18},
|
|
493
|
+
square: {width: 36, height: 36, borderRadius: Radius.XS},
|
|
494
|
+
dotAvatar: {
|
|
495
|
+
position: 'absolute',
|
|
496
|
+
width: 12,
|
|
497
|
+
height: 12,
|
|
498
|
+
borderRadius: 6,
|
|
499
|
+
bottom: 0,
|
|
500
|
+
right: 0,
|
|
501
|
+
borderWidth: 1,
|
|
502
|
+
borderColor: Colors.black_01,
|
|
503
|
+
},
|
|
504
|
+
headerButton: {paddingHorizontal: 4},
|
|
505
|
+
headerRightButton: {
|
|
506
|
+
flexDirection: 'row',
|
|
507
|
+
justifyContent: 'center',
|
|
508
|
+
alignItems: 'center',
|
|
509
|
+
paddingRight: Spacing.M,
|
|
510
|
+
},
|
|
511
|
+
toolkitContainer: {
|
|
512
|
+
marginLeft: Spacing.S,
|
|
513
|
+
padding: Spacing.XS,
|
|
514
|
+
height: 28,
|
|
515
|
+
borderRadius: 14,
|
|
516
|
+
borderColor: '#00000066',
|
|
517
|
+
justifyContent: 'center',
|
|
518
|
+
alignItems: 'center',
|
|
519
|
+
flexDirection: 'row',
|
|
520
|
+
},
|
|
521
|
+
divider: {
|
|
522
|
+
width: 1,
|
|
523
|
+
height: 12,
|
|
524
|
+
marginHorizontal: 4,
|
|
525
|
+
},
|
|
526
|
+
headerLeft: {
|
|
527
|
+
marginLeft: 12,
|
|
528
|
+
},
|
|
529
|
+
title: {
|
|
530
|
+
fontSize: scaleSize(15),
|
|
531
|
+
lineHeight: scaleSize(22),
|
|
532
|
+
fontWeight: 'bold',
|
|
533
|
+
},
|
|
534
|
+
badge: {
|
|
535
|
+
position: 'absolute',
|
|
536
|
+
top: -Spacing.S,
|
|
537
|
+
right: -6,
|
|
538
|
+
},
|
|
539
|
+
badgeDot: {
|
|
540
|
+
position: 'absolute',
|
|
541
|
+
top: -Spacing.XS,
|
|
542
|
+
right: -Spacing.XS,
|
|
543
|
+
},
|
|
544
|
+
});
|
|
545
|
+
|
|
483
546
|
export {
|
|
484
547
|
NavigationButton,
|
|
485
548
|
HeaderTitle,
|