SectionItem.js
1.07 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
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import PropTypes from 'prop-types';
const {
View,
Text,
Image,
TouchableOpacity,
StyleSheet,
Dimensions,
} = ReactNative;
export default class SectionItem extends React.Component {
static propTypes = {
name: PropTypes.string.isRequired,
onPressSection: PropTypes.func,
};
constructor(props) {
super (props);
}
render() {
if (!this.props.name) {
return null;
}
return (
<TouchableOpacity style={styles.container} onPress={() => {
this.props.onPressSection && this.props.onPressSection();
}}>
<Text style={styles.name}>{this.props.name}</Text>
</TouchableOpacity>
);
}
}
let styles = StyleSheet.create({
container: {
flexDirection: 'row',
// alignItems: 'center',
alignSelf: 'center',
backgroundColor: '#f2f2f2',
},
name: {
fontSize: 14,
margin: 4,
},
});