-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
104 lines (100 loc) · 3.28 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 {
StatusBar,
Image,
Animated,
View,
Dimensions,
StyleSheet,
} from 'react-native';
const {width} = Dimensions.get('screen');
const data = [
'https://cdn.dribbble.com/users/3281732/screenshots/11192830/media/7690704fa8f0566d572a085637dd1eee.jpg?compress=1&resize=1200x1200',
'https://cdn.dribbble.com/users/3281732/screenshots/13130602/media/592ccac0a949b39f058a297fd1faa38e.jpg?compress=1&resize=1200x1200',
'https://cdn.dribbble.com/users/3281732/screenshots/9165292/media/ccbfbce040e1941972dbc6a378c35e98.jpg?compress=1&resize=1200x1200',
'https://cdn.dribbble.com/users/3281732/screenshots/11205211/media/44c854b0a6e381340fbefe276e03e8e4.jpg?compress=1&resize=1200x1200',
'https://cdn.dribbble.com/users/3281732/screenshots/7003560/media/48d5ac3503d204751a2890ba82cc42ad.jpg?compress=1&resize=1200x1200',
'https://cdn.dribbble.com/users/3281732/screenshots/6727912/samji_illustrator.jpeg?compress=1&resize=1200x1200',
'https://cdn.dribbble.com/users/3281732/screenshots/13661330/media/1d9d3cd01504fa3f5ae5016e5ec3a313.jpg?compress=1&resize=1200x1200',
];
const imageW = width * 0.7;
const imageH = imageW * 1.54;
const App = () => {
const scrollX = React.useRef(new Animated.Value(0)).current;
return (
<View style={{flex: 1, backgroundColor: 'white'}}>
<StatusBar hidden />
<View style={StyleSheet.absoluteFillObject}>
{data.map((image, index) => {
const inputRange = [
(index - 1) * width,
index * width,
(index + 1) * width,
];
const opacity = scrollX.interpolate({
inputRange,
outputRange: [0, 1, 0],
});
return (
<Animated.Image
key={`image-${index}`}
source={{uri: image}}
style={[
StyleSheet.absoluteFillObject,
{
opacity,
},
]}
blurRadius={30}
/>
);
})}
</View>
<Animated.FlatList
onScroll={Animated.event(
[{nativeEvent: {contentOffset: {x: scrollX}}}],
{useNativeDriver: true},
)}
data={data}
keyExtractor={(_, index) => index.toString()}
horizontal
pagingEnabled
renderItem={({item}) => {
return (
<View
style={{
width,
justifyContent: 'center',
alignItems: 'center',
}}>
<View
style={{
shadowColor: '#000',
shadowOpacity: 0.5,
shadowOffset: {
width: 0,
height: 0,
},
shadowRadius: 20,
elevation: 12,
backgroundColor: 'transparent',
borderRadius: 16,
}}>
<Image
source={{uri: item}}
style={{
width: imageW,
height: imageH,
resizeMode: 'cover',
borderRadius: 16,
}}
/>
</View>
</View>
);
}}
/>
</View>
);
};
export default App;