@momo-kits/foundation 0.89.6-rc.2 → 0.89.6-rc.3
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 +77 -335
- package/Application/ModalScreen.tsx +159 -12
- package/Application/Navigation.ts +19 -5
- package/Application/NavigationContainer.tsx +25 -14
- package/Application/Navigator.ts +16 -14
- package/Application/StackScreen.tsx +42 -287
- package/Application/index.ts +11 -13
- package/Application/types.ts +33 -62
- package/Application/utils.tsx +25 -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 +8 -45
- 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 +45 -56
- package/Popup/PopupPromotion.tsx +7 -5
- 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 +0 -22
- package/Text/styles.ts +1 -1
- package/Text/types.ts +1 -19
- 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 +6 -7
- 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/Badge/BadgeDotAnimation.tsx +0 -95
- package/Input/TextTyping.tsx +0 -113
- package/Layout/FloatingButton.tsx +0 -168
- package/migrate_typo.js +0 -56
|
@@ -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,26 @@ 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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
121
|
+
const canGoBack = navigator?.ref.current?.canGoBack();
|
|
122
|
+
if (!canGoBack) {
|
|
123
|
+
const currentRoute = navigator?.ref?.current?.getCurrentRoute?.();
|
|
124
|
+
const params = {
|
|
125
|
+
...context,
|
|
126
|
+
screen_name: currentRoute?.params?.screen?.name ?? currentRoute?.name,
|
|
127
|
+
trigger_id: '111154000000000000',
|
|
128
|
+
icon_name: 'back',
|
|
129
|
+
};
|
|
130
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
131
|
+
appId: context.appId,
|
|
132
|
+
message: 'service_icon_clicked',
|
|
133
|
+
params,
|
|
134
|
+
});
|
|
135
|
+
navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
|
|
136
|
+
}
|
|
166
137
|
if (canGoBack) {
|
|
167
|
-
navigator?.ref
|
|
138
|
+
navigator?.ref.current?.goBack();
|
|
168
139
|
} else if (navigator?.maxApi) {
|
|
169
|
-
navigator?.maxApi?.dismiss
|
|
140
|
+
navigator?.maxApi?.dismiss(navigator.dismissData);
|
|
170
141
|
} else {
|
|
171
142
|
const currentTime = new Date().getTime();
|
|
172
143
|
const requestId = `navigationBackPress#${currentTime}`;
|
|
@@ -199,7 +170,6 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
199
170
|
return (
|
|
200
171
|
<View style={styles.headerLeft}>
|
|
201
172
|
<NavigationButton
|
|
202
|
-
accessibilityLabel="btn_navigation_back"
|
|
203
173
|
icon="ic_back"
|
|
204
174
|
tintColor={tintColor}
|
|
205
175
|
onPress={goBackSafe}
|
|
@@ -209,23 +179,17 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
209
179
|
);
|
|
210
180
|
};
|
|
211
181
|
|
|
212
|
-
/**
|
|
213
|
-
* header background for default
|
|
214
|
-
*/
|
|
215
182
|
const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
216
183
|
image,
|
|
184
|
+
backgroundColor,
|
|
217
185
|
animatedValue,
|
|
218
|
-
|
|
186
|
+
useBorder = false,
|
|
219
187
|
}) => {
|
|
220
188
|
const {theme} = useContext(ApplicationContext);
|
|
221
189
|
let headerImage = theme.assets?.headerBackground;
|
|
222
|
-
let backgroundColor;
|
|
223
190
|
if (image === null) {
|
|
224
191
|
headerImage = undefined;
|
|
225
192
|
}
|
|
226
|
-
if (useSurface) {
|
|
227
|
-
backgroundColor = theme.colors.background.surface;
|
|
228
|
-
}
|
|
229
193
|
const opacity = animatedValue?.interpolate({
|
|
230
194
|
inputRange: [0, 114],
|
|
231
195
|
outputRange: [0, 1],
|
|
@@ -237,9 +201,9 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
|
237
201
|
style={[
|
|
238
202
|
Styles.flex,
|
|
239
203
|
{
|
|
240
|
-
backgroundColor,
|
|
204
|
+
backgroundColor: backgroundColor ?? theme.colors.background.default,
|
|
241
205
|
overflow: 'hidden',
|
|
242
|
-
borderBottomWidth:
|
|
206
|
+
borderBottomWidth: useBorder ? 1 : 0,
|
|
243
207
|
borderColor: theme.colors.border.default,
|
|
244
208
|
opacity,
|
|
245
209
|
},
|
|
@@ -260,10 +224,6 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
|
260
224
|
);
|
|
261
225
|
};
|
|
262
226
|
|
|
263
|
-
/**
|
|
264
|
-
* Header custom with image, title, subtitle
|
|
265
|
-
* @constructor
|
|
266
|
-
*/
|
|
267
227
|
const HeaderCustom: React.FC<TitleCustomProps> = ({
|
|
268
228
|
title,
|
|
269
229
|
subTitle,
|
|
@@ -273,7 +233,7 @@ const HeaderCustom: React.FC<TitleCustomProps> = ({
|
|
|
273
233
|
tintColor,
|
|
274
234
|
dotColor,
|
|
275
235
|
}) => {
|
|
276
|
-
const avatarStyle = imageShape
|
|
236
|
+
const avatarStyle = imageShape == 'circle' ? styles.circle : styles.square;
|
|
277
237
|
const header = (
|
|
278
238
|
<View style={Styles.row}>
|
|
279
239
|
<View>
|
|
@@ -283,10 +243,7 @@ const HeaderCustom: React.FC<TitleCustomProps> = ({
|
|
|
283
243
|
)}
|
|
284
244
|
</View>
|
|
285
245
|
<View style={[Styles.flex, {paddingHorizontal: 8}]}>
|
|
286
|
-
<Text
|
|
287
|
-
accessibilityLabel={'title_navigation_header'}
|
|
288
|
-
typography="header_default_bold"
|
|
289
|
-
color={tintColor}>
|
|
246
|
+
<Text typography="header_default_bold" color={tintColor}>
|
|
290
247
|
{title}
|
|
291
248
|
</Text>
|
|
292
249
|
<Text typography="description_default_regular" color={tintColor}>
|
|
@@ -298,56 +255,51 @@ const HeaderCustom: React.FC<TitleCustomProps> = ({
|
|
|
298
255
|
return <View style={styles.headerTitleContainer}>{content ?? header}</View>;
|
|
299
256
|
};
|
|
300
257
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
buttons = buttons.slice(0, 3);
|
|
258
|
+
const HeaderRightAction: React.FC<any> = ({children, ...restProps}) => {
|
|
259
|
+
const validateType = (child: React.ReactElement) => {
|
|
260
|
+
const valid = child?.type === NavigationButton || child?.type == Fragment;
|
|
261
|
+
if (__DEV__ && !valid) {
|
|
262
|
+
console.warn(
|
|
263
|
+
'HeaderRightAction contains element type of NavigationButton, Please check again.',
|
|
264
|
+
);
|
|
309
265
|
}
|
|
266
|
+
return child;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const renderAction = () => {
|
|
270
|
+
if (Array.isArray(children)) {
|
|
271
|
+
return children.map((child, index) => {
|
|
272
|
+
return (
|
|
273
|
+
<View key={`HeaderRightAction ${index}`} style={styles.headerButton}>
|
|
274
|
+
{React.cloneElement(validateType(child), {...restProps})}
|
|
275
|
+
</View>
|
|
276
|
+
);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
310
280
|
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
|
-
})}
|
|
281
|
+
<View style={styles.headerButton}>
|
|
282
|
+
{React.cloneElement(validateType(children), {...restProps})}
|
|
323
283
|
</View>
|
|
324
284
|
);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
return (
|
|
328
|
-
<View style={styles.headerRightButton} onLayout={onLayout}>
|
|
329
|
-
{children ?? <HeaderToolkitAction {...props} />}
|
|
330
|
-
</View>
|
|
331
|
-
);
|
|
285
|
+
};
|
|
286
|
+
return <View style={styles.headerRightButton}>{renderAction()}</View>;
|
|
332
287
|
};
|
|
333
288
|
|
|
334
|
-
/**
|
|
335
|
-
* Header toolkit action
|
|
336
|
-
*/
|
|
337
289
|
const HeaderToolkitAction: React.FC<any> = ({
|
|
338
290
|
tintColor,
|
|
339
291
|
pinnedTool,
|
|
340
292
|
runtimeTools = [],
|
|
341
293
|
preventClose,
|
|
342
294
|
}) => {
|
|
343
|
-
const {navigator} = useContext(ApplicationContext);
|
|
344
|
-
const miniContext = useContext
|
|
295
|
+
const {theme, navigator} = useContext(ApplicationContext);
|
|
296
|
+
const miniContext = useContext(MiniAppContext);
|
|
345
297
|
const [toolConfig, setToolConfig] = useState<any>();
|
|
346
298
|
const {onAction} = toolConfig ?? {};
|
|
347
299
|
|
|
348
300
|
let backgroundColor;
|
|
349
|
-
if (tintColor
|
|
350
|
-
backgroundColor =
|
|
301
|
+
if (tintColor != Colors.black_01) {
|
|
302
|
+
backgroundColor = theme.colors.background.surface;
|
|
351
303
|
}
|
|
352
304
|
|
|
353
305
|
useEffect(() => {
|
|
@@ -367,7 +319,7 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
367
319
|
(config: any) => {
|
|
368
320
|
navigator.toolkitConfig = config;
|
|
369
321
|
setToolConfig(navigator?.toolkitConfig);
|
|
370
|
-
}
|
|
322
|
+
},
|
|
371
323
|
);
|
|
372
324
|
};
|
|
373
325
|
|
|
@@ -378,9 +330,9 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
378
330
|
{runtimeTools},
|
|
379
331
|
(res: {item: {action?: string; key: string}}) => {
|
|
380
332
|
const {item} = res;
|
|
381
|
-
navigator?.toolkitCallback?.(item
|
|
333
|
+
navigator?.toolkitCallback?.(item);
|
|
382
334
|
getToolkitConfig();
|
|
383
|
-
}
|
|
335
|
+
},
|
|
384
336
|
);
|
|
385
337
|
};
|
|
386
338
|
|
|
@@ -397,7 +349,7 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
397
349
|
navigator?.maxApi?.dispatchFunction?.(
|
|
398
350
|
'dismiss',
|
|
399
351
|
undefined,
|
|
400
|
-
undefined
|
|
352
|
+
undefined,
|
|
401
353
|
);
|
|
402
354
|
},
|
|
403
355
|
}}
|
|
@@ -417,7 +369,6 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
417
369
|
if (pinTool)
|
|
418
370
|
return (
|
|
419
371
|
<NavigationButton
|
|
420
|
-
accessibilityLabel="btn_navigation_pin"
|
|
421
372
|
icon={pinTool.icon as string}
|
|
422
373
|
tintColor={tintColor}
|
|
423
374
|
badgeValue={badgeValue}
|
|
@@ -425,19 +376,20 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
425
376
|
onPress={() => {
|
|
426
377
|
navigator?.maxApi?.dispatchFunction?.(
|
|
427
378
|
'onToolAction',
|
|
428
|
-
|
|
379
|
+
[pinTool?.key],
|
|
429
380
|
() => {
|
|
430
381
|
getToolkitConfig();
|
|
431
|
-
}
|
|
382
|
+
},
|
|
432
383
|
);
|
|
433
384
|
navigator?.toolkitCallback?.(pinTool.key);
|
|
434
385
|
}}
|
|
435
386
|
/>
|
|
436
387
|
);
|
|
437
388
|
};
|
|
389
|
+
|
|
438
390
|
if (toolConfig) {
|
|
439
391
|
return (
|
|
440
|
-
<View style={
|
|
392
|
+
<View style={styles.headerRightButton}>
|
|
441
393
|
{renderPinnedTool()}
|
|
442
394
|
<View
|
|
443
395
|
style={[
|
|
@@ -445,18 +397,13 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
445
397
|
{
|
|
446
398
|
backgroundColor: backgroundColor ?? '#00000066',
|
|
447
399
|
borderWidth: backgroundColor ? 0.5 : 0,
|
|
448
|
-
marginLeft: renderPinnedTool() ? Spacing.S : 0,
|
|
449
400
|
},
|
|
450
401
|
]}>
|
|
451
|
-
<TouchableOpacity
|
|
452
|
-
accessibilityLabel={'btn_navigation_more'}
|
|
453
|
-
onPress={onMore}>
|
|
402
|
+
<TouchableOpacity onPress={onMore}>
|
|
454
403
|
<Icon color={tintColor} source="navigation_more_horiz" size={20} />
|
|
455
404
|
</TouchableOpacity>
|
|
456
405
|
<View style={[styles.divider, {backgroundColor: tintColor}]} />
|
|
457
|
-
<TouchableOpacity
|
|
458
|
-
accessibilityLabel={'btn_navigation_close'}
|
|
459
|
-
onPress={onClose}>
|
|
406
|
+
<TouchableOpacity onPress={onClose}>
|
|
460
407
|
<Icon
|
|
461
408
|
color={tintColor}
|
|
462
409
|
source="16_navigation_close_circle"
|
|
@@ -471,9 +418,6 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
471
418
|
return <View />;
|
|
472
419
|
};
|
|
473
420
|
|
|
474
|
-
/**
|
|
475
|
-
* default header banner for header animated
|
|
476
|
-
*/
|
|
477
421
|
const HeaderAnimated: React.FC<HeaderAnimatedProps> = ({
|
|
478
422
|
animatedValue,
|
|
479
423
|
image,
|
|
@@ -514,191 +458,6 @@ const HeaderAnimated: React.FC<HeaderAnimatedProps> = ({
|
|
|
514
458
|
);
|
|
515
459
|
};
|
|
516
460
|
|
|
517
|
-
/**
|
|
518
|
-
* Header extended with background image
|
|
519
|
-
* @constructor
|
|
520
|
-
*/
|
|
521
|
-
const HeaderExtendHeader: React.FC<{
|
|
522
|
-
headerType?: HeaderType;
|
|
523
|
-
animatedValue: Animated.Value;
|
|
524
|
-
heightHeader: number;
|
|
525
|
-
inputSearchProps?: InputSearchProps;
|
|
526
|
-
inputSearchRef?: Ref<InputRef>;
|
|
527
|
-
navigation?: Navigation;
|
|
528
|
-
}> = ({
|
|
529
|
-
headerType = 'default',
|
|
530
|
-
animatedValue,
|
|
531
|
-
heightHeader,
|
|
532
|
-
inputSearchProps,
|
|
533
|
-
inputSearchRef,
|
|
534
|
-
navigation,
|
|
535
|
-
}) => {
|
|
536
|
-
const {theme} = useContext(ApplicationContext);
|
|
537
|
-
const [rightSpace, setRightSpace] = useState(0);
|
|
538
|
-
const animated = useRef(new Animated.Value(0));
|
|
539
|
-
|
|
540
|
-
useEffect(() => {
|
|
541
|
-
const listener = animatedValue.addListener(({value}) => {
|
|
542
|
-
animated.current.setValue(value);
|
|
543
|
-
});
|
|
544
|
-
return () => {
|
|
545
|
-
animatedValue?.removeListener(listener);
|
|
546
|
-
};
|
|
547
|
-
}, []);
|
|
548
|
-
|
|
549
|
-
const height = animated.current.interpolate({
|
|
550
|
-
inputRange: [0, 100],
|
|
551
|
-
outputRange: [heightHeader + 52, heightHeader],
|
|
552
|
-
extrapolate: 'clamp',
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
const translateX = animated.current.interpolate({
|
|
556
|
-
inputRange: [0, 100],
|
|
557
|
-
outputRange: [SCREEN_PADDING, BACK_WIDTH + SCREEN_PADDING * 2],
|
|
558
|
-
extrapolate: 'clamp',
|
|
559
|
-
});
|
|
560
|
-
|
|
561
|
-
if (navigation) {
|
|
562
|
-
navigation.onHeaderRightChange = (width: number) => {
|
|
563
|
-
setRightSpace(width);
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
const renderInputView = (hasColorBG: boolean = false) => {
|
|
568
|
-
return (
|
|
569
|
-
<Animated.View
|
|
570
|
-
style={{
|
|
571
|
-
justifyContent: 'flex-end',
|
|
572
|
-
height,
|
|
573
|
-
}}>
|
|
574
|
-
<Animated.View
|
|
575
|
-
style={{
|
|
576
|
-
transform: [{translateX}],
|
|
577
|
-
marginVertical: Spacing.S,
|
|
578
|
-
width: animated.current.interpolate({
|
|
579
|
-
inputRange: [0, 100],
|
|
580
|
-
outputRange: [
|
|
581
|
-
screenWidth - SCREEN_PADDING * 2,
|
|
582
|
-
screenWidth - SCREEN_PADDING * 3 - BACK_WIDTH - rightSpace,
|
|
583
|
-
],
|
|
584
|
-
extrapolate: 'clamp',
|
|
585
|
-
}),
|
|
586
|
-
}}>
|
|
587
|
-
<InputSearch
|
|
588
|
-
{...inputSearchProps}
|
|
589
|
-
ref={inputSearchRef}
|
|
590
|
-
hasColorBG={hasColorBG}
|
|
591
|
-
showButtonText={false}
|
|
592
|
-
/>
|
|
593
|
-
</Animated.View>
|
|
594
|
-
</Animated.View>
|
|
595
|
-
);
|
|
596
|
-
};
|
|
597
|
-
|
|
598
|
-
if (inputSearchProps) {
|
|
599
|
-
if (headerType === 'surface') {
|
|
600
|
-
return (
|
|
601
|
-
<>
|
|
602
|
-
<Animated.View
|
|
603
|
-
style={[
|
|
604
|
-
styles.headerBox,
|
|
605
|
-
{
|
|
606
|
-
backgroundColor: theme.colors.background.surface,
|
|
607
|
-
borderBottomWidth: 1,
|
|
608
|
-
borderColor: theme.colors.border.default,
|
|
609
|
-
height,
|
|
610
|
-
},
|
|
611
|
-
]}
|
|
612
|
-
/>
|
|
613
|
-
{renderInputView(true)}
|
|
614
|
-
</>
|
|
615
|
-
);
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
if (headerType === 'extended') {
|
|
619
|
-
return (
|
|
620
|
-
<>
|
|
621
|
-
<Animated.View
|
|
622
|
-
style={[
|
|
623
|
-
styles.headerBox,
|
|
624
|
-
{
|
|
625
|
-
height,
|
|
626
|
-
},
|
|
627
|
-
]}>
|
|
628
|
-
<Image
|
|
629
|
-
source={{
|
|
630
|
-
uri: theme.assets?.headerBackground,
|
|
631
|
-
}}
|
|
632
|
-
style={styles.headerBackground}
|
|
633
|
-
/>
|
|
634
|
-
</Animated.View>
|
|
635
|
-
{renderInputView()}
|
|
636
|
-
</>
|
|
637
|
-
);
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
return (
|
|
641
|
-
<>
|
|
642
|
-
<View style={[styles.headerBox, {height: heightHeader}]}>
|
|
643
|
-
<Image
|
|
644
|
-
source={{
|
|
645
|
-
uri: theme.assets?.headerBackground,
|
|
646
|
-
}}
|
|
647
|
-
style={styles.headerBackground}
|
|
648
|
-
/>
|
|
649
|
-
</View>
|
|
650
|
-
{renderInputView()}
|
|
651
|
-
</>
|
|
652
|
-
);
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
if (headerType === 'extended') {
|
|
656
|
-
return (
|
|
657
|
-
<View style={{minHeight: heightHeader}}>
|
|
658
|
-
<Image
|
|
659
|
-
source={{
|
|
660
|
-
uri: theme.assets?.headerBackground,
|
|
661
|
-
}}
|
|
662
|
-
style={styles.extendedHeader}
|
|
663
|
-
/>
|
|
664
|
-
</View>
|
|
665
|
-
);
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
return <View />;
|
|
669
|
-
};
|
|
670
|
-
|
|
671
|
-
const HeaderRightAction: React.FC<any> = ({children, ...restProps}) => {
|
|
672
|
-
if (__DEV__) {
|
|
673
|
-
Alert.alert(
|
|
674
|
-
'HeaderRightAction',
|
|
675
|
-
'This component is deprecated and will removed 10/2024, please use new type headerRight specs instead v0.92.34'
|
|
676
|
-
);
|
|
677
|
-
}
|
|
678
|
-
const validateType = (child: React.ReactElement) => {
|
|
679
|
-
return child;
|
|
680
|
-
};
|
|
681
|
-
|
|
682
|
-
const renderAction = () => {
|
|
683
|
-
if (Array.isArray(children)) {
|
|
684
|
-
return children.map((child, index) => {
|
|
685
|
-
return (
|
|
686
|
-
<View key={`HeaderRightAction ${index}`} style={styles.headerButton}>
|
|
687
|
-
{React.cloneElement(validateType(child), {...restProps})}
|
|
688
|
-
</View>
|
|
689
|
-
);
|
|
690
|
-
});
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
return (
|
|
694
|
-
<View style={styles.headerButton}>
|
|
695
|
-
{React.cloneElement(validateType(children), {...restProps})}
|
|
696
|
-
</View>
|
|
697
|
-
);
|
|
698
|
-
};
|
|
699
|
-
return <View style={styles.headerRightButton}>{renderAction()}</View>;
|
|
700
|
-
};
|
|
701
|
-
|
|
702
461
|
const styles = StyleSheet.create({
|
|
703
462
|
navigationButton: {
|
|
704
463
|
height: 28,
|
|
@@ -735,9 +494,10 @@ const styles = StyleSheet.create({
|
|
|
735
494
|
flexDirection: 'row',
|
|
736
495
|
justifyContent: 'center',
|
|
737
496
|
alignItems: 'center',
|
|
738
|
-
paddingRight: Spacing.
|
|
497
|
+
paddingRight: Spacing.S,
|
|
739
498
|
},
|
|
740
499
|
toolkitContainer: {
|
|
500
|
+
marginLeft: Spacing.S,
|
|
741
501
|
padding: Spacing.XS,
|
|
742
502
|
height: 28,
|
|
743
503
|
borderRadius: 14,
|
|
@@ -769,22 +529,6 @@ const styles = StyleSheet.create({
|
|
|
769
529
|
top: -Spacing.XS,
|
|
770
530
|
right: -Spacing.XS,
|
|
771
531
|
},
|
|
772
|
-
badgeDotAnimation: {
|
|
773
|
-
position: 'absolute',
|
|
774
|
-
top: -Spacing.XS,
|
|
775
|
-
right: -Spacing.XS,
|
|
776
|
-
},
|
|
777
|
-
extendedHeader: {
|
|
778
|
-
aspectRatio: 1.75,
|
|
779
|
-
position: 'absolute',
|
|
780
|
-
width: '100%',
|
|
781
|
-
height: 210,
|
|
782
|
-
},
|
|
783
|
-
headerBox: {
|
|
784
|
-
width: '100%',
|
|
785
|
-
position: 'absolute',
|
|
786
|
-
overflow: 'hidden',
|
|
787
|
-
},
|
|
788
532
|
});
|
|
789
533
|
|
|
790
534
|
export {
|
|
@@ -792,10 +536,8 @@ export {
|
|
|
792
536
|
HeaderTitle,
|
|
793
537
|
HeaderLeft,
|
|
794
538
|
HeaderBackground,
|
|
539
|
+
HeaderRightAction,
|
|
795
540
|
HeaderToolkitAction,
|
|
796
541
|
HeaderCustom,
|
|
797
542
|
HeaderAnimated,
|
|
798
|
-
HeaderRight,
|
|
799
|
-
HeaderExtendHeader,
|
|
800
|
-
HeaderRightAction,
|
|
801
543
|
};
|