-
Notifications
You must be signed in to change notification settings - Fork 427
/
Copy pathIssueHead.js
151 lines (141 loc) · 6.3 KB
/
IssueHead.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
144
145
146
147
148
149
150
151
/**
* Created by guoshuyu on 2017/11/11.
*/
import React, {
Component,
} from 'react'
import {
View, Text
} 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详情Header
*/
class IssueItem extends Component {
constructor(props) {
super(props)
}
componentDidMount() {
}
componentWillUnmount() {
}
render() {
let {actionTime, actionUser, actionUserPic, issueComment, issueDes, issueDesHtml, closed_by} = this.props;
let stateText = (closed_by) ?
<View>
<Text selectable={true}
style={[styles.subSmallText, {marginVertical: 5,}]}>{"Closed by " + closed_by.login}</Text>
</View> : <View/>;
if (issueDesHtml && issueDesHtml.indexOf("<br>") >= 0) {
issueDesHtml = issueDesHtml.replace(/<br>/g, '\n');
}
return (
<View
style={[{
marginTop: Constant.normalMarginEdge,
marginLeft: Constant.normalMarginEdge,
marginRight: Constant.normalMarginEdge,
paddingHorizontal: Constant.normalMarginEdge,
paddingTop: Constant.normalMarginEdge,
borderRadius: 3,
}, styles.shadowCard, {backgroundColor: Constant.primaryColor}]}
onPress={() => {
this.props.onPressItem && this.props.onPressItem();
}}>
<View style={[styles.flexDirectionRowNotFlex,]}>
<UserImage uri={actionUserPic}
loginUser={actionUser}
resizeMethod="scale"
style={[{
height: Constant.bigIconSize, width: Constant.bigIconSize,
marginTop: 5,
borderRadius: Constant.bigIconSize / 2
}]}/>
<View style={{flex: 1, marginLeft: Constant.normalMarginEdge}}>
<View style={[styles.flexDirectionRowNotFlex, styles.centerH]}>
<Text style={[styles.flex, styles.normalTextWhite, {fontWeight: "bold",}]}
selectable={true}>
{actionUser}
</Text>
<TimeText style={[styles.miLightSmallText, {marginTop: -3}]}
time={actionTime}/>
</View>
<View
style={[styles.flexDirectionRowNotFlex, styles.centerH, {marginVertical: Constant.normalMarginEdge / 2}]}>
<Text style={[styles.miLightSmallText, {marginRight: Constant.normalMarginEdge / 2}]}
numberOfLines={Constant.normalNumberOfLine}>
{this.props.issueTag}
</Text>
<IconC name={this.props.state === 'open' ? "issue-opened" : "issue-closed"}
backgroundColor={Constant.transparentColor}
color={this.props.state === 'open' ? "green" : "red"} size={13}
style={styles.centerH}>
<Text
style={[styles.miLightSmallText, {color: this.props.state === 'open' ? "green" : "red"}]}>
{" " + this.props.state + " "}
</Text>
</IconC>
<Icon name="comment"
iconStyle={{marginRight: 3}}
backgroundColor={Constant.transparentColor}
color={Constant.miWhite} size={11}
style={styles.centerH}>
<Text style={[styles.miLightSmallText, {fontSize: Constant.minTextSize}]}>
{" " + this.props.commentCount}
</Text>
</Icon>
</View>
<View
selectable={true}
style={[styles.flexDirectionRowNotFlex, {
marginBottom: Constant.normalMarginEdge
}]}>
<Text style={[styles.miLightSmallText,]} selectable={true}>{issueComment}</Text>
</View>
</View>
</View>
<View style={[styles.centerV, {marginBottom: issueDes ? Constant.normalMarginEdge : 0}]}>
<HTMLView
style={[{
marginTop: Constant.normalMarginEdge / 2,
backgroundColor: Constant.transparentColor
}]}
selectable={true}
numberOfLines={9999}
value={issueDesHtml ? issueDesHtml : ""}
stylesheet={{pre: styles.inCode, code: styles.pCode}}
textComponentProps={{
style: styles.miLightSmallText,
numberOfLines: 9999,
}}
textComponent={() => {
return (
<Text/>
)
}}
/>
{stateText}
</View>
</View>
)
}
}
const propTypes = {
actionTime: PropTypes.string,
actionUser: PropTypes.string,
issueDes: PropTypes.string,
actionUserPic: PropTypes.string,
issueComment: PropTypes.string,
issueTag: PropTypes.string,
onPressItem: PropTypes.func,
commentCount: PropTypes.string,
};
IssueItem.propTypes = propTypes;
export default IssueItem