3
3
4
4
import React , { Component } from 'react' ;
5
5
import { connect } from 'react-redux' ;
6
- import { StyleSheet , View , Text , TouchableOpacity , Image } from 'react-native ' ;
6
+ import styled from 'styled-components ' ;
7
7
import { GithubHtmlView } from 'components' ;
8
8
import { Icon } from 'react-native-elements' ;
9
9
import ActionSheet from 'react-native-actionsheet' ;
10
10
11
11
import { translate , relativeTimeToNow } from 'utils' ;
12
12
import { colors , fonts , normalize } from 'config' ;
13
13
14
- const styles = StyleSheet . create ( {
15
- container : {
16
- paddingRight : 10 ,
17
- paddingTop : 10 ,
18
- backgroundColor : 'transparent' ,
19
- } ,
20
- header : {
21
- flexDirection : 'row' ,
22
- marginLeft : 10 ,
23
- alignItems : 'center' ,
24
- } ,
25
- avatarContainer : {
26
- backgroundColor : colors . greyLight ,
27
- borderRadius : 17 ,
28
- width : 34 ,
29
- height : 34 ,
30
- } ,
31
- avatar : {
32
- width : 34 ,
33
- height : 34 ,
34
- borderRadius : 17 ,
35
- } ,
36
- titleSubtitleContainer : {
37
- justifyContent : 'center' ,
38
- flex : 1 ,
39
- marginLeft : 10 ,
40
- } ,
41
- dateContainer : {
42
- flex : 0.15 ,
43
- alignItems : 'flex-end' ,
44
- justifyContent : 'center' ,
45
- } ,
46
- linkDescription : {
47
- ... fonts . fontPrimaryBold ,
48
- fontSize : normalize ( 13 ) ,
49
- color : colors . primaryDark ,
50
- } ,
51
- date : {
52
- color : colors . greyDark ,
53
- } ,
54
- commentContainer : {
55
- paddingTop : 5 ,
56
- marginLeft : 54 ,
57
- borderBottomColor : colors . greyLight ,
58
- borderBottomWidth : 1 ,
59
- } ,
60
- commentBottomPadding : {
61
- paddingBottom : 15 ,
62
- } ,
63
- commentText : {
64
- fontSize : normalize ( 12 ) ,
65
- color : colors . primaryDark ,
66
- } ,
67
- commentTextNone : {
68
- ... fonts . fontPrimary ,
69
- color : colors . primaryDark ,
70
- fontStyle : 'italic' ,
71
- } ,
72
- actionButtonIconContainer : {
73
- paddingTop : 5 ,
74
- paddingBottom : 10 ,
75
- alignItems : 'flex-end' ,
76
- justifyContent : 'center' ,
77
- } ,
78
- } ) ;
14
+ const Container = styled . View `
15
+ padding: 10px 10px 0 0;
16
+ background-color: transparent;
17
+ ` ;
18
+
19
+ const Header = styled . View `
20
+ flex-direction: row;
21
+ margin-left: 10;
22
+ align-items: center;
23
+ ` ;
24
+
25
+ const AvatarContainer = styled . TouchableOpacity `
26
+ background-color: ${ colors . greyLight } ;
27
+ border-radius : 17;
28
+ width: 34;
29
+ height: 34;
30
+ ` ;
31
+
32
+ const Avatar = styled . Image `
33
+ border-radius: 17;
34
+ width: 34;
35
+ height: 34;
36
+ ` ;
37
+
38
+ const TitleSubtitleContainer = styled . View `
39
+ justify-content: center;
40
+ flex: 1;
41
+ margin-left: 10;
42
+ ` ;
43
+
44
+ const DateContainer = styled . View `
45
+ flex: 0.15;
46
+ align-items: flex-end;
47
+ justify-content: center;
48
+ ` ;
49
+
50
+ const LinkDescription = styled . Text `
51
+ ${ { ... fonts . fontPrimaryBold } } ;
52
+ font-size: ${ normalize ( 13 ) } ;
53
+ color: ${ colors . primaryDark } ;
54
+ ` ;
55
+
56
+ const DateLabel = styled . Text `
57
+ color: ${ colors . greyDark } ;
58
+ ` ;
59
+
60
+ const CommentContainer = styled . View `
61
+ padding-top: 5;
62
+ margin-left: 54;
63
+ border-bottom-color: ${ colors . greyLight } ;
64
+ border-bottom-width: 1;
65
+ padding-bottom: ${ props => ( props . bottomPadding ? 15 : 0 ) } ;
66
+ ` ;
67
+
68
+ const CommentTextNone = styled . Text `
69
+ ${ { ... fonts . fontPrimary } } ;
70
+ color: ${ colors . primaryDark } ;
71
+ font-style: italic;
72
+ ` ;
73
+
74
+ const ActionButtonIconContainer = styled . View `
75
+ padding: 5px 0 10px;
76
+ align-items: flex-end;
77
+ justify-content: center;
78
+ ` ;
79
79
80
80
const mapStateToProps = state => ( {
81
81
authUser : state . auth . user ,
@@ -131,11 +131,10 @@ class CommentListItemComponent extends Component {
131
131
comment . user && authUser . login === comment . user . login ;
132
132
133
133
return (
134
- < View style = { styles . container } >
135
- < View style = { styles . header } >
134
+ < Container >
135
+ < Header >
136
136
{ comment . user && (
137
- < TouchableOpacity
138
- style = { styles . avatarContainer }
137
+ < AvatarContainer
139
138
onPress = { ( ) =>
140
139
navigation . navigate (
141
140
authUser . login === comment . user . login
@@ -144,21 +143,20 @@ class CommentListItemComponent extends Component {
144
143
{
145
144
user : comment . user ,
146
145
}
147
- ) }
146
+ )
147
+ }
148
148
>
149
- < Image
150
- style = { styles . avatar }
149
+ < Avatar
151
150
source = { {
152
151
uri : comment . user . avatar_url ,
153
152
} }
154
153
/>
155
- </ TouchableOpacity >
154
+ </ AvatarContainer >
156
155
) }
157
156
158
157
{ comment . user && (
159
- < View style = { styles . titleSubtitleContainer } >
160
- < Text
161
- style = { styles . linkDescription }
158
+ < TitleSubtitleContainer >
159
+ < LinkDescription
162
160
onPress = { ( ) =>
163
161
navigation . navigate (
164
162
authUser . login === comment . user . login
@@ -167,49 +165,43 @@ class CommentListItemComponent extends Component {
167
165
{
168
166
user : comment . user ,
169
167
}
170
- ) }
168
+ )
169
+ }
171
170
>
172
171
{ comment . user . login }
173
- </ Text >
174
- </ View >
172
+ </ LinkDescription >
173
+ </ TitleSubtitleContainer >
175
174
) }
176
175
177
- < View style = { styles . dateContainer } >
178
- < Text style = { styles . date } >
179
- { relativeTimeToNow ( comment . created_at ) }
180
- </ Text >
181
- </ View >
182
- </ View >
183
-
184
- < View
185
- style = { [
186
- styles . commentContainer ,
187
- ! isActionMenuEnabled && styles . commentBottomPadding ,
188
- ] }
189
- >
176
+ < DateContainer >
177
+ < DateLabel > { relativeTimeToNow ( comment . created_at ) } </ DateLabel >
178
+ </ DateContainer >
179
+ </ Header >
180
+
181
+ < CommentContainer bottomPadding = { ! isActionMenuEnabled } >
190
182
{ commentPresent ? (
191
183
< GithubHtmlView
192
184
source = { comment . body_html }
193
185
onLinkPress = { onLinkPress }
194
186
/>
195
187
) : (
196
- < Text style = { styles . commentTextNone } >
188
+ < CommentTextNone >
197
189
{ translate ( 'issue.main.noDescription' , locale ) }
198
- </ Text >
190
+ </ CommentTextNone >
199
191
) }
200
192
201
193
{ isActionMenuEnabled && (
202
- < View style = { styles . actionButtonIconContainer } >
194
+ < ActionButtonIconContainer >
203
195
< Icon
204
196
color = { colors . grey }
205
197
size = { 20 }
206
198
name = { 'ellipsis-h' }
207
199
type = { 'font-awesome' }
208
200
onPress = { this . showMenu }
209
201
/>
210
- </ View >
202
+ </ ActionButtonIconContainer >
211
203
) }
212
- </ View >
204
+ </ CommentContainer >
213
205
214
206
< ActionSheet
215
207
ref = { o => {
@@ -223,7 +215,7 @@ class CommentListItemComponent extends Component {
223
215
cancelButtonIndex = { this . commentActionSheetOptions ( comment ) . length }
224
216
onPress = { this . handlePress }
225
217
/>
226
- </ View >
218
+ </ Container >
227
219
) ;
228
220
}
229
221
}
0 commit comments