@momo-kits/foundation 0.109.1-beta.2 → 0.109.1-beta.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.
@@ -16,10 +16,14 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
16
16
  animatedValue,
17
17
  useGradient = true,
18
18
  useShadowHeader = true,
19
+ gradientColor,
20
+ headerBackground,
19
21
  }) => {
20
22
  const {theme} = useContext(ApplicationContext);
21
23
 
22
- let headerImage = theme.assets?.headerBackground;
24
+ const linearGradientColor = gradientColor ?? theme.colors.gradient;
25
+
26
+ let headerImage = headerBackground ?? theme.assets?.headerBackground;
23
27
  if (image === null) {
24
28
  headerImage = undefined;
25
29
  }
@@ -50,7 +54,7 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
50
54
  <View style={styles.gradientContainer}>
51
55
  {useGradient && (
52
56
  <LinearGradientAnimated
53
- colors={[theme.colors.gradient, theme.colors.gradient + '00']}
57
+ colors={[linearGradientColor, linearGradientColor + '00']}
54
58
  style={[styles.extendedHeader, {opacity: opacityGradient}]}>
55
59
  {!!headerImage && (
56
60
  <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} from '../../Consts';
8
+ import {Colors, Radius, Spacing, Styles} from '../../Consts';
9
9
  import {Image} from '../../Image';
10
10
 
11
11
  const SCREEN_PADDING = 12;
@@ -27,6 +27,8 @@ const HeaderExtendHeader: React.FC<{
27
27
  inputSearchRef?: Ref<InputRef>;
28
28
  navigation?: Navigation;
29
29
  useShadowHeader?: boolean;
30
+ gradientColor?: string;
31
+ headerBackground?: string;
30
32
  }> = ({
31
33
  headerType = 'default',
32
34
  animatedValue,
@@ -35,11 +37,17 @@ const HeaderExtendHeader: React.FC<{
35
37
  inputSearchProps,
36
38
  inputSearchRef,
37
39
  useShadowHeader = true,
40
+ gradientColor,
41
+ headerBackground: customHeaderBackground,
38
42
  }) => {
39
43
  const {theme} = useContext(ApplicationContext);
40
44
 
41
45
  const animated = useRef(new Animated.Value(0));
42
46
 
47
+ const linearGradientColor = gradientColor ?? theme.colors.gradient;
48
+ const headerBackground =
49
+ customHeaderBackground ?? theme.assets?.headerBackground;
50
+
43
51
  const opacityBackground = animatedValue?.interpolate({
44
52
  inputRange: [0, 52],
45
53
  outputRange: [0, 1],
@@ -82,47 +90,12 @@ const HeaderExtendHeader: React.FC<{
82
90
  });
83
91
 
84
92
  if (inputSearchProps) {
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
-
93
+ const renderInputView = () => {
94
+ return (
120
95
  <Animated.View
121
96
  style={{
122
97
  justifyContent: 'flex-end',
123
98
  height,
124
- position: 'absolute',
125
- zIndex: 2,
126
99
  }}>
127
100
  <Animated.View
128
101
  style={{
@@ -147,6 +120,40 @@ const HeaderExtendHeader: React.FC<{
147
120
  </Animated.View>
148
121
  </Animated.View>
149
122
  </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()}
150
157
  <Verified />
151
158
  </>
152
159
  );
@@ -169,12 +176,12 @@ const HeaderExtendHeader: React.FC<{
169
176
  ]}
170
177
  />
171
178
  <LinearGradientAnimated
172
- colors={[theme.colors.gradient, theme.colors.gradient + '00']}
179
+ colors={[linearGradientColor, linearGradientColor + '00']}
173
180
  style={[styles.extendedHeader, {opacity: opacityGradient}]}>
174
- {!!theme.assets?.headerBackground && (
181
+ {!!headerBackground && (
175
182
  <Image
176
183
  style={styles.headerBackground}
177
- source={{uri: theme.assets?.headerBackground}}
184
+ source={{uri: headerBackground}}
178
185
  loading={false}
179
186
  />
180
187
  )}
@@ -303,6 +303,11 @@ const styles = StyleSheet.create({
303
303
  position: 'absolute',
304
304
  width: '100%',
305
305
  },
306
+ headerBox: {
307
+ width: '100%',
308
+ position: 'absolute',
309
+ overflow: 'hidden',
310
+ },
306
311
  verifiedDot: {
307
312
  width: 4,
308
313
  height: 4,
@@ -174,6 +174,8 @@ export type HeaderBackgroundProps = {
174
174
  useGradient?: boolean;
175
175
  useShadowHeader?: boolean;
176
176
  backgroundColor?: string;
177
+ gradientColor?: string;
178
+ headerBackground?: string;
177
179
  };
178
180
 
179
181
  export type TitleUserProps = {
package/Layout/Screen.tsx CHANGED
@@ -136,6 +136,16 @@ 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;
139
149
  }
140
150
 
141
151
  const Screen = forwardRef(
@@ -160,6 +170,8 @@ const Screen = forwardRef(
160
170
  inputSearchProps,
161
171
  inputSearchRef,
162
172
  animatedValue: customAnimatedValue,
173
+ headerBackground,
174
+ gradientColor,
163
175
  }: ScreenProps,
164
176
  ref: any
165
177
  ) => {
@@ -175,10 +187,9 @@ const Screen = forwardRef(
175
187
 
176
188
  let handleScroll;
177
189
  let Component: any = View;
178
-
179
- let keyboardOffset = heightHeader - Math.min(insets.bottom, 21);
190
+ let keyboardOffset = heightHeader - 20;
180
191
  if (headerType === 'extended' || animatedHeader || inputSearchProps) {
181
- keyboardOffset = -Math.min(insets.bottom, 21);
192
+ keyboardOffset = -20;
182
193
  }
183
194
 
184
195
  /**
@@ -233,6 +244,8 @@ const Screen = forwardRef(
233
244
  {...props}
234
245
  animatedValue={animatedValue.current}
235
246
  useShadowHeader={useShadowHeader}
247
+ headerBackground={headerBackground}
248
+ gradientColor={gradientColor}
236
249
  />
237
250
  ),
238
251
  headerTitle: (props: any) => <HeaderTitle {...props} />,
@@ -276,6 +289,8 @@ const Screen = forwardRef(
276
289
  animatedValue={animatedValue.current}
277
290
  useGradient={false}
278
291
  useShadowHeader={useShadowHeader}
292
+ headerBackground={headerBackground}
293
+ gradientColor={gradientColor}
279
294
  />
280
295
  ),
281
296
  headerTitle: (props: any) => {
@@ -343,7 +358,7 @@ const Screen = forwardRef(
343
358
  } else {
344
359
  setHeaderType(headerType);
345
360
  }
346
- }, [headerType, animatedHeader, inputSearchProps, useShadowHeader]);
361
+ }, [headerType, animatedHeader, inputSearchProps]);
347
362
 
348
363
  /**
349
364
  * expose ref for screen
@@ -487,6 +502,8 @@ const Screen = forwardRef(
487
502
  navigation={navigation}
488
503
  inputSearchRef={inputSearchRef}
489
504
  useShadowHeader={useShadowHeader}
505
+ gradientColor={gradientColor}
506
+ headerBackground={headerBackground}
490
507
  />
491
508
 
492
509
  <KeyboardAvoidingView
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.109.1-beta.2",
3
+ "version": "0.109.1-beta.3",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},