KeywordText.js
1.83 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
'use strict';
import React from 'react';
import ReactNative from 'react-native';
const {
View,
Image,
Text,
TouchableHighlight,
Dimensions,
StyleSheet,
} = ReactNative;
export default class KeywordText extends React.Component {
constructor(props) {
super (props);
this.state = {
helight: false,
}
}
render() {
let {index, keyword, androiddata, onPressKeyword} = this.props;
let textColor = this.state.helight ? {color: 'rgb(66, 66, 66)'} : {color: 'rgb(191, 191, 191)'};
return (
<TouchableHighlight
style={styles.container}
underlayColor={'rgb(255, 255, 255)'}
onPress={() => {
onPressKeyword && onPressKeyword(keyword, androiddata, index);
}}
onPressIn={() => {
this.setState({
helight: !this.state.helight,
});
}}
onPressOut={() => {
this.setState({
helight: !this.state.helight,
});
}}
>
<Text style={[styles.text, textColor]} numberOfLines={1}>{keyword}</Text>
</TouchableHighlight>
);
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
flexDirection: 'row',
alignItems: 'center',
alignSelf: 'flex-start',
height: 25,
backgroundColor: 'rgb(255, 255, 255)',
borderColor: 'rgb(191, 191, 191)',
borderRadius: 3,
borderWidth: 1,
margin: 4,
maxWidth: width - 52,
},
text: {
marginHorizontal: 10,
marginVertical: 6,
fontSize: 13,
maxWidth: width - 64,
},
});