-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNavBarBackButton.ios.js
More file actions
75 lines (66 loc) · 1.56 KB
/
NavBarBackButton.ios.js
File metadata and controls
75 lines (66 loc) · 1.56 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
/* @flow */
import React from 'react'
import PropTypes from 'prop-types'
import { TouchableOpacity, Text, StyleSheet } from 'react-native'
import Ionicon from 'react-native-vector-icons/Ionicons'
type State = {
tintColor: String
}
class NavBarBackButton extends React.Component<any, State> {
state: State
static propTypes = {
...TouchableOpacity.propTypes,
tintColor: PropTypes.string,
children: PropTypes.string.isRequired,
style: Text.propTypes.style,
showBackTitle: PropTypes.bool,
}
constructor (props: Object) {
super(props)
this.state = {
tintColor: props.tintColor || 'black'
}
}
_renderBackTitle () {
if (this.props.showBackTitle) {
return (
<Text style={[this.props.style, styles.navText]}>
{this.props.children}
</Text>
)
}
}
render () {
const touchableProps = {
onPress: this.props.onPress,
onPressIn: this.props.onPressIn,
onPressOut: this.props.onPressOut,
onLongPress: this.props.onLongPress
}
return (
<TouchableOpacity
{...touchableProps}
style={styles.container}>
<Ionicon name='ios-arrow-back' size={32} style={styles.icon}
color={this.state.tintColor} />
{this._renderBackTitle()}
</TouchableOpacity>
)
}
}
const styles = StyleSheet.create({
container: {
flexDirection: 'row',
paddingTop: 2,
paddingRight: 15,
},
icon: {
paddingLeft: 8,
paddingTop: 2,
},
navText: {
paddingLeft: 5,
paddingTop: 7,
},
})
export default NavBarBackButton