-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
104 lines (99 loc) · 2.64 KB
/
App.js
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import React from "react";
import {
Animated,
FlatList,
StatusBar,
StyleSheet,
Text,
View,
} from "react-native";
import Footer from "./components/Footer";
import Header from "./components/Header";
const data = [
{ color: "green", title: "Hola Mundo" },
{ color: "violet", title: "Hola Mundo" },
{ color: "orange", title: "Hola Mundo" },
{ color: "green", title: "Hola Mundo" },
{ color: "violet", title: "Hola Mundo" },
{ color: "orange", title: "Hola Mundo" },
{ color: "green", title: "Hola Mundo" },
{ color: "violet", title: "Hola Mundo" },
{ color: "orange", title: "Hola Mundo" },
{ color: "green", title: "Hola Mundo" },
{ color: "violet", title: "Hola Mundo" },
{ color: "orange", title: "Hola Mundo" },
{ color: "green", title: "Hola Mundo" },
{ color: "violet", title: "Hola Mundo" },
{ color: "orange", title: "Hola Mundo" },
];
export default function App() {
const scrollY = React.useRef(new Animated.Value(0)).current;
const diffClamp = Animated.diffClamp(scrollY, 0, 50);
const translateHeaderY = diffClamp.interpolate({
inputRange: [0, 50],
outputRange: [0, -50],
});
const translateFooterY = diffClamp.interpolate({
inputRange: [0, 50],
outputRange: [0, 50],
});
return (
<View style={styles.container}>
<StatusBar backgroundColor="#fff" barStyle="dark-content" />
<Animated.View
style={{
transform: [{ translateY: translateHeaderY }],
zIndex: 100,
}}
>
<Header />
</Animated.View>
<Animated.FlatList
data={data}
showsVerticalScrollIndicator={false}
contentContainerStyle={styles.contentFlatList}
keyExtractor={(_, index) => index.toString()}
onScroll={Animated.event(
[{ nativeEvent: { contentOffset: { y: scrollY } } }],
{ useNativeDriver: true }
)}
renderItem={({ item }) => {
return (
<View
style={[styles.containerItems, { backgroundColor: item.color }]}
>
<Text>{item.title}</Text>
</View>
);
}}
/>
<Animated.View
style={{
transform: [{ translateY: translateFooterY }],
zIndex: 100,
}}
>
<Footer />
</Animated.View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
},
contentFlatList: {
marginTop: 50,
paddingTop: 10,
paddingBottom: 60,
},
containerItems: {
height: 120,
marginBottom: 20,
borderRadius: 10,
justifyContent: "center",
alignItems: "center",
marginHorizontal: 20,
},
});