-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
90 lines (85 loc) · 2.07 KB
/
App.tsx
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import React from 'react';
import {
Animated,
View,
Text,
Image,
SafeAreaView,
StyleSheet,
} from 'react-native';
import ParallaxScrollView from './ParallaxScrollView';
/**
* Photo by Anna Meshkov on Unsplash
*/
const uri =
'https://images.unsplash.com/photo-1587895517743-aeb27c849044?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1234&q=80';
export default class App extends React.Component {
renderParallaxHeader = (value) => {
return <Image source={{uri}} style={Styles.image} resizeMode="cover" />;
};
renderFixedHeader = (value) => {
return (
<View style={Styles.fixedHeader}>
<Text style={{color: 'white'}}>Fixed Header</Text>
</View>
);
};
renderStickyHeader = (value) => {
const opacity = value.interpolate({
inputRange: [0, 150, 200],
outputRange: [0, 0, 1],
extrapolate: 'clamp',
});
return (
<View style={Styles.stickyHeader}>
<Animated.View style={[Styles.stickyHeaderBackground, {opacity}]} />
</View>
);
};
render() {
const IHeight = 250;
const HeaderHeight = 50;
return (
<SafeAreaView style={{flex: 1}}>
<ParallaxScrollView
style={{flex: 1}}
parallaxHeaderHeight={IHeight}
stickyHeaderHeight={HeaderHeight}
parallaxHeader={this.renderParallaxHeader}
fixedHeader={this.renderFixedHeader}
stickyHeader={this.renderStickyHeader}>
<View style={Styles.content}>
<Text>Content</Text>
</View>
</ParallaxScrollView>
</SafeAreaView>
);
}
}
const Styles = StyleSheet.create({
image: {
width: '100%',
height: '100%',
},
fixedHeader: {
height: 50,
width: '100%',
padding: 10,
justifyContent: 'center',
},
stickyHeader: {
height: 50,
width: '100%',
backgroundColor: 'rgba(0,0,0,0.4)',
},
stickyHeaderBackground: {
...StyleSheet.absoluteFill,
backgroundColor: 'purple',
},
content: {
width: '100%',
height: 10000,
padding: 20,
backgroundColor: 'green',
},
});