forked from Trinea/react-native-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViewPagerAndroidDemo.js
75 lines (71 loc) · 1.75 KB
/
ViewPagerAndroidDemo.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
/**
* React Native Demo
* https://github.com/trinea/react-native-demo
* @Trinea
*/
import React, { Component } from 'react';
import {
AppRegistry,
Text, View, ViewPagerAndroid, TouchableOpacity,
} from 'react-native';
export default class ViewPagerAndroidDemo extends Component {
constructor(props) {
super(props);
}
onClick(page) {
this.viewPager.setPage(page - 1);
}
render() {
return (
<View style={styles.flex1}>
<ViewPagerAndroid
ref={viewPager => { this.viewPager = viewPager; }}
style={styles.flex1}
initialPage={1}
pageMargin={0}>
<View style={styles.page}>
<Text>Page 1</Text>
</View>
<View style={styles.page}>
<Text>Page 2</Text>
</View>
<View style={styles.page}>
<Text>Page 3</Text>
</View>
</ViewPagerAndroid>
<View style={styles.footerMenu}>
<TouchableOpacity onPress={() => this.onClick(1)}>
<Text>Tab 1</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.onClick(2)}>
<Text>Tab 2</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.onClick(3)}>
<Text>Tab 3</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
var styles = {
flex1: {
flex: 1,
},
page: {
alignItems: 'center',
flexDirection: 'row',
flex: 1,
justifyContent: 'center',
borderWidth: 1,
borderColor: 'black',
},
footerMenu: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
backgroundColor: '#F2F2F2',
height: 40,
paddingHorizontal: 40,
},
}