-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNavBarButton.js
58 lines (51 loc) · 1.4 KB
/
NavBarButton.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
/**
* Created by Rahul Jiresal on 11/5/15.
*/
'use strict';
var ReactNative = require('react-native');
var React = require('react');
var {
TouchableOpacity,
Text,
StyleSheet,
Image
} = ReactNative;
var NavBarButton = React.createClass({
render: function() {
var alignment = (this.props.side === 'left') ? styles.navBarLeftButton : styles.navBarRightButton;
var child;
if (this.props.text) {
child = <Text style={[styles.navBarButtonText, { color: this.props.color || 'black' }]}>{this.props.text}</Text>;
}
else if (this.props.source) {
child = <Image style={[styles.navBarTitleImage, this.props.color ? { tintColor: this.props.color } : {} ]}
source={this.props.source}
resizeMode={ 'contain' }/>
}
return (
<TouchableOpacity
style={ alignment }
onPress={this.props.onPress}>
{ child }
</TouchableOpacity>
);
},
});
var styles = StyleSheet.create({
navBarLeftButton: {
paddingLeft: 10,
justifyContent: 'center'
},
navBarRightButton: {
paddingRight: 10,
justifyContent: 'center'
},
navBarButtonText: {
fontSize: 16,
},
navBarTitleImage: {
height: 24,
width: 24,
}
})
module.exports = NavBarButton;