-
Notifications
You must be signed in to change notification settings - Fork 427
/
Copy pathCodeFileItem.js
103 lines (93 loc) · 2.7 KB
/
CodeFileItem.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
100
101
102
103
/**
* 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'
import Icon from 'react-native-vector-icons/FontAwesome'
/**
* 代码通用Item
*/
class CodeFileItem extends Component {
constructor(props) {
super(props)
}
componentDidMount() {
}
componentWillUnmount() {
}
render() {
return (
<View/>
)
}
render() {
let {onClickFun, itemText, titleStyle, itemIcon, itemTextTitle, needTitle} = this.props;
let leftIcon = (itemIcon) ?
<Icon name={itemIcon} size={14} color={Constant.subTextColor}/>
: <View/>;
let title = (needTitle) ?
<View style={[styles.flexDirectionRow, styles.centerH, {
marginTop: Constant.normalMarginEdge,
marginHorizontal: Constant.normalMarginEdge,
}]}>
<Text style={[{flex: 1}, ...titleStyle]}>{itemTextTitle}</Text>
</View> : <View/>;
return (
<TouchableOpacity
onPress={() => {
onClickFun && onClickFun()
}}
style={[{
}, ...this.props.viewStyle]}>
{title}
<View
style={[styles.flexDirectionRow, styles.centerH, styles.shadowCard, {
padding: Constant.normalMarginEdge,
marginVertical: Constant.normalMarginEdge / 2,
marginHorizontal: Constant.normalMarginEdge,
borderRadius: 3,
}]}>
{leftIcon}
<Text style={[{flex: 1, marginLeft: Constant.normalMarginEdge}]}>{itemText}</Text>
</View>
</TouchableOpacity>
);
}
}
const propTypes = {
itemText: PropTypes.string,
needTitle: PropTypes.bool,
onClickFun: PropTypes.func,
showIconNext: PropTypes.bool,
topLine: PropTypes.bool,
bottomLine: PropTypes.bool,
itemIcon: PropTypes.string,
itemIconColor: PropTypes.string,
itemIconSize: PropTypes.number,
textStyle: PropTypes.any,
viewStyle: PropTypes.array,
};
CodeFileItem.propTypes = propTypes;
CodeFileItem.defaultProps = {
showIconNext: true,
topLine: true,
bottomLine: true,
needTitle: true,
textStyle: styles.smallText,
itemIconColor: Constant.primaryColor,
itemIconSize: Constant.smallIconSize,
viewStyle: [],
};
export default CodeFileItem;