@momo-kits/foundation 0.109.1-beta.3 → 0.109.1-optimize.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16,14 +16,10 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
|
16
16
|
animatedValue,
|
|
17
17
|
useGradient = true,
|
|
18
18
|
useShadowHeader = true,
|
|
19
|
-
gradientColor,
|
|
20
|
-
headerBackground,
|
|
21
19
|
}) => {
|
|
22
20
|
const {theme} = useContext(ApplicationContext);
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
let headerImage = headerBackground ?? theme.assets?.headerBackground;
|
|
22
|
+
let headerImage = theme.assets?.headerBackground;
|
|
27
23
|
if (image === null) {
|
|
28
24
|
headerImage = undefined;
|
|
29
25
|
}
|
|
@@ -54,7 +50,7 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
|
54
50
|
<View style={styles.gradientContainer}>
|
|
55
51
|
{useGradient && (
|
|
56
52
|
<LinearGradientAnimated
|
|
57
|
-
colors={[
|
|
53
|
+
colors={[theme.colors.gradient, theme.colors.gradient + '00']}
|
|
58
54
|
style={[styles.extendedHeader, {opacity: opacityGradient}]}>
|
|
59
55
|
{!!headerImage && (
|
|
60
56
|
<Image
|
|
@@ -5,7 +5,7 @@ import {Animated, Dimensions, Platform, StyleSheet, View} from 'react-native';
|
|
|
5
5
|
import {HeaderType} from '../../Layout/types';
|
|
6
6
|
import {InputRef, InputSearch, InputSearchProps} from '../../Input';
|
|
7
7
|
import Navigation from '../Navigation';
|
|
8
|
-
import {Colors, Radius, Spacing
|
|
8
|
+
import {Colors, Radius, Spacing} from '../../Consts';
|
|
9
9
|
import {Image} from '../../Image';
|
|
10
10
|
|
|
11
11
|
const SCREEN_PADDING = 12;
|
|
@@ -27,8 +27,6 @@ const HeaderExtendHeader: React.FC<{
|
|
|
27
27
|
inputSearchRef?: Ref<InputRef>;
|
|
28
28
|
navigation?: Navigation;
|
|
29
29
|
useShadowHeader?: boolean;
|
|
30
|
-
gradientColor?: string;
|
|
31
|
-
headerBackground?: string;
|
|
32
30
|
}> = ({
|
|
33
31
|
headerType = 'default',
|
|
34
32
|
animatedValue,
|
|
@@ -37,17 +35,11 @@ const HeaderExtendHeader: React.FC<{
|
|
|
37
35
|
inputSearchProps,
|
|
38
36
|
inputSearchRef,
|
|
39
37
|
useShadowHeader = true,
|
|
40
|
-
gradientColor,
|
|
41
|
-
headerBackground: customHeaderBackground,
|
|
42
38
|
}) => {
|
|
43
39
|
const {theme} = useContext(ApplicationContext);
|
|
44
40
|
|
|
45
41
|
const animated = useRef(new Animated.Value(0));
|
|
46
42
|
|
|
47
|
-
const linearGradientColor = gradientColor ?? theme.colors.gradient;
|
|
48
|
-
const headerBackground =
|
|
49
|
-
customHeaderBackground ?? theme.assets?.headerBackground;
|
|
50
|
-
|
|
51
43
|
const opacityBackground = animatedValue?.interpolate({
|
|
52
44
|
inputRange: [0, 52],
|
|
53
45
|
outputRange: [0, 1],
|
|
@@ -90,12 +82,47 @@ const HeaderExtendHeader: React.FC<{
|
|
|
90
82
|
});
|
|
91
83
|
|
|
92
84
|
if (inputSearchProps) {
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
return (
|
|
86
|
+
<>
|
|
87
|
+
<Animated.View style={{height: height}} />
|
|
88
|
+
<Animated.View
|
|
89
|
+
style={[
|
|
90
|
+
useShadowHeader ? styles.shadowHeader : styles.dividerHeader,
|
|
91
|
+
{
|
|
92
|
+
backgroundColor: theme.colors.background.surface,
|
|
93
|
+
opacity: opacityBackground,
|
|
94
|
+
position: 'absolute',
|
|
95
|
+
width: '100%',
|
|
96
|
+
height: heightHeader,
|
|
97
|
+
zIndex: 1,
|
|
98
|
+
},
|
|
99
|
+
]}
|
|
100
|
+
/>
|
|
101
|
+
|
|
102
|
+
<Animated.View
|
|
103
|
+
style={[
|
|
104
|
+
styles.headerBox,
|
|
105
|
+
{height: headerType === 'extended' ? height : heightHeader},
|
|
106
|
+
]}>
|
|
107
|
+
<LinearGradientAnimated
|
|
108
|
+
colors={[theme.colors.gradient, theme.colors.gradient + '00']}
|
|
109
|
+
style={[styles.extendedHeader, {opacity: opacityGradient}]}>
|
|
110
|
+
{!!theme.assets?.headerBackground && (
|
|
111
|
+
<Image
|
|
112
|
+
style={styles.headerBackground}
|
|
113
|
+
source={{uri: theme.assets?.headerBackground}}
|
|
114
|
+
loading={false}
|
|
115
|
+
/>
|
|
116
|
+
)}
|
|
117
|
+
</LinearGradientAnimated>
|
|
118
|
+
</Animated.View>
|
|
119
|
+
|
|
95
120
|
<Animated.View
|
|
96
121
|
style={{
|
|
97
122
|
justifyContent: 'flex-end',
|
|
98
123
|
height,
|
|
124
|
+
position: 'absolute',
|
|
125
|
+
zIndex: 2,
|
|
99
126
|
}}>
|
|
100
127
|
<Animated.View
|
|
101
128
|
style={{
|
|
@@ -120,40 +147,6 @@ const HeaderExtendHeader: React.FC<{
|
|
|
120
147
|
</Animated.View>
|
|
121
148
|
</Animated.View>
|
|
122
149
|
</Animated.View>
|
|
123
|
-
);
|
|
124
|
-
};
|
|
125
|
-
return (
|
|
126
|
-
<>
|
|
127
|
-
<Animated.View
|
|
128
|
-
style={[
|
|
129
|
-
styles.headerBox,
|
|
130
|
-
{height: headerType === 'extended' ? height : heightHeader},
|
|
131
|
-
]}>
|
|
132
|
-
<Animated.View
|
|
133
|
-
style={[
|
|
134
|
-
Styles.flex,
|
|
135
|
-
styles.shadowHeader,
|
|
136
|
-
{
|
|
137
|
-
borderBottomWidth: 1,
|
|
138
|
-
borderColor: theme.colors.border.default,
|
|
139
|
-
backgroundColor: theme.colors.background.surface,
|
|
140
|
-
opacity: opacityBackground,
|
|
141
|
-
},
|
|
142
|
-
]}
|
|
143
|
-
/>
|
|
144
|
-
<LinearGradientAnimated
|
|
145
|
-
colors={[linearGradientColor, linearGradientColor + '00']}
|
|
146
|
-
style={[styles.extendedHeader, {opacity: opacityGradient}]}>
|
|
147
|
-
{!!headerBackground && (
|
|
148
|
-
<Image
|
|
149
|
-
style={styles.headerBackground}
|
|
150
|
-
source={{uri: headerBackground}}
|
|
151
|
-
loading={false}
|
|
152
|
-
/>
|
|
153
|
-
)}
|
|
154
|
-
</LinearGradientAnimated>
|
|
155
|
-
</Animated.View>
|
|
156
|
-
{renderInputView()}
|
|
157
150
|
<Verified />
|
|
158
151
|
</>
|
|
159
152
|
);
|
|
@@ -176,12 +169,12 @@ const HeaderExtendHeader: React.FC<{
|
|
|
176
169
|
]}
|
|
177
170
|
/>
|
|
178
171
|
<LinearGradientAnimated
|
|
179
|
-
colors={[
|
|
172
|
+
colors={[theme.colors.gradient, theme.colors.gradient + '00']}
|
|
180
173
|
style={[styles.extendedHeader, {opacity: opacityGradient}]}>
|
|
181
|
-
{!!headerBackground && (
|
|
174
|
+
{!!theme.assets?.headerBackground && (
|
|
182
175
|
<Image
|
|
183
176
|
style={styles.headerBackground}
|
|
184
|
-
source={{uri: headerBackground}}
|
|
177
|
+
source={{uri: theme.assets?.headerBackground}}
|
|
185
178
|
loading={false}
|
|
186
179
|
/>
|
|
187
180
|
)}
|
package/Application/types.ts
CHANGED
package/Layout/Screen.tsx
CHANGED
|
@@ -136,16 +136,6 @@ export interface ScreenProps extends ViewProps {
|
|
|
136
136
|
* Optional. If `true`, use shadow header.
|
|
137
137
|
*/
|
|
138
138
|
useShadowHeader?: boolean;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Optional. Custom header Gradient Color.
|
|
142
|
-
*/
|
|
143
|
-
gradientColor?: string;
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Optional. Custom headerBackground Image
|
|
147
|
-
*/
|
|
148
|
-
headerBackground?: string;
|
|
149
139
|
}
|
|
150
140
|
|
|
151
141
|
const Screen = forwardRef(
|
|
@@ -170,8 +160,6 @@ const Screen = forwardRef(
|
|
|
170
160
|
inputSearchProps,
|
|
171
161
|
inputSearchRef,
|
|
172
162
|
animatedValue: customAnimatedValue,
|
|
173
|
-
headerBackground,
|
|
174
|
-
gradientColor,
|
|
175
163
|
}: ScreenProps,
|
|
176
164
|
ref: any
|
|
177
165
|
) => {
|
|
@@ -187,9 +175,10 @@ const Screen = forwardRef(
|
|
|
187
175
|
|
|
188
176
|
let handleScroll;
|
|
189
177
|
let Component: any = View;
|
|
190
|
-
|
|
178
|
+
|
|
179
|
+
let keyboardOffset = heightHeader - Math.min(insets.bottom, 21);
|
|
191
180
|
if (headerType === 'extended' || animatedHeader || inputSearchProps) {
|
|
192
|
-
keyboardOffset = -
|
|
181
|
+
keyboardOffset = -Math.min(insets.bottom, 21);
|
|
193
182
|
}
|
|
194
183
|
|
|
195
184
|
/**
|
|
@@ -244,8 +233,6 @@ const Screen = forwardRef(
|
|
|
244
233
|
{...props}
|
|
245
234
|
animatedValue={animatedValue.current}
|
|
246
235
|
useShadowHeader={useShadowHeader}
|
|
247
|
-
headerBackground={headerBackground}
|
|
248
|
-
gradientColor={gradientColor}
|
|
249
236
|
/>
|
|
250
237
|
),
|
|
251
238
|
headerTitle: (props: any) => <HeaderTitle {...props} />,
|
|
@@ -289,8 +276,6 @@ const Screen = forwardRef(
|
|
|
289
276
|
animatedValue={animatedValue.current}
|
|
290
277
|
useGradient={false}
|
|
291
278
|
useShadowHeader={useShadowHeader}
|
|
292
|
-
headerBackground={headerBackground}
|
|
293
|
-
gradientColor={gradientColor}
|
|
294
279
|
/>
|
|
295
280
|
),
|
|
296
281
|
headerTitle: (props: any) => {
|
|
@@ -358,7 +343,7 @@ const Screen = forwardRef(
|
|
|
358
343
|
} else {
|
|
359
344
|
setHeaderType(headerType);
|
|
360
345
|
}
|
|
361
|
-
}, [headerType, animatedHeader, inputSearchProps]);
|
|
346
|
+
}, [headerType, animatedHeader, inputSearchProps, useShadowHeader]);
|
|
362
347
|
|
|
363
348
|
/**
|
|
364
349
|
* expose ref for screen
|
|
@@ -502,8 +487,6 @@ const Screen = forwardRef(
|
|
|
502
487
|
navigation={navigation}
|
|
503
488
|
inputSearchRef={inputSearchRef}
|
|
504
489
|
useShadowHeader={useShadowHeader}
|
|
505
|
-
gradientColor={gradientColor}
|
|
506
|
-
headerBackground={headerBackground}
|
|
507
490
|
/>
|
|
508
491
|
|
|
509
492
|
<KeyboardAvoidingView
|