forked from race604/react-native-viewpager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBottomScreen.js
89 lines (77 loc) · 1.6 KB
/
BottomScreen.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
'use strict';
import React from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Dimensions,
ToastAndroid,
Platform,
AlertIOS,
} from 'react-native';
var ViewPager = require('react-native-viewpager');
//var ViewPager = require('./ViewPager');
var deviceWidth = Dimensions.get('window').width;
var PAGES = [
'Page 0',
'Page 1',
'Page 2',
'Page 3',
'Page 4',
];
function notifyMessage(msg: string) {
if (Platform.OS === 'android') {
ToastAndroid.show(msg, ToastAndroid.SHORT)
} else {
AlertIOS.alert(msg);
}
}
var ImagesScreen = React.createClass({
getInitialState: function() {
var dataSource = new ViewPager.DataSource({
pageHasChanged: (p1, p2) => p1 !== p2,
});
return {
dataSource: dataSource.cloneWithPages(PAGES),
};
},
render: function() {
return (
<ViewPager
style={this.props.style}
dataSource={this.state.dataSource}
renderPage={this._renderPage}
onChangePage={this._onChangePage}
isLoop={false}
autoPlay={false}/>
);
},
_renderPage: function(
data: Object,
pageID: number | string,) {
return (
<View style={styles.page}>
<Text style={styles.text}>{data}</Text>
</View>
);
},
_onChangePage: function(
page: number | string
) {
notifyMessage('Current page: ' + page);
},
});
var styles = StyleSheet.create({
page: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
text: {
fontSize: 20,
textAlign: 'center',
},
});
module.exports = ImagesScreen;