@momo-kits/foundation 0.81.51-beta.0 → 0.81.52
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/index.tsx → BottomTab.tsx} +18 -42
- package/Application/Components.tsx +91 -356
- package/Application/ModalScreen.tsx +185 -14
- package/Application/Navigation.ts +19 -5
- package/Application/NavigationContainer.tsx +72 -62
- package/Application/Navigator.ts +48 -154
- package/Application/StackScreen.tsx +32 -289
- package/Application/index.ts +15 -13
- package/Application/types.ts +35 -81
- package/Application/utils.tsx +30 -76
- package/Assets/icon_bank.json +1 -1
- package/Badge/Badge.tsx +1 -1
- package/Badge/index.tsx +1 -2
- package/Badge/styles.ts +6 -50
- package/Button/index.tsx +26 -44
- package/CheckBox/index.tsx +26 -37
- package/CheckBox/types.ts +3 -5
- package/Consts/colors+spacing+radius.ts +0 -14
- package/Icon/index.tsx +8 -9
- package/Icon/types.ts +2 -2
- package/IconButton/index.tsx +14 -24
- package/Image/index.tsx +8 -23
- package/Image/types.ts +0 -2
- package/Input/Input.tsx +26 -116
- package/Input/InputDropDown.tsx +51 -66
- package/Input/InputMoney.tsx +15 -106
- package/Input/InputOTP.tsx +26 -49
- package/Input/InputSearch.tsx +99 -252
- package/Input/InputTextArea.tsx +6 -26
- package/Input/common.tsx +22 -48
- package/Input/index.tsx +77 -112
- package/Input/styles.ts +11 -48
- package/Input/utils.ts +1 -1
- package/Layout/Card.tsx +3 -4
- package/Layout/GridSystem.tsx +1 -1
- package/Layout/ItemList.tsx +2 -3
- package/Layout/Screen.tsx +121 -242
- package/Layout/Section.tsx +3 -4
- package/Layout/styles.ts +13 -11
- package/Layout/types.ts +1 -1
- package/Layout/utils.ts +4 -4
- package/Loader/index.tsx +0 -2
- package/Pagination/PaginationScroll.tsx +2 -2
- package/Pagination/styles.ts +1 -1
- package/Popup/PopupNotify.tsx +46 -57
- package/Popup/PopupPromotion.tsx +8 -6
- package/Popup/types.ts +7 -1
- package/Radio/index.tsx +20 -35
- package/Radio/types.ts +3 -5
- package/Switch/index.tsx +18 -32
- package/Switch/types.ts +3 -5
- package/Tag/index.tsx +2 -9
- package/Tag/styles.ts +2 -3
- package/Tag/types.ts +0 -12
- package/Text/index.tsx +5 -24
- package/Text/styles.ts +8 -8
- package/Title/index.tsx +103 -170
- package/Title/styles.ts +9 -36
- package/Title/types.ts +48 -16
- package/code-scanner.js +16 -125
- package/index.ts +0 -7
- package/package.json +7 -8
- package/publish.sh +21 -16
- package/tsconfig.json +1 -1
- package/Application/BottomSheet.tsx +0 -216
- package/Application/BottomTab/BottomTabBar.tsx +0 -278
- package/Application/Localize.ts +0 -44
- package/Application/constants.ts +0 -9
- package/Badge/BadgeDotAnimation.tsx +0 -95
- package/Input/TextTyping.tsx +0 -113
- package/Layout/FloatingButton.tsx +0 -168
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import React, {
|
|
2
|
-
|
|
2
|
+
Fragment,
|
|
3
3
|
useCallback,
|
|
4
4
|
useContext,
|
|
5
5
|
useEffect,
|
|
6
|
-
useRef,
|
|
7
6
|
useState,
|
|
8
7
|
} from 'react';
|
|
9
8
|
import {
|
|
10
|
-
Alert,
|
|
11
9
|
Animated,
|
|
12
10
|
BackHandler,
|
|
13
11
|
DeviceEventEmitter,
|
|
14
|
-
Dimensions,
|
|
15
12
|
StatusBar,
|
|
16
13
|
StyleSheet,
|
|
17
14
|
TouchableOpacity,
|
|
@@ -32,18 +29,7 @@ import {scaleSize, Text} from '../Text';
|
|
|
32
29
|
import {Icon} from '../Icon';
|
|
33
30
|
import {PopupNotify} from '../Popup';
|
|
34
31
|
import {Badge, BadgeDot} from '../Badge';
|
|
35
|
-
|
|
36
|
-
import Navigation from './Navigation';
|
|
37
|
-
import {InputRef, InputSearch, InputSearchProps} from '../Input';
|
|
38
|
-
import {BadgeDotAnimation} from '../Badge';
|
|
39
|
-
|
|
40
|
-
const SCREEN_PADDING = 12;
|
|
41
|
-
const BACK_WIDTH = 28;
|
|
42
|
-
const {width: screenWidth} = Dimensions.get('window');
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* default navigation button used header nav
|
|
46
|
-
*/
|
|
32
|
+
|
|
47
33
|
const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
48
34
|
icon,
|
|
49
35
|
tintColor,
|
|
@@ -51,11 +37,10 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
51
37
|
useBorder = true,
|
|
52
38
|
badgeType,
|
|
53
39
|
badgeValue,
|
|
54
|
-
accessibilityLabel = '',
|
|
55
40
|
}) => {
|
|
56
41
|
const {theme} = useContext(ApplicationContext);
|
|
57
42
|
let buttonStyle: ViewStyle = {backgroundColor: '#00000066'};
|
|
58
|
-
if (tintColor
|
|
43
|
+
if (tintColor != Colors.black_01) {
|
|
59
44
|
buttonStyle = {
|
|
60
45
|
backgroundColor: 'transparent',
|
|
61
46
|
borderColor: '#00000066',
|
|
@@ -72,11 +57,6 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
72
57
|
if (badgeType === 'dot') {
|
|
73
58
|
return <BadgeDot size="small" style={styles.badgeDot} />;
|
|
74
59
|
}
|
|
75
|
-
if (badgeType === 'dot-animation') {
|
|
76
|
-
return (
|
|
77
|
-
<BadgeDotAnimation size="small" style={styles.badgeDotAnimation} />
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
60
|
|
|
81
61
|
if (isNumber(badgeValue)) {
|
|
82
62
|
return <Badge label={badgeValue} style={styles.badge} />;
|
|
@@ -84,9 +64,8 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
84
64
|
}, [badgeType, badgeValue]);
|
|
85
65
|
|
|
86
66
|
return (
|
|
87
|
-
<View style={{width: 28}}>
|
|
67
|
+
<View style={{width: scaleSize(28)}}>
|
|
88
68
|
<TouchableOpacity
|
|
89
|
-
accessibilityLabel={accessibilityLabel}
|
|
90
69
|
style={[styles.navigationButton, buttonStyle]}
|
|
91
70
|
onPress={onPress}>
|
|
92
71
|
<Icon
|
|
@@ -100,23 +79,17 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
100
79
|
);
|
|
101
80
|
};
|
|
102
81
|
|
|
103
|
-
/**
|
|
104
|
-
* default header title used for nav
|
|
105
|
-
*/
|
|
106
82
|
const HeaderTitle: React.FC<any> = props => {
|
|
107
83
|
const {theme} = useContext(ApplicationContext);
|
|
108
|
-
const opacity = props.animatedValue?.interpolate(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
);
|
|
84
|
+
const opacity = props.animatedValue?.interpolate({
|
|
85
|
+
inputRange: [0, 200],
|
|
86
|
+
outputRange: [0, 1],
|
|
87
|
+
extrapolate: 'clamp',
|
|
88
|
+
});
|
|
115
89
|
|
|
116
90
|
return (
|
|
117
91
|
<Animated.Text
|
|
118
92
|
{...props}
|
|
119
|
-
accessibilityLabel={'title_navigation_header'}
|
|
120
93
|
style={[
|
|
121
94
|
styles.title,
|
|
122
95
|
{fontFamily: `${theme.font}-Bold`, opacity, color: props.tintColor},
|
|
@@ -125,22 +98,19 @@ const HeaderTitle: React.FC<any> = props => {
|
|
|
125
98
|
);
|
|
126
99
|
};
|
|
127
100
|
|
|
128
|
-
/**
|
|
129
|
-
* default header left used for nav
|
|
130
|
-
*/
|
|
131
101
|
const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
132
102
|
tintColor,
|
|
133
103
|
preventBack,
|
|
134
104
|
onPressLeftHeader,
|
|
135
105
|
useBorder,
|
|
136
106
|
}) => {
|
|
137
|
-
const context = useContext
|
|
107
|
+
const context = useContext(MiniAppContext);
|
|
138
108
|
const {navigator} = useContext(ApplicationContext);
|
|
139
109
|
|
|
140
110
|
useEffect(() => {
|
|
141
111
|
const backHandler = BackHandler.addEventListener(
|
|
142
112
|
'hardwareBackPress',
|
|
143
|
-
goBackSafe
|
|
113
|
+
goBackSafe,
|
|
144
114
|
);
|
|
145
115
|
|
|
146
116
|
return () => backHandler.remove();
|
|
@@ -148,25 +118,20 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
148
118
|
|
|
149
119
|
const goBackSafe = () => {
|
|
150
120
|
const goBack = () => {
|
|
151
|
-
const canGoBack = navigator?.ref
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
appId: `auto - ${context.appId}`,
|
|
162
|
-
message: 'service_icon_clicked',
|
|
163
|
-
params,
|
|
164
|
-
});
|
|
165
|
-
navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
|
|
121
|
+
const canGoBack = navigator?.ref.current?.canGoBack();
|
|
122
|
+
if (!canGoBack) {
|
|
123
|
+
const currentRoute = navigator?.ref?.current.getCurrentRoute();
|
|
124
|
+
navigator?.maxApi?.trackEvent?.('service_icon_clicked', {
|
|
125
|
+
...context,
|
|
126
|
+
screen_name: currentRoute?.params?.screen?.name ?? currentRoute?.name,
|
|
127
|
+
trigger_id: '111154000000000000',
|
|
128
|
+
icon_name: 'back',
|
|
129
|
+
});
|
|
130
|
+
}
|
|
166
131
|
if (canGoBack) {
|
|
167
|
-
navigator?.ref
|
|
132
|
+
navigator?.ref.current?.goBack();
|
|
168
133
|
} else if (navigator?.maxApi) {
|
|
169
|
-
navigator?.maxApi?.dismiss
|
|
134
|
+
navigator?.maxApi?.dismiss(navigator.dismissData);
|
|
170
135
|
} else {
|
|
171
136
|
const currentTime = new Date().getTime();
|
|
172
137
|
const requestId = `navigationBackPress#${currentTime}`;
|
|
@@ -199,7 +164,6 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
199
164
|
return (
|
|
200
165
|
<View style={styles.headerLeft}>
|
|
201
166
|
<NavigationButton
|
|
202
|
-
accessibilityLabel="btn_navigation_back"
|
|
203
167
|
icon="ic_back"
|
|
204
168
|
tintColor={tintColor}
|
|
205
169
|
onPress={goBackSafe}
|
|
@@ -209,23 +173,17 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
209
173
|
);
|
|
210
174
|
};
|
|
211
175
|
|
|
212
|
-
/**
|
|
213
|
-
* header background for default
|
|
214
|
-
*/
|
|
215
176
|
const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
216
177
|
image,
|
|
178
|
+
backgroundColor,
|
|
217
179
|
animatedValue,
|
|
218
|
-
|
|
180
|
+
useBorder = false,
|
|
219
181
|
}) => {
|
|
220
182
|
const {theme} = useContext(ApplicationContext);
|
|
221
183
|
let headerImage = theme.assets?.headerBackground;
|
|
222
|
-
let backgroundColor;
|
|
223
184
|
if (image === null) {
|
|
224
185
|
headerImage = undefined;
|
|
225
186
|
}
|
|
226
|
-
if (useSurface) {
|
|
227
|
-
backgroundColor = theme.colors.background.surface;
|
|
228
|
-
}
|
|
229
187
|
const opacity = animatedValue?.interpolate({
|
|
230
188
|
inputRange: [0, 114],
|
|
231
189
|
outputRange: [0, 1],
|
|
@@ -237,9 +195,9 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
|
237
195
|
style={[
|
|
238
196
|
Styles.flex,
|
|
239
197
|
{
|
|
240
|
-
backgroundColor,
|
|
198
|
+
backgroundColor: backgroundColor ?? theme.colors.background.default,
|
|
241
199
|
overflow: 'hidden',
|
|
242
|
-
borderBottomWidth:
|
|
200
|
+
borderBottomWidth: useBorder ? 1 : 0,
|
|
243
201
|
borderColor: theme.colors.border.default,
|
|
244
202
|
opacity,
|
|
245
203
|
},
|
|
@@ -260,10 +218,6 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
|
260
218
|
);
|
|
261
219
|
};
|
|
262
220
|
|
|
263
|
-
/**
|
|
264
|
-
* Header custom with image, title, subtitle
|
|
265
|
-
* @constructor
|
|
266
|
-
*/
|
|
267
221
|
const HeaderCustom: React.FC<TitleCustomProps> = ({
|
|
268
222
|
title,
|
|
269
223
|
subTitle,
|
|
@@ -273,7 +227,7 @@ const HeaderCustom: React.FC<TitleCustomProps> = ({
|
|
|
273
227
|
tintColor,
|
|
274
228
|
dotColor,
|
|
275
229
|
}) => {
|
|
276
|
-
const avatarStyle = imageShape
|
|
230
|
+
const avatarStyle = imageShape == 'circle' ? styles.circle : styles.square;
|
|
277
231
|
const header = (
|
|
278
232
|
<View style={Styles.row}>
|
|
279
233
|
<View>
|
|
@@ -283,10 +237,7 @@ const HeaderCustom: React.FC<TitleCustomProps> = ({
|
|
|
283
237
|
)}
|
|
284
238
|
</View>
|
|
285
239
|
<View style={[Styles.flex, {paddingHorizontal: 8}]}>
|
|
286
|
-
<Text
|
|
287
|
-
accessibilityLabel={'title_navigation_header'}
|
|
288
|
-
typography="header_default_bold"
|
|
289
|
-
color={tintColor}>
|
|
240
|
+
<Text typography="header_default_bold" color={tintColor}>
|
|
290
241
|
{title}
|
|
291
242
|
</Text>
|
|
292
243
|
<Text typography="description_default_regular" color={tintColor}>
|
|
@@ -298,55 +249,51 @@ const HeaderCustom: React.FC<TitleCustomProps> = ({
|
|
|
298
249
|
return <View style={styles.headerTitleContainer}>{content ?? header}</View>;
|
|
299
250
|
};
|
|
300
251
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
252
|
+
const HeaderRightAction: React.FC<any> = ({children, ...restProps}) => {
|
|
253
|
+
const validateType = (child: React.ReactElement) => {
|
|
254
|
+
const valid = child?.type === NavigationButton || child?.type == Fragment;
|
|
255
|
+
if (__DEV__ && !valid) {
|
|
256
|
+
console.warn(
|
|
257
|
+
'HeaderRightAction contains element type of NavigationButton, Please check again.',
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
return child;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const renderAction = () => {
|
|
264
|
+
if (Array.isArray(children)) {
|
|
265
|
+
return children.map((child, index) => {
|
|
266
|
+
return (
|
|
267
|
+
<View key={`HeaderRightAction ${index}`} style={styles.headerButton}>
|
|
268
|
+
{React.cloneElement(validateType(child), {...restProps})}
|
|
269
|
+
</View>
|
|
270
|
+
);
|
|
271
|
+
});
|
|
309
272
|
}
|
|
273
|
+
|
|
310
274
|
return (
|
|
311
|
-
<View style={styles.
|
|
312
|
-
{
|
|
313
|
-
return (
|
|
314
|
-
<View
|
|
315
|
-
key={`HeaderRightAction ${index}`}
|
|
316
|
-
style={{
|
|
317
|
-
marginLeft: index !== 0 ? Spacing.S : 0,
|
|
318
|
-
}}>
|
|
319
|
-
<NavigationButton {...item} tintColor={props?.tintColor} />
|
|
320
|
-
</View>
|
|
321
|
-
);
|
|
322
|
-
})}
|
|
275
|
+
<View style={styles.headerButton}>
|
|
276
|
+
{React.cloneElement(validateType(children), {...restProps})}
|
|
323
277
|
</View>
|
|
324
278
|
);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
return (
|
|
328
|
-
<View style={styles.headerRightButton} onLayout={onLayout}>
|
|
329
|
-
{children ?? <HeaderToolkitAction {...props} />}
|
|
330
|
-
</View>
|
|
331
|
-
);
|
|
279
|
+
};
|
|
280
|
+
return <View style={styles.headerRightButton}>{renderAction()}</View>;
|
|
332
281
|
};
|
|
333
282
|
|
|
334
|
-
/**
|
|
335
|
-
* Header toolkit action
|
|
336
|
-
*/
|
|
337
283
|
const HeaderToolkitAction: React.FC<any> = ({
|
|
338
284
|
tintColor,
|
|
339
285
|
pinnedTool,
|
|
340
|
-
|
|
286
|
+
runtimeTools = [],
|
|
287
|
+
preventBack,
|
|
341
288
|
}) => {
|
|
342
|
-
const {navigator} = useContext(ApplicationContext);
|
|
343
|
-
const miniContext = useContext
|
|
289
|
+
const {theme, navigator} = useContext(ApplicationContext);
|
|
290
|
+
const miniContext = useContext(MiniAppContext);
|
|
344
291
|
const [toolConfig, setToolConfig] = useState<any>();
|
|
345
292
|
const {onAction} = toolConfig ?? {};
|
|
346
293
|
|
|
347
294
|
let backgroundColor;
|
|
348
|
-
if (tintColor
|
|
349
|
-
backgroundColor =
|
|
295
|
+
if (tintColor != Colors.black_01) {
|
|
296
|
+
backgroundColor = theme.colors.background.surface;
|
|
350
297
|
}
|
|
351
298
|
|
|
352
299
|
useEffect(() => {
|
|
@@ -366,39 +313,37 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
366
313
|
(config: any) => {
|
|
367
314
|
navigator.toolkitConfig = config;
|
|
368
315
|
setToolConfig(navigator?.toolkitConfig);
|
|
369
|
-
}
|
|
316
|
+
},
|
|
370
317
|
);
|
|
371
318
|
};
|
|
372
319
|
|
|
373
320
|
const onMore = () => {
|
|
374
321
|
onAction?.('onMore');
|
|
375
322
|
navigator?.maxApi?.dispatchFunction?.(
|
|
376
|
-
'
|
|
377
|
-
{
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
],
|
|
323
|
+
'showTools',
|
|
324
|
+
{runtimeTools},
|
|
325
|
+
(res: {item: {action?: string; key: string}}) => {
|
|
326
|
+
const {item} = res;
|
|
327
|
+
navigator?.toolkitCallback?.(item);
|
|
328
|
+
getToolkitConfig();
|
|
383
329
|
},
|
|
384
|
-
() => {}
|
|
385
330
|
);
|
|
386
331
|
};
|
|
387
332
|
|
|
388
333
|
const onClose = () => {
|
|
389
|
-
if (
|
|
334
|
+
if (preventBack) {
|
|
390
335
|
navigator?.showModal({
|
|
391
336
|
screen: () => (
|
|
392
337
|
<PopupNotify
|
|
393
|
-
{...
|
|
338
|
+
{...preventBack}
|
|
394
339
|
primary={{
|
|
395
|
-
title:
|
|
340
|
+
title: preventBack.primary.title,
|
|
396
341
|
onPress: () => {
|
|
397
|
-
|
|
342
|
+
preventBack?.primary.onPress();
|
|
398
343
|
navigator?.maxApi?.dispatchFunction?.(
|
|
399
344
|
'dismiss',
|
|
400
345
|
undefined,
|
|
401
|
-
undefined
|
|
346
|
+
undefined,
|
|
402
347
|
);
|
|
403
348
|
},
|
|
404
349
|
}}
|
|
@@ -418,7 +363,6 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
418
363
|
if (pinTool)
|
|
419
364
|
return (
|
|
420
365
|
<NavigationButton
|
|
421
|
-
accessibilityLabel="btn_navigation_pin"
|
|
422
366
|
icon={pinTool.icon as string}
|
|
423
367
|
tintColor={tintColor}
|
|
424
368
|
badgeValue={badgeValue}
|
|
@@ -426,19 +370,20 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
426
370
|
onPress={() => {
|
|
427
371
|
navigator?.maxApi?.dispatchFunction?.(
|
|
428
372
|
'onToolAction',
|
|
429
|
-
|
|
373
|
+
[pinTool?.key],
|
|
430
374
|
() => {
|
|
431
375
|
getToolkitConfig();
|
|
432
|
-
}
|
|
376
|
+
},
|
|
433
377
|
);
|
|
434
378
|
navigator?.toolkitCallback?.(pinTool.key);
|
|
435
379
|
}}
|
|
436
380
|
/>
|
|
437
381
|
);
|
|
438
382
|
};
|
|
383
|
+
|
|
439
384
|
if (toolConfig) {
|
|
440
385
|
return (
|
|
441
|
-
<View style={
|
|
386
|
+
<View style={styles.headerRightButton}>
|
|
442
387
|
{renderPinnedTool()}
|
|
443
388
|
<View
|
|
444
389
|
style={[
|
|
@@ -446,18 +391,13 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
446
391
|
{
|
|
447
392
|
backgroundColor: backgroundColor ?? '#00000066',
|
|
448
393
|
borderWidth: backgroundColor ? 0.5 : 0,
|
|
449
|
-
marginLeft: renderPinnedTool() ? Spacing.S : 0,
|
|
450
394
|
},
|
|
451
395
|
]}>
|
|
452
|
-
<TouchableOpacity
|
|
453
|
-
accessibilityLabel={'btn_navigation_more'}
|
|
454
|
-
onPress={onMore}>
|
|
396
|
+
<TouchableOpacity onPress={onMore}>
|
|
455
397
|
<Icon color={tintColor} source="navigation_more_horiz" size={20} />
|
|
456
398
|
</TouchableOpacity>
|
|
457
399
|
<View style={[styles.divider, {backgroundColor: tintColor}]} />
|
|
458
|
-
<TouchableOpacity
|
|
459
|
-
accessibilityLabel={'btn_navigation_close'}
|
|
460
|
-
onPress={onClose}>
|
|
400
|
+
<TouchableOpacity onPress={onClose}>
|
|
461
401
|
<Icon
|
|
462
402
|
color={tintColor}
|
|
463
403
|
source="16_navigation_close_circle"
|
|
@@ -472,13 +412,10 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
472
412
|
return <View />;
|
|
473
413
|
};
|
|
474
414
|
|
|
475
|
-
/**
|
|
476
|
-
* default header banner for header animated
|
|
477
|
-
*/
|
|
478
415
|
const HeaderAnimated: React.FC<HeaderAnimatedProps> = ({
|
|
479
416
|
animatedValue,
|
|
480
417
|
image,
|
|
481
|
-
|
|
418
|
+
onPress,
|
|
482
419
|
}) => {
|
|
483
420
|
const scale = animatedValue.interpolate({
|
|
484
421
|
inputRange: [-300, 0, 300],
|
|
@@ -497,207 +434,22 @@ const HeaderAnimated: React.FC<HeaderAnimatedProps> = ({
|
|
|
497
434
|
});
|
|
498
435
|
|
|
499
436
|
return (
|
|
500
|
-
<
|
|
501
|
-
style={{
|
|
502
|
-
height: 210,
|
|
503
|
-
opacity: opacity,
|
|
504
|
-
transform: [{scale}, {translateY}],
|
|
505
|
-
}}>
|
|
506
|
-
{children ?? (
|
|
507
|
-
<Image
|
|
508
|
-
source={{
|
|
509
|
-
uri: image,
|
|
510
|
-
}}
|
|
511
|
-
style={{width: '100%', height: '100%'}}
|
|
512
|
-
/>
|
|
513
|
-
)}
|
|
514
|
-
</Animated.View>
|
|
515
|
-
);
|
|
516
|
-
};
|
|
517
|
-
|
|
518
|
-
/**
|
|
519
|
-
* Header extended with background image
|
|
520
|
-
* @constructor
|
|
521
|
-
*/
|
|
522
|
-
const HeaderExtendHeader: React.FC<{
|
|
523
|
-
headerType?: HeaderType;
|
|
524
|
-
animatedValue: Animated.Value;
|
|
525
|
-
heightHeader: number;
|
|
526
|
-
inputSearchProps?: InputSearchProps;
|
|
527
|
-
inputSearchRef?: Ref<InputRef>;
|
|
528
|
-
navigation?: Navigation;
|
|
529
|
-
}> = ({
|
|
530
|
-
headerType = 'default',
|
|
531
|
-
animatedValue,
|
|
532
|
-
heightHeader,
|
|
533
|
-
inputSearchProps,
|
|
534
|
-
inputSearchRef,
|
|
535
|
-
navigation,
|
|
536
|
-
}) => {
|
|
537
|
-
const {theme} = useContext(ApplicationContext);
|
|
538
|
-
const [rightSpace, setRightSpace] = useState(0);
|
|
539
|
-
const animated = useRef(new Animated.Value(0));
|
|
540
|
-
|
|
541
|
-
useEffect(() => {
|
|
542
|
-
const listener = animatedValue.addListener(({value}) => {
|
|
543
|
-
animated.current.setValue(value);
|
|
544
|
-
});
|
|
545
|
-
return () => {
|
|
546
|
-
animatedValue?.removeListener(listener);
|
|
547
|
-
};
|
|
548
|
-
}, []);
|
|
549
|
-
|
|
550
|
-
const height = animated.current.interpolate({
|
|
551
|
-
inputRange: [0, 100],
|
|
552
|
-
outputRange: [heightHeader + 52, heightHeader],
|
|
553
|
-
extrapolate: 'clamp',
|
|
554
|
-
});
|
|
555
|
-
|
|
556
|
-
const translateX = animated.current.interpolate({
|
|
557
|
-
inputRange: [0, 100],
|
|
558
|
-
outputRange: [SCREEN_PADDING, BACK_WIDTH + SCREEN_PADDING * 2],
|
|
559
|
-
extrapolate: 'clamp',
|
|
560
|
-
});
|
|
561
|
-
|
|
562
|
-
if (navigation) {
|
|
563
|
-
navigation.onHeaderRightChange = (width: number) => {
|
|
564
|
-
setRightSpace(width);
|
|
565
|
-
};
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
const renderInputView = (hasColorBG: boolean = false) => {
|
|
569
|
-
return (
|
|
437
|
+
<TouchableOpacity onPress={onPress}>
|
|
570
438
|
<Animated.View
|
|
571
439
|
style={{
|
|
572
|
-
|
|
573
|
-
|
|
440
|
+
height: 210,
|
|
441
|
+
opacity: opacity,
|
|
442
|
+
transform: [{scale}, {translateY}],
|
|
574
443
|
}}>
|
|
575
|
-
<Animated.View
|
|
576
|
-
style={{
|
|
577
|
-
transform: [{translateX}],
|
|
578
|
-
marginVertical: Spacing.S,
|
|
579
|
-
width: animated.current.interpolate({
|
|
580
|
-
inputRange: [0, 100],
|
|
581
|
-
outputRange: [
|
|
582
|
-
screenWidth - SCREEN_PADDING * 2,
|
|
583
|
-
screenWidth - SCREEN_PADDING * 3 - BACK_WIDTH - rightSpace,
|
|
584
|
-
],
|
|
585
|
-
extrapolate: 'clamp',
|
|
586
|
-
}),
|
|
587
|
-
}}>
|
|
588
|
-
<InputSearch
|
|
589
|
-
{...inputSearchProps}
|
|
590
|
-
ref={inputSearchRef}
|
|
591
|
-
hasColorBG={hasColorBG}
|
|
592
|
-
showButtonText={false}
|
|
593
|
-
/>
|
|
594
|
-
</Animated.View>
|
|
595
|
-
</Animated.View>
|
|
596
|
-
);
|
|
597
|
-
};
|
|
598
|
-
|
|
599
|
-
if (inputSearchProps) {
|
|
600
|
-
if (headerType === 'surface') {
|
|
601
|
-
return (
|
|
602
|
-
<>
|
|
603
|
-
<Animated.View
|
|
604
|
-
style={[
|
|
605
|
-
styles.headerBox,
|
|
606
|
-
{
|
|
607
|
-
backgroundColor: theme.colors.background.surface,
|
|
608
|
-
borderBottomWidth: 1,
|
|
609
|
-
borderColor: theme.colors.border.default,
|
|
610
|
-
height,
|
|
611
|
-
},
|
|
612
|
-
]}
|
|
613
|
-
/>
|
|
614
|
-
{renderInputView(true)}
|
|
615
|
-
</>
|
|
616
|
-
);
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
if (headerType === 'extended') {
|
|
620
|
-
return (
|
|
621
|
-
<>
|
|
622
|
-
<Animated.View
|
|
623
|
-
style={[
|
|
624
|
-
styles.headerBox,
|
|
625
|
-
{
|
|
626
|
-
height,
|
|
627
|
-
},
|
|
628
|
-
]}>
|
|
629
|
-
<Image
|
|
630
|
-
source={{
|
|
631
|
-
uri: theme.assets?.headerBackground,
|
|
632
|
-
}}
|
|
633
|
-
style={styles.headerBackground}
|
|
634
|
-
/>
|
|
635
|
-
</Animated.View>
|
|
636
|
-
{renderInputView()}
|
|
637
|
-
</>
|
|
638
|
-
);
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
return (
|
|
642
|
-
<>
|
|
643
|
-
<View style={[styles.headerBox, {height: heightHeader}]}>
|
|
644
|
-
<Image
|
|
645
|
-
source={{
|
|
646
|
-
uri: theme.assets?.headerBackground,
|
|
647
|
-
}}
|
|
648
|
-
style={styles.headerBackground}
|
|
649
|
-
/>
|
|
650
|
-
</View>
|
|
651
|
-
{renderInputView()}
|
|
652
|
-
</>
|
|
653
|
-
);
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
if (headerType === 'extended') {
|
|
657
|
-
return (
|
|
658
|
-
<View style={{minHeight: heightHeader}}>
|
|
659
444
|
<Image
|
|
660
445
|
source={{
|
|
661
|
-
uri:
|
|
446
|
+
uri: image,
|
|
662
447
|
}}
|
|
663
|
-
style={
|
|
448
|
+
style={{width: '100%', height: '100%'}}
|
|
664
449
|
/>
|
|
665
|
-
</View>
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
return <View />;
|
|
670
|
-
};
|
|
671
|
-
|
|
672
|
-
const HeaderRightAction: React.FC<any> = ({children, ...restProps}) => {
|
|
673
|
-
if (__DEV__) {
|
|
674
|
-
Alert.alert(
|
|
675
|
-
'HeaderRightAction',
|
|
676
|
-
'This component is deprecated and will removed 10/2024, please use new type headerRight specs instead v0.92.34'
|
|
677
|
-
);
|
|
678
|
-
}
|
|
679
|
-
const validateType = (child: React.ReactElement) => {
|
|
680
|
-
return child;
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
const renderAction = () => {
|
|
684
|
-
if (Array.isArray(children)) {
|
|
685
|
-
return children.map((child, index) => {
|
|
686
|
-
return (
|
|
687
|
-
<View key={`HeaderRightAction ${index}`} style={styles.headerButton}>
|
|
688
|
-
{React.cloneElement(validateType(child), {...restProps})}
|
|
689
|
-
</View>
|
|
690
|
-
);
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
return (
|
|
695
|
-
<View style={styles.headerButton}>
|
|
696
|
-
{React.cloneElement(validateType(children), {...restProps})}
|
|
697
|
-
</View>
|
|
698
|
-
);
|
|
699
|
-
};
|
|
700
|
-
return <View style={styles.headerRightButton}>{renderAction()}</View>;
|
|
450
|
+
</Animated.View>
|
|
451
|
+
</TouchableOpacity>
|
|
452
|
+
);
|
|
701
453
|
};
|
|
702
454
|
|
|
703
455
|
const styles = StyleSheet.create({
|
|
@@ -736,9 +488,10 @@ const styles = StyleSheet.create({
|
|
|
736
488
|
flexDirection: 'row',
|
|
737
489
|
justifyContent: 'center',
|
|
738
490
|
alignItems: 'center',
|
|
739
|
-
paddingRight: Spacing.
|
|
491
|
+
paddingRight: Spacing.S,
|
|
740
492
|
},
|
|
741
493
|
toolkitContainer: {
|
|
494
|
+
marginLeft: Spacing.S,
|
|
742
495
|
padding: Spacing.XS,
|
|
743
496
|
height: 28,
|
|
744
497
|
borderRadius: 14,
|
|
@@ -770,22 +523,6 @@ const styles = StyleSheet.create({
|
|
|
770
523
|
top: -Spacing.XS,
|
|
771
524
|
right: -Spacing.XS,
|
|
772
525
|
},
|
|
773
|
-
badgeDotAnimation: {
|
|
774
|
-
position: 'absolute',
|
|
775
|
-
top: -Spacing.XS,
|
|
776
|
-
right: -Spacing.XS,
|
|
777
|
-
},
|
|
778
|
-
extendedHeader: {
|
|
779
|
-
aspectRatio: 1.75,
|
|
780
|
-
position: 'absolute',
|
|
781
|
-
width: '100%',
|
|
782
|
-
height: 210,
|
|
783
|
-
},
|
|
784
|
-
headerBox: {
|
|
785
|
-
width: '100%',
|
|
786
|
-
position: 'absolute',
|
|
787
|
-
overflow: 'hidden',
|
|
788
|
-
},
|
|
789
526
|
});
|
|
790
527
|
|
|
791
528
|
export {
|
|
@@ -793,10 +530,8 @@ export {
|
|
|
793
530
|
HeaderTitle,
|
|
794
531
|
HeaderLeft,
|
|
795
532
|
HeaderBackground,
|
|
533
|
+
HeaderRightAction,
|
|
796
534
|
HeaderToolkitAction,
|
|
797
535
|
HeaderCustom,
|
|
798
536
|
HeaderAnimated,
|
|
799
|
-
HeaderRight,
|
|
800
|
-
HeaderExtendHeader,
|
|
801
|
-
HeaderRightAction,
|
|
802
537
|
};
|