-
Notifications
You must be signed in to change notification settings - Fork 427
/
Copy pathIssueItem.js
143 lines (132 loc) · 5.33 KB
/
IssueItem.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/**
* Created by guoshuyu on 2017/11/11.
*/
import React, {
Component,
} from 'react'
import {
View, Text, TouchableOpacity
} from 'react-native';
import PropTypes from 'prop-types';
import styles from '../../style'
import * as Constant from '../../style/constant'
import TimeText from './TimeText'
import UserImage from './UserImage'
import Icon from 'react-native-vector-icons/FontAwesome'
import IconC from 'react-native-vector-icons/Octicons'
import HTMLView from '../common/CommonHtmlView';
/**
* Issue列表Item
*/
class IssueItem extends Component {
constructor(props) {
super(props)
}
componentDidMount() {
}
componentWillUnmount() {
}
render() {
let {actionTime, actionUser, actionUserPic, issueComment, markdownBody, issueCommentHtml} = this.props;
let bottom = (this.props.issueTag) ? <View style={[styles.flexDirectionRowNotFlex, styles.centerH]}>
<IconC name={this.props.state === 'open' ? "issue-opened" : "issue-closed"}
backgroundColor={Constant.transparentColor}
color={this.props.state === 'open' ? "green" : "red"} size={13}>
<Text style={[styles.subLightSmallText, {color: this.props.state === 'open' ? "green" : "red"}]}>
{this.props.state + " "}
</Text>
</IconC>
<Text style={[styles.subLightSmallText, {flex: 1}]}
numberOfLines={Constant.normalNumberOfLine}>
{this.props.issueTag}
</Text>
<Icon.Button name="comment"
iconStyle={{marginRight: 3}}
backgroundColor={Constant.transparentColor}
color={Constant.subLightTextColor} size={10}>
<Text style={[styles.subLightSmallText, {fontSize: Constant.minTextSize}]}>
{this.props.commentCount}
</Text>
</Icon.Button>
</View> : <View/>;
let bottomMargin = (this.props.issueTag) ? 0 : Constant.normalMarginEdge;
let body = (markdownBody) ? <HTMLView
style={[{
marginTop: Constant.normalMarginEdge / 2,
backgroundColor: Constant.transparentColor
}]}
numberOfLines={9999}
value={issueCommentHtml}
textComponentProps={{
style: styles.subSmallText,
numberOfLines: 9999,
}}
selectable={true}
stylesheet={{pre: styles.inCode, code: styles.pCode}}
textComponent={() => {
return (
<Text/>
)
}}
/> : <Text selectable={true} style={[styles.subSmallText,]}>{issueComment}</Text>;
return (
<TouchableOpacity
style={[{
marginVertical: Constant.normalMarginEdge / 2,
marginLeft: Constant.normalMarginEdge,
marginRight: Constant.normalMarginEdge,
paddingHorizontal: Constant.normalMarginEdge,
paddingTop: Constant.normalMarginEdge,
borderRadius: 3,
}, styles.shadowCard]}
onPress={() => {
this.props.onPressItem && this.props.onPressItem();
}}
onLongPress={() => {
this.props.onLongPressItem && this.props.onLongPressItem();
}}>
<View style={[styles.flexDirectionRowNotFlex,]}>
<UserImage uri={actionUserPic}
loginUser={actionUser}
resizeMethod="scale"
style={[{
height: Constant.normalIconSize, width: Constant.normalIconSize,
marginTop: 5,
borderRadius: Constant.normalIconSize / 2
}]}/>
<View style={{
flex: 1,
marginLeft: Constant.normalMarginEdge,
marginBottom: bottomMargin
}}>
<View style={[styles.flexDirectionRowNotFlex, styles.centerH]}>
<Text selectable={true} style={[styles.flex, styles.normalText, {fontWeight: "bold",}]}>
{actionUser}
</Text>
<TimeText style={[styles.subSmallText, {marginTop: -3}]}
time={actionTime}/>
</View>
<View
style={[styles.flexDirectionRowNotFlex, {marginTop: Constant.normalMarginEdge / 2}]}>
{body}
</View>
{bottom}
</View>
</View>
</TouchableOpacity>
)
}
}
const propTypes = {
actionTime: PropTypes.string,
actionUser: PropTypes.string,
actionUserPic: PropTypes.string,
issueComment: PropTypes.string,
issueTag: PropTypes.string,
onPressItem: PropTypes.func,
onLongPressItem: PropTypes.func,
commentCount: PropTypes.string,
markdownBody: PropTypes.bool,
};
IssueItem.propTypes = propTypes;
export default IssueItem