KeywordHeader.js
1.78 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
'use strict';
import React from 'react';
import ReactNative from 'react-native';
const {
View,
Image,
Text,
TouchableOpacity,
Dimensions,
StyleSheet,
} = ReactNative;
export default class KeywordHeader extends React.Component {
constructor(props) {
super (props);
}
renderAction() {
if (this.props.onPressAction) {
return (
<TouchableOpacity style={styles.action} onPress={() => {
this.props.onPressAction && this.props.onPressAction();
}}>
<Image
style={styles.delete}
source={require('../../images/shanchu.png')}
resizeMode={'contain'}
/>
</TouchableOpacity>
);
}
return null;
}
render() {
let {icon, title, onPressAction} = this.props;
return (
<View style={styles.container}>
<Image
style={styles.icon}
source={icon}
resizeMode={'contain'}
/>
<Text style={styles.text}>{title}</Text>
{this.renderAction()}
</View>
);
}
}
let styles = StyleSheet.create({
container: {
flexDirection: 'row',
alignItems: 'center',
width: Dimensions.get('window').width,
height: 40,
},
icon: {
marginLeft: 15,
width: 13,
height: 17,
},
text: {
marginLeft: 10,
color: '#b0b0b0',
fontSize: 12,
},
action: {
position: 'absolute',
right: 10,
height: 40,
},
delete: {
width: 28,
height: 28,
top: 6,
},
});