@momo-kits/foundation 0.111.1-optimize.3 → 0.111.1-optimize.4

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.
@@ -0,0 +1,105 @@
1
+ import React, {FC, useContext} from 'react';
2
+ import {Animated, Platform, StyleSheet} from 'react-native';
3
+ import {Image} from '../../Image';
4
+ import {Colors} from '../../Consts';
5
+ import {ApplicationContext} from '@momo-kits/foundation';
6
+ import AnimatedInterpolation = Animated.AnimatedInterpolation;
7
+
8
+ type BackgroundImageViewProps = {
9
+ useShadowHeader: boolean;
10
+ headerBackground?: string;
11
+ heightHeader: number | string;
12
+ opacityBackground: AnimatedInterpolation;
13
+ };
14
+
15
+ const BackgroundImageView: FC<BackgroundImageViewProps> = ({
16
+ useShadowHeader = true,
17
+ headerBackground = null,
18
+ heightHeader,
19
+ opacityBackground,
20
+ }) => {
21
+ const {theme} = useContext(ApplicationContext);
22
+ return (
23
+ <>
24
+ <Animated.View
25
+ style={[
26
+ useShadowHeader ? styles.shadowHeader : styles.dividerHeader,
27
+ {
28
+ position: 'absolute',
29
+ width: '100%',
30
+ zIndex: 1,
31
+ height: heightHeader,
32
+ backgroundColor: theme.colors.background.surface,
33
+ opacity: opacityBackground,
34
+ overflow: Platform.OS === 'android' ? 'hidden' : 'visible',
35
+ },
36
+ ]}>
37
+ {Platform.OS === 'android' && headerBackground && (
38
+ <Image
39
+ style={styles.headerBackground}
40
+ source={{uri: headerBackground}}
41
+ loading={false}
42
+ />
43
+ )}
44
+ </Animated.View>
45
+ {Platform.OS === 'ios' && (
46
+ <Animated.View
47
+ style={[
48
+ {
49
+ position: 'absolute',
50
+ width: '100%',
51
+ zIndex: 1,
52
+ height: heightHeader,
53
+ overflow: 'hidden',
54
+ },
55
+ ]}>
56
+ {headerBackground && (
57
+ <Image
58
+ style={styles.headerBackground}
59
+ source={{uri: headerBackground}}
60
+ loading={false}
61
+ />
62
+ )}
63
+ </Animated.View>
64
+ )}
65
+ </>
66
+ );
67
+ };
68
+
69
+ export default BackgroundImageView;
70
+
71
+ const styles = StyleSheet.create({
72
+ headerBackground: {
73
+ width: '100%',
74
+ height: undefined,
75
+ position: 'absolute',
76
+ aspectRatio: 375 / 154,
77
+ },
78
+ dividerHeader: {
79
+ borderBottomWidth: 1,
80
+ borderColor: Colors.black_04,
81
+ },
82
+ shadowHeader: {
83
+ ...Platform.select({
84
+ ios: {
85
+ shadowColor: Colors.black_20,
86
+ shadowOffset: {
87
+ width: 3,
88
+ height: 3,
89
+ },
90
+ shadowOpacity: 0.12,
91
+ shadowRadius: 10,
92
+ },
93
+ android: {
94
+ shadowColor: Colors.black_17,
95
+ shadowOffset: {
96
+ width: 3,
97
+ height: 3,
98
+ },
99
+ shadowOpacity: 0.12,
100
+ shadowRadius: 10,
101
+ elevation: 10,
102
+ },
103
+ }),
104
+ },
105
+ });
@@ -1,10 +1,11 @@
1
1
  import LinearGradient from 'react-native-linear-gradient';
2
- import {Animated, Platform, StyleSheet, View} from 'react-native';
2
+ import {Animated, StyleSheet, View} from 'react-native';
3
3
  import React, {useContext} from 'react';
4
4
  import {HeaderBackgroundProps} from '../types';
5
5
  import {ApplicationContext} from '../index';
6
- import {Colors, Styles} from '../../Consts';
6
+ import {Styles} from '../../Consts';
7
7
  import {Image} from '../../Image';
8
+ import BackgroundImageView from './BackgroundImageView';
8
9
 
9
10
  const LinearGradientAnimated = Animated.createAnimatedComponent(LinearGradient);
10
11
 
@@ -33,39 +34,14 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
33
34
  extrapolate: 'clamp',
34
35
  });
35
36
 
36
- if (Platform.OS === 'android' && headerImage) {
37
- useShadowHeader = false;
38
- }
39
-
40
37
  return (
41
38
  <View style={Styles.flex}>
42
- <Animated.View
43
- style={[
44
- useShadowHeader ? styles.shadowHeader : styles.dividerHeader,
45
- {
46
- backgroundColor: theme.colors.background.surface,
47
- opacity: opacityBackground,
48
- height: '100%',
49
- width: '100%',
50
- },
51
- ]}
39
+ <BackgroundImageView
40
+ useShadowHeader={useShadowHeader}
41
+ heightHeader={'100%'}
42
+ opacityBackground={opacityBackground}
43
+ headerBackground={headerBackground}
52
44
  />
53
- <Animated.View
54
- style={{
55
- position: 'absolute',
56
- zIndex: 1,
57
- height: '100%',
58
- width: '100%',
59
- overflow: 'hidden',
60
- }}>
61
- {theme?.assets?.headerBackground && (
62
- <Image
63
- style={styles.headerBackground}
64
- source={{uri: theme?.assets?.headerBackground}}
65
- loading={false}
66
- />
67
- )}
68
- </Animated.View>
69
45
  <View style={styles.gradientContainer}>
70
46
  {useGradient && !!gradientColor && (
71
47
  <LinearGradientAnimated
@@ -86,29 +62,6 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
86
62
  };
87
63
 
88
64
  const styles = StyleSheet.create({
89
- shadowHeader: {
90
- ...Platform.select({
91
- ios: {
92
- shadowColor: Colors.black_20,
93
- shadowOffset: {
94
- width: 3,
95
- height: 3,
96
- },
97
- shadowOpacity: 0.12,
98
- shadowRadius: 10,
99
- },
100
- android: {
101
- shadowColor: Colors.black_17,
102
- shadowOffset: {
103
- width: 3,
104
- height: 3,
105
- },
106
- shadowOpacity: 0.12,
107
- shadowRadius: 10,
108
- elevation: 10,
109
- },
110
- }),
111
- },
112
65
  gradientContainer: {
113
66
  width: '100%',
114
67
  height: '100%',
@@ -125,10 +78,6 @@ const styles = StyleSheet.create({
125
78
  position: 'absolute',
126
79
  aspectRatio: 375 / 152,
127
80
  },
128
- dividerHeader: {
129
- borderBottomWidth: 1,
130
- borderColor: Colors.black_04,
131
- },
132
81
  });
133
82
 
134
83
  export {HeaderBackground};
@@ -8,6 +8,7 @@ import Navigation from '../Navigation';
8
8
  import {Colors, Radius, Spacing} from '../../Consts';
9
9
  import {Image} from '../../Image';
10
10
  import {SearchHeaderProps} from '../types';
11
+ import BackgroundImageView from './BackgroundImageView';
11
12
 
12
13
  const SCREEN_PADDING = 12;
13
14
  const BACK_WIDTH = 28;
@@ -88,7 +89,7 @@ const HeaderExtendHeader: React.FC<{
88
89
  extrapolate: 'clamp',
89
90
  });
90
91
 
91
- if (Platform.OS === 'android' && headerBackground) {
92
+ if (inputSearchProps && Platform.OS === 'android') {
92
93
  useShadowHeader = false;
93
94
  }
94
95
 
@@ -96,38 +97,12 @@ const HeaderExtendHeader: React.FC<{
96
97
  return (
97
98
  <>
98
99
  <Animated.View style={{height: height}} />
99
- <Animated.View
100
- style={[
101
- useShadowHeader ? styles.shadowHeader : styles.dividerHeader,
102
- {
103
- position: 'absolute',
104
- width: '100%',
105
- zIndex: 1,
106
- height: heightHeader,
107
- backgroundColor: theme.colors.background.surface,
108
- opacity: opacityBackground,
109
- },
110
- ]}
100
+ <BackgroundImageView
101
+ useShadowHeader={useShadowHeader}
102
+ heightHeader={heightHeader}
103
+ opacityBackground={opacityBackground}
104
+ headerBackground={headerBackground}
111
105
  />
112
- <Animated.View
113
- style={[
114
- {
115
- position: 'absolute',
116
- width: '100%',
117
- height: heightHeader,
118
- zIndex: 1,
119
- overflow: 'hidden',
120
- },
121
- ]}>
122
- {headerBackground && (
123
- <Image
124
- style={styles.headerBackground}
125
- source={{uri: headerBackground}}
126
- loading={false}
127
- />
128
- )}
129
- </Animated.View>
130
-
131
106
  <Animated.View
132
107
  style={[
133
108
  styles.headerBox,
@@ -185,37 +160,12 @@ const HeaderExtendHeader: React.FC<{
185
160
  if (headerType === 'extended') {
186
161
  return (
187
162
  <>
188
- <Animated.View
189
- style={[
190
- useShadowHeader ? styles.shadowHeader : styles.dividerHeader,
191
- {
192
- position: 'absolute',
193
- width: '100%',
194
- zIndex: 1,
195
- height: heightHeader,
196
- backgroundColor: theme.colors.background.surface,
197
- opacity: opacityBackground,
198
- },
199
- ]}
163
+ <BackgroundImageView
164
+ useShadowHeader={useShadowHeader}
165
+ heightHeader={heightHeader}
166
+ opacityBackground={opacityBackground}
167
+ headerBackground={headerBackground}
200
168
  />
201
- <Animated.View
202
- style={[
203
- {
204
- position: 'absolute',
205
- width: '100%',
206
- zIndex: 1,
207
- height: heightHeader,
208
- overflow: 'hidden',
209
- },
210
- ]}>
211
- {headerBackground && (
212
- <Image
213
- style={styles.headerBackground}
214
- source={{uri: headerBackground}}
215
- loading={false}
216
- />
217
- )}
218
- </Animated.View>
219
169
  {!!gradientColor && (
220
170
  <LinearGradientAnimated
221
171
  colors={[gradientColor, gradientColor + '00']}
@@ -271,33 +221,6 @@ const styles = StyleSheet.create({
271
221
  position: 'absolute',
272
222
  alignSelf: 'center',
273
223
  },
274
- dividerHeader: {
275
- borderBottomWidth: 1,
276
- borderColor: Colors.black_04,
277
- },
278
- shadowHeader: {
279
- ...Platform.select({
280
- ios: {
281
- shadowColor: Colors.black_20,
282
- shadowOffset: {
283
- width: 3,
284
- height: 3,
285
- },
286
- shadowOpacity: 0.12,
287
- shadowRadius: 10,
288
- },
289
- android: {
290
- shadowColor: Colors.black_17,
291
- shadowOffset: {
292
- width: 3,
293
- height: 3,
294
- },
295
- shadowOpacity: 0.12,
296
- shadowRadius: 10,
297
- elevation: 10,
298
- },
299
- }),
300
- },
301
224
  });
302
225
 
303
226
  export {HeaderExtendHeader};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.111.1-optimize.3",
3
+ "version": "0.111.1-optimize.4",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},