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
93 lines (78 loc) · 1.55 KB
/
Nav.js
File metadata and controls
93 lines (78 loc) · 1.55 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
import React, {
Component,
View,
Text,
StyleSheet,
TouchableOpacity,
Dimensions,
Platform
} from 'react-native';
const {height, width} = Dimensions.get('window');
class Nav extends Component {
_renderNavContent() {
let navs = this.props.navs || {};
return ['Left', 'Center', 'Right'].map((position)=> {
let nav = navs[position];
if (nav) {
return (
<TouchableOpacity
key={position}
onPress={nav.onPress}
style={{flex: position=='Center'?2:1}}>
<Text style={[styles.navItem,styles['nav'+position]]}>
{nav.text}
</Text>
</TouchableOpacity>
)
}
return (
<Text key={position} style={[styles.navItem,styles['nav'+position]]}/>
)
})
}
render() {
return (
<View
ref={view=>this.nav=view}
style={styles.nav}>
{this._renderNavContent()}
</View>
)
}
}
const navHeight = 55;
const statusBarHeight = Platform.OS === 'ios' ? 20 : 0;
const styles = StyleSheet.create({
nav: {
height: navHeight + statusBarHeight,
width: width,
borderBottomColor: 'rgba(0,0,0,0.03)',
backgroundColor: '#292829',
borderBottomWidth: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
paddingTop: statusBarHeight,
paddingLeft: 15,
paddingRight: 15
},
navItem: {
color: 'rgba(255,255,255,0.7)',
fontSize: 16
},
navLeft: {
textAlign: 'left',
flex: 1
},
navRight: {
textAlign: 'right',
flex: 1
},
navCenter: {
textAlign: 'center',
color: 'rgba(241,196,15,0.9)',
flex: 2
}
});
Nav.navHeight = navHeight;
export default Nav;