forked from osdio/noder-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNav.js
More file actions
95 lines (78 loc) · 1.85 KB
/
Nav.js
File metadata and controls
95 lines (78 loc) · 1.85 KB
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
var React = require('react-native')
var window = require('../util/window')
var { width, height } = window.get()
var {
Component,
View,
Text,
StyleSheet,
TouchableOpacity
} = React
class Nav extends Component {
constructor(props) {
super(props)
}
_renderNavContent() {
var navs = this.props.navs || {}
return ['Left', 'Center', 'Right'].map((position)=> {
var nav = navs[position]
if (nav) {
return (
<TouchableOpacity
onPress={nav.onPress}
>
<Text style={[styles.navItem,styles['nav'+position]]}>
{nav.text}
</Text>
</TouchableOpacity>
)
}
return (
<Text style={[styles.navItem,styles['nav'+position]]}>
</Text>
)
})
}
render() {
return (
<View
ref={view=>this.nav=view}
style={styles.nav}>
{this._renderNavContent()}
</View>
)
}
}
var navHeight = 55
var styles = StyleSheet.create({
nav: {
height: navHeight,
width: width,
borderBottomColor: 'rgba(0,0,0,0.03)',
borderBottomWidth: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center'
},
navItem: {
color: 'rgba(0,0,0,0.7)',
fontSize: 16
},
navLeft: {
textAlign: 'left',
paddingLeft: 15,
flex: 1
},
navRight: {
textAlign: 'right',
paddingRight: 15,
flex: 1
},
navCenter: {
textAlign: 'center',
flex: 2,
color: '#3498DB'
}
})
Nav.navHeight = navHeight
module.exports = Nav