11import React , { StyleSheet , Text , TouchableHighlight , Image , View , PropTypes } from 'react-native' ;
22
3- const propTypes = {
4- goToTweet : PropTypes . func . isRequired ,
5- text : PropTypes . string ,
6- user : PropTypes . object ,
7- } ;
8-
93class Tweet extends React . Component {
104 constructor ( props ) {
115 super ( props ) ;
12- this . styles = StyleSheet . create ( {
13- tweetContainer : {
14- flexDirection : 'row' ,
15- alignItems : 'center' ,
16- backgroundColor : 'white' ,
17- borderBottomWidth : 1 ,
18- borderColor : '#DAE6F0' ,
19- paddingTop : 4 ,
20- paddingBottom : 10 ,
21- } ,
22- avatar : {
23- backgroundColor : 'gray' ,
24- width : 50 ,
25- height : 50 ,
26- marginLeft : 10 ,
27- borderRadius : 4 ,
28- } ,
29- userContainer : {
30- flexDirection : 'row' ,
31- } ,
32- username : {
33- marginLeft : 4 ,
34- fontSize : 13 ,
35- color : '#8999a5' ,
36- marginTop : 2 ,
37- } ,
38- name : {
39- fontWeight : '600' ,
40- fontSize : 15 ,
41- } ,
42- text : {
43- marginTop : 5 ,
44- } ,
45- rightContainer : {
46- flex : 1 ,
47- padding : 10 ,
48- } ,
49- } ) ;
506 this . goToTweet = this . goToTweet . bind ( this ) ;
517 }
528
@@ -62,21 +18,67 @@ class Tweet extends React.Component {
6218
6319 return (
6420 < TouchableHighlight underlayColor = "transparent" onPress = { this . goToTweet } >
65- < View style = { this . styles . tweetContainer } >
66- < Image source = { { uri : user . avatar } } style = { this . styles . avatar } />
67- < View style = { this . styles . rightContainer } >
68- < View style = { this . styles . userContainer } >
69- < Text style = { this . styles . name } > { user . name } </ Text >
70- < Text style = { this . styles . username } > @{ user . username } </ Text >
21+ < View style = { styles . tweetContainer } >
22+ < Image source = { { uri : user . avatar } } style = { styles . avatar } />
23+ < View style = { styles . rightContainer } >
24+ < View style = { styles . userContainer } >
25+ < Text style = { styles . name } > { user . name } </ Text >
26+ < Text style = { styles . username } > @{ user . username } </ Text >
7127 </ View >
72- < Text style = { this . styles . text } > { text } </ Text >
28+ < Text style = { styles . text } > { text } </ Text >
7329 </ View >
7430 </ View >
7531 </ TouchableHighlight >
7632 ) ;
7733 }
7834}
7935
36+ const propTypes = {
37+ goToTweet : PropTypes . func . isRequired ,
38+ text : PropTypes . string ,
39+ user : PropTypes . object ,
40+ } ;
41+
42+ const styles = StyleSheet . create ( {
43+ tweetContainer : {
44+ flexDirection : 'row' ,
45+ alignItems : 'center' ,
46+ backgroundColor : 'white' ,
47+ borderBottomWidth : 1 ,
48+ borderColor : '#DAE6F0' ,
49+ paddingTop : 4 ,
50+ paddingBottom : 10 ,
51+ } ,
52+ avatar : {
53+ backgroundColor : 'gray' ,
54+ width : 50 ,
55+ height : 50 ,
56+ marginLeft : 10 ,
57+ borderRadius : 4 ,
58+ } ,
59+ userContainer : {
60+ flexDirection : 'row' ,
61+ } ,
62+ username : {
63+ marginLeft : 4 ,
64+ fontSize : 13 ,
65+ color : '#8999a5' ,
66+ marginTop : 2 ,
67+ } ,
68+ name : {
69+ fontWeight : '600' ,
70+ fontSize : 15 ,
71+ } ,
72+ text : {
73+ marginTop : 5 ,
74+ } ,
75+ rightContainer : {
76+ flex : 1 ,
77+ padding : 10 ,
78+ } ,
79+ } ) ;
80+
8081Tweet . propTypes = propTypes ;
8182
83+
8284export default Tweet ;
0 commit comments