1
1
import React , { Component } from 'react' ;
2
- import { StyleSheet , View , ActivityIndicator } from 'react-native' ;
2
+ import { StyleSheet , ActivityIndicator } from 'react-native' ;
3
3
import { ListItem } from 'react-native-elements' ;
4
4
import Parse from 'parse-diff' ;
5
5
import moment from 'moment/min/moment-with-locales.min' ;
6
+ import styled from 'styled-components/native' ;
6
7
7
8
import {
8
9
StateBadge ,
@@ -12,63 +13,70 @@ import {
12
13
Button ,
13
14
} from 'components' ;
14
15
import { translate } from 'utils' ;
15
- import { colors , fonts , normalize } from 'config' ;
16
+ import { colors , styledFonts , normalize } from 'config' ;
16
17
import { v3 } from 'api' ;
17
18
18
19
const styles = StyleSheet . create ( {
19
- headerContainer : {
20
- flexDirection : 'row' ,
21
- alignItems : 'center' ,
22
- justifyContent : 'center' ,
23
- paddingRight : 10 ,
24
- } ,
25
- borderBottom : {
26
- borderBottomWidth : 1 ,
27
- borderBottomColor : colors . greyLight ,
28
- } ,
29
- title : {
30
- color : colors . primaryDark ,
31
- ...fonts . fontPrimarySemiBold ,
32
- } ,
33
- titleSmall : {
34
- color : colors . primaryDark ,
35
- ...fonts . fontPrimarySemiBold ,
36
- fontSize : normalize ( 10 ) ,
37
- } ,
38
- listItemContainer : {
39
- borderBottomWidth : 0 ,
40
- flex : 1 ,
41
- } ,
42
- diffBlocksContainer : {
43
- flexDirection : 'row' ,
44
- alignItems : 'center' ,
45
- justifyContent : 'flex-end' ,
46
- paddingRight : 10 ,
47
- paddingBottom : 10 ,
48
- } ,
49
20
badge : {
50
21
alignItems : 'flex-end' ,
51
22
justifyContent : 'center' ,
52
23
} ,
53
- labelButtonGroup : {
54
- flexWrap : 'wrap' ,
55
- flexDirection : 'row' ,
56
- marginLeft : 54 ,
57
- paddingBottom : 15 ,
58
- } ,
59
- assigneesSection : {
60
- marginLeft : 54 ,
61
- paddingBottom : 5 ,
62
- } ,
63
- mergeButtonContainer : {
64
- flex : 1 ,
65
- flexDirection : 'row' ,
66
- justifyContent : 'center' ,
67
- alignItems : 'center' ,
68
- paddingVertical : 15 ,
69
- } ,
70
24
} ) ;
71
25
26
+ const HeaderContainer = styled . View `
27
+ flex-direction: row;
28
+ align-items: center;
29
+ justify-content: center;
30
+ padding-right: 10;
31
+ ` ;
32
+
33
+ const ContainerBorderBottom = styled . View `
34
+ border-bottom-width: 1;
35
+ border-bottom-color: ${ colors . greyLight } ;
36
+ ` ;
37
+
38
+ const ListItemStyled = styled ( ListItem ) `
39
+ color: ${ colors . primaryDark }
40
+ font-family: ${ styledFonts . fontPrimarySemiBold }
41
+ ` ;
42
+
43
+ const ListItemURL = ListItemStyled . extend `
44
+ font-size: ${ normalize ( 10 ) } ;
45
+ ` ;
46
+
47
+ const ListItemIssueTitle = ListItemStyled . extend `
48
+ border-bottom-width: 0;
49
+ flex: 1;
50
+ ` ;
51
+
52
+ const DiffBlocksContainer = styled . View `
53
+ flex-direction: row;
54
+ align-items: center;
55
+ justify-content: flex-end;
56
+ padding-right: 10;
57
+ padding-bottom: 10;
58
+ ` ;
59
+
60
+ const LabelButtonGroup = styled . View `
61
+ flex-wrap: wrap;
62
+ flex-direction: row;
63
+ margin-left: 54;
64
+ padding-bottom: 15;
65
+ ` ;
66
+
67
+ const AssigneesSection = styled . View `
68
+ margin-left: 54;
69
+ padding-bottom: 5;
70
+ ` ;
71
+
72
+ const MergeButtonContainer = styled . View `
73
+ flex: 1;
74
+ flex-direction: row;
75
+ justify-content: center;
76
+ align-items: center;
77
+ padding-vertical: 15;
78
+ ` ;
79
+
72
80
export class IssueDescription extends Component {
73
81
props : {
74
82
issue : Object ,
@@ -114,11 +122,10 @@ export class IssueDescription extends Component {
114
122
} ) ;
115
123
116
124
return (
117
- < View style = { ( styles . container , styles . borderBottom ) } >
118
- { issue . repository_url &&
119
- < ListItem
125
+ < ContainerBorderBottom >
126
+ { issue . repository_url && (
127
+ < ListItemURL
120
128
title = { issue . repository_url . replace ( `${ v3 . root } /repos/` , '' ) }
121
- titleStyle = { styles . titleSmall }
122
129
leftIcon = { {
123
130
name : 'repo' ,
124
131
size : 17 ,
@@ -127,14 +134,13 @@ export class IssueDescription extends Component {
127
134
} }
128
135
onPress = { ( ) => onRepositoryPress ( issue . repository_url ) }
129
136
hideChevron
130
- /> }
137
+ />
138
+ ) }
131
139
132
- < View style = { styles . headerContainer } >
133
- < ListItem
140
+ < HeaderContainer >
141
+ < ListItemIssueTitle
134
142
title = { issue . title }
135
- titleStyle = { styles . title }
136
143
subtitle = { moment ( issue . created_at ) . fromNow ( ) }
137
- containerStyle = { styles . listItemContainer }
138
144
leftIcon = { {
139
145
name : issue . pull_request ? 'git-pull-request' : 'issue-opened' ,
140
146
size : 36 ,
@@ -146,69 +152,76 @@ export class IssueDescription extends Component {
146
152
147
153
{ ! issue . pull_request ||
148
154
( issue . pull_request &&
149
- ! isPendingCheckMerge &&
150
- < StateBadge
151
- style = { styles . badge }
152
- issue = { issue }
153
- isMerged = { isMerged && issue . pull_request }
154
- locale = { locale }
155
- /> ) }
156
- </ View >
155
+ ! isPendingCheckMerge && (
156
+ < StateBadge
157
+ style = { styles . badge }
158
+ issue = { issue }
159
+ isMerged = { isMerged && issue . pull_request }
160
+ locale = { locale }
161
+ />
162
+ ) ) }
163
+ </ HeaderContainer >
157
164
158
- { issue . pull_request &&
159
- < View style = { styles . diffBlocksContainer } >
160
- { isPendingDiff &&
161
- < ActivityIndicator animating = { isPendingDiff } size = "small" /> }
165
+ { issue . pull_request && (
166
+ < DiffBlocksContainer >
167
+ { isPendingDiff && (
168
+ < ActivityIndicator animating = { isPendingDiff } size = "small" />
169
+ ) }
162
170
163
171
{ ! isPendingDiff &&
164
- ( lineAdditions !== 0 || lineDeletions !== 0 ) &&
165
- < DiffBlocks
166
- additions = { lineAdditions }
167
- deletions = { lineDeletions }
168
- showNumbers
169
- onPress = { ( ) =>
170
- navigation . navigate ( 'PullDiff' , {
171
- title : translate ( 'repository.pullDiff.title' , locale ) ,
172
- locale,
173
- diff,
174
- } ) }
175
- /> }
176
- </ View > }
172
+ ( lineAdditions !== 0 || lineDeletions !== 0 ) && (
173
+ < DiffBlocks
174
+ additions = { lineAdditions }
175
+ deletions = { lineDeletions }
176
+ showNumbers
177
+ onPress = { ( ) =>
178
+ navigation . navigate ( 'PullDiff' , {
179
+ title : translate ( 'repository.pullDiff.title' , locale ) ,
180
+ locale,
181
+ diff,
182
+ } ) }
183
+ />
184
+ ) }
185
+ </ DiffBlocksContainer >
186
+ ) }
177
187
178
188
{ issue . labels &&
179
- issue . labels . length > 0 &&
180
- < View style = { styles . labelButtonGroup } >
181
- { this . renderLabelButtons ( issue . labels ) }
182
- </ View > }
189
+ issue . labels . length > 0 && (
190
+ < LabelButtonGroup >
191
+ { this . renderLabelButtons ( issue . labels ) }
192
+ </ LabelButtonGroup >
193
+ ) }
183
194
{ issue . assignees &&
184
- issue . assignees . length > 0 &&
185
- < View style = { styles . assigneesSection } >
186
- < MembersList
187
- title = { translate ( 'issue.main.assignees' , locale ) }
188
- members = { issue . assignees }
189
- containerStyle = { { marginTop : 0 , paddingTop : 0 , paddingLeft : 0 } }
190
- smallTitle
191
- navigation = { navigation }
192
- />
193
- </ View > }
195
+ issue . assignees . length > 0 && (
196
+ < AssigneesSection >
197
+ < MembersList
198
+ title = { translate ( 'issue.main.assignees' , locale ) }
199
+ members = { issue . assignees }
200
+ containerStyle = { { marginTop : 0 , paddingTop : 0 , paddingLeft : 0 } }
201
+ smallTitle
202
+ navigation = { navigation }
203
+ />
204
+ </ AssigneesSection >
205
+ ) }
194
206
195
207
{ issue . pull_request &&
196
208
! isMerged &&
197
209
issue . state === 'open' &&
198
- userHasPushPermission &&
199
- < View style = { styles . mergeButtonContainer } >
200
- < Button
201
- type = { isMergeable ? 'success' : 'default' }
202
- icon = { { name : 'git-merge' , type : 'octicon' } }
203
- disabled = { ! isMergeable }
204
- onPress = { ( ) =>
205
- navigation . navigate ( 'PullMerge' , {
206
- title : translate ( 'issue.pullMerge.title' , locale ) ,
207
- } ) }
208
- title = { translate ( 'issue.main.mergeButton' , locale ) }
209
- />
210
- </ View > }
211
- </ View >
210
+ userHasPushPermission && (
211
+ < MergeButtonContainer >
212
+ < Button
213
+ type = { isMergeable ? 'success' : 'default' }
214
+ icon = { { name : 'git-merge' , type : 'octicon' } }
215
+ disabled = { ! isMergeable }
216
+ onPress = { ( ) =>
217
+ navigation . navigate ( 'PullMerge' , {
218
+ title : translate ( 'issue.pullMerge.title' , locale ) ,
219
+ } ) }
220
+ title = { translate ( 'issue.main.mergeButton' , locale ) }
221
+ />
222
+ </ MergeButtonContainer >
223
+ ) }
224
+ </ ContainerBorderBottom >
212
225
) ;
213
226
}
214
227
}
0 commit comments