1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
import React from 'react';
import Animated, {interpolate} from 'react-native-reanimated';
import {StyleSheet} from 'react-native';
import {SCREEN_HEIGHT, SCREEN_WIDTH, StatusBarHeight} from '../../utils';
interface SearchResultsBackgroundProps {
top: Animated.Value<number>;
}
const SearchResultsBackground: React.FC<SearchResultsBackgroundProps> = ({
top,
children,
}) => {
const opacityBackground: Animated.Node<number> = interpolate(top, {
inputRange: [-SCREEN_HEIGHT, 0],
outputRange: [0, 1],
});
const opacityContent: Animated.Node<number> = interpolate(top, {
inputRange: [-SCREEN_HEIGHT / 40, 0],
outputRange: [0, 1],
});
return (
<Animated.View
style={[styles.container, {opacity: opacityBackground, top}]}>
<Animated.ScrollView
contentContainerStyle={styles.contentContainer}
style={[styles.results, {opacity: opacityContent}]}>
{children}
</Animated.ScrollView>
</Animated.View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
height: SCREEN_HEIGHT,
width: SCREEN_WIDTH,
padding: 20,
position: 'absolute',
backgroundColor: '#fff',
zIndex: 0,
},
contentContainer: {
flexGrow: 1,
paddingBottom: SCREEN_HEIGHT / 15,
},
results: {
marginTop: StatusBarHeight + 110,
},
});
export default SearchResultsBackground;
|