-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSwiperExample.js
84 lines (77 loc) · 1.84 KB
/
SwiperExample.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
import React, {Component} from 'react';
import {Text, View, StyleSheet} from 'react-native';
import Swiper from 'react-native-swiper';
import {PageControlJaloro} from 'react-native-chi-page-control';
export default class SwiperEaxample extends Component {
state = {
progress: 0,
};
constructor(props) {
super(props);
this.onIndexChanged = this.onIndexChanged.bind(this);
}
render() {
return (
<View style={{flex: 1}}>
<Swiper
style={styles.wrapper}
showsPagination={false}
loop={false}
onIndexChanged={this.onIndexChanged}
>
<View style={styles.slide1}>
<Text style={styles.text}>Hello Swiper</Text>
</View>
<View style={styles.slide2}>
<Text style={styles.text}>Beautiful</Text>
</View>
<View style={styles.slide3}>
<Text style={styles.text}>And simple</Text>
</View>
</Swiper>
<View style={styles.pageControlView}>
<PageControlJaloro
progress={this.state.progress}
numberOfPages={3}
animationDuration={300}
/>
</View>
</View>
);
}
onIndexChanged(index) {
this.setState({progress: index / 2});
}
}
const styles = StyleSheet.create({
wrapper: {},
slide1: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#9DD6EB',
},
slide2: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#97CAE5',
},
slide3: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#92BBD9',
},
text: {
color: '#fff',
fontSize: 30,
fontWeight: 'bold',
},
pageControlView: {
position: 'absolute',
width: '100%',
alignItems: 'center',
bottom: 50,
},
});