-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswiper.js
107 lines (73 loc) · 2.74 KB
/
swiper.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
105
106
import React from 'react';
import {
SafeAreaView,
View,
StatusBar,Image,Text,Dimensions,StyleSheet
} from 'react-native';
import Swiper from 'react-native-swiper';
class App extends React.Component {
constructor(props) {
super(props);
this.state ={
//data:require("./data.json")
}
}
render() {
const { width } = Dimensions.get('window');
const styles = StyleSheet.create({
container: {
height: 200,
width:width
},
wrapper: {
},
slide: {
flex: 1,
justifyContent: 'center',
backgroundColor: 'transparent'
},
text: {
color: '#fff',
fontSize: 30,
fontWeight: 'bold',
},
image: {
width,
height: 120,
flex: 1
}
});
return (
<>
<StatusBar />
<SafeAreaView>
<View style={styles.container}>
<Swiper style={styles.wrapper} height={140}
onMomentumScrollEnd={(e, state, context) => console.log('index:', state.index)}
dot={<View style={{ backgroundColor: 'rgba(0,0,0,.2)', width: 5, height: 5, borderRadius: 4, marginLeft: 3, marginRight: 3, marginTop: 3, marginBottom: 3 }} />}
activeDot={<View style={{ backgroundColor: '#000', width: 8, height: 8, borderRadius: 4, marginLeft: 3, marginRight: 3, marginTop: 3, marginBottom: 3 }} />}
paginationStyle={{
bottom: -23, left: null, right: 10
}}
autoplay = {true}
>
<View style={styles.slide} title={<Text numberOfLines={1}>Aussie tourist dies at Bali hotel</Text>}>
<Image resizeMode='stretch' style={styles.image} source={require('./assets/big.jpg')} />
</View>
<View style={styles.slide} title={<Text numberOfLines={1}>Big lie behind Nine’s new show</Text>}>
<Image resizeMode='stretch' style={styles.image} source={require('./assets/big.jpg')} />
</View>
<View style={styles.slide} title={<Text numberOfLines={1}>Why Stone split from Garfield</Text>}>
<Image resizeMode='stretch' style={styles.image} source={require('./assets/big.jpg')} />
</View>
<View style={styles.slide} title={<Text numberOfLines={1}>Learn from Kim K to land that job</Text>}>
<Image resizeMode='stretch' style={styles.image} source={require('./assets/big.jpg')} />
</View>
</Swiper>
</View>
</SafeAreaView>
</>
);
}
}
export default App;