-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
91 lines (84 loc) · 2.63 KB
/
index.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
90
91
'use strict';
// Module dependencies
let React = require('react-native');
let styles = require('./styles');
let {
Text,
View,
TouchableOpacity,
PropTypes
} = React;
const STATUS_BAR_HEIGHT = 20;
const NAV_BAR_HEIGHT = 39;
module.exports = React.createClass({
propTypes: {
title: PropTypes.string,
backFunc: PropTypes.func,
tintColor: PropTypes.string,
titleTextColor: PropTypes.string,
barTintColor: PropTypes.string,
actionName: PropTypes.string,
actionFunc: PropTypes.func,
actionTextColor: PropTypes.string,
backHidden: PropTypes.bool,
statusbarPadding: PropTypes.bool,
backColor: PropTypes.string,
barBottomColor: PropTypes.string,
barBottomThickness: PropTypes.number,
backIcon: PropTypes.bool,
backName: PropTypes.string,
},
getDefaultProps () {
return {
title: 'title',
backFunc () {},
tintColor: '#777',
backColor: '#777',
titleTextColor: '#333',
barTintColor: 'white',
actionName: '',
actionFunc () {},
actionTextColor: '#666',
backHidden: false,
backIcon: true,
backName: 'back',
backTextColor: '#666',
statusbarPadding: true,
barBottomColor: '#d4d4d4',
barBottomThickness: 0.5,
};
},
render () {
return (
<View style={
[styles.navbar,
{
backgroundColor: this.props.barTintColor,
height: this.props.statusbarPadding ? NAV_BAR_HEIGHT + STATUS_BAR_HEIGHT : NAV_BAR_HEIGHT,
borderColor: this.props.barBottomColor,
borderBottomWidth: this.props.barBottomThickness,
},
this.props.statusbarPadding ? { paddingTop: STATUS_BAR_HEIGHT } : {}]}>
{
!this.props.backHidden ?
<TouchableOpacity
style={this.props.backIcon ? styles.iconWrapper : styles.backBtn}
onPress={this.props.backFunc}>
{
this.props.backIcon ?
<View style={[styles.icon, {borderColor:this.props.backColor}]} />:
<Text style={[styles.actionName, {color: this.props.backColor}]}>{this.props.backName}</Text>
}
</TouchableOpacity> : null
}
<Text style={[styles.title, {color:this.props.titleTextColor}]}>{this.props.title}</Text>
{
this.props.actionName ?
<TouchableOpacity style={styles.actionBtn} onPress={this.props.actionFunc.bind(this)}>
<Text style={[styles.actionName, { color: this.props.actionTextColor }]}>{this.props.actionName}</Text>
</TouchableOpacity> : null
}
</View>
);
}
});