-
Notifications
You must be signed in to change notification settings - Fork 427
/
Copy pathCommonRowItem.js
99 lines (89 loc) · 2.89 KB
/
CommonRowItem.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
92
93
94
95
96
97
98
99
/**
* Created by guoshuyu on 2017/11/11.
*/
import React, {
Component,
} from 'react';
import PropTypes from 'prop-types';
import {
Text,
Image,
View,
TouchableOpacity,
Dimensions,
StyleSheet
} from 'react-native';
import * as Constant from '../../style/constant'
import styles from '../../style/index'
import Icon from 'react-native-vector-icons/EvilIcons'
import IconC from 'react-native-vector-icons/Octicons'
/**
* 通用行Item
*/
class CommonRowItem extends Component {
constructor(props) {
super(props)
}
componentDidMount() {
}
componentWillUnmount() {
}
render() {
let {onClickFun, itemText, showIconNext, textStyle, nameStyle, topLine, bottomLine, itemIcon, iconSize, nameText} = this.props;
let IconComponent = (showIconNext) ?
<Icon name={Constant.nextIcon} size={Constant.smallIconSize} color={Constant.primaryColor}/>
: <View/>;
let tl = (topLine) ? StyleSheet.hairlineWidth : 0;
let bl = (bottomLine) ? StyleSheet.hairlineWidth : 0;
let leftIcon = (itemIcon) ?
<IconC name={itemIcon} size={iconSize ? iconSize : 13} color={Constant.primaryColor}/>
: <View/>;
let leftText = (nameText) ?
<Text style={[...nameStyle]}>{nameText}</Text>
: <View/>;
return (
<TouchableOpacity
onPress={() => {
onClickFun && onClickFun()
}}
style={[{
minHeight: 50, marginLeft: Constant.normalMarginEdge, marginRight: Constant.normalMarginEdge,
marginVertical: Constant.normalMarginEdge / 2,
}, ...this.props.viewStyle]}>
<View style={[styles.flexDirectionRow, styles.centerH,
{borderTopWidth: tl, borderTopColor: Constant.lineColor},
{borderBottomWidth: bl, borderBottomColor: Constant.lineColor},]}>
{leftIcon}
{leftText}
<Text style={[{flex: 1}, ...textStyle]}>{itemText}</Text>
{IconComponent}
</View>
</TouchableOpacity>
);
}
}
const propTypes = {
itemText: PropTypes.string,
onClickFun: PropTypes.func,
showIconNext: PropTypes.bool,
topLine: PropTypes.bool,
bottomLine: PropTypes.bool,
itemIcon: PropTypes.string,
iconSize: PropTypes.number,
itemIconColor: PropTypes.string,
nameText: PropTypes.string,
itemIconSize: PropTypes.number,
textStyle: PropTypes.any,
viewStyle: PropTypes.array,
};
CommonRowItem.propTypes = propTypes;
CommonRowItem.defaultProps = {
showIconNext: true,
topLine: true,
bottomLine: true,
textStyle: styles.smallText,
itemIconColor: Constant.primaryColor,
itemIconSize: Constant.smallIconSize,
viewStyle: [],
};
export default CommonRowItem;