6
6
Image ,
7
7
TouchableOpacity ,
8
8
Dimensions ,
9
+ StyleSheet ,
9
10
} from 'react-native' ;
10
11
11
12
const { width, height} = Dimensions . get ( 'window' ) ;
@@ -20,28 +21,37 @@ export default class MessageCell extends React.PureComponent {
20
21
const { name, full_name} = this . props . item . item || { } ;
21
22
console . log ( `===>message cell props, ${ name } , ${ full_name } ` , this . props . item . item )
22
23
return (
23
- < View style = { { alignItems : 'stretch' , justifyContent : 'center' , backgroundColor : 'white' , paddingHorizontal : 10 , paddingTop : 10 , } } >
24
+ < View style = { styles . container } >
24
25
< TouchableOpacity
25
26
onPress = { ( ) => console . log ( 'item clicked' ) }
26
- style = { {
27
- backgroundColor : 'yellow' , alignItems : 'stretch' , justifyContent : 'center' ,
28
- height : 250 ,
29
- } } >
30
- < View style = { {
31
- flex : 1 , justifyContent : 'flex-start' , alignItems : 'center' ,
32
- backgroundColor : 'orange' , borderRadius : 10 , overflow : 'hidden'
33
- } } >
27
+ style = { styles . touchable } >
28
+ < View style = { styles . touchableInside } >
34
29
< Image
35
30
source = { require ( './img/graphql_wx.jpg' ) }
36
- style = { { borderTopLeftRadius : 10 , borderTopRightRadius : 10 , backgroundColor : 'red' , width : SCREEN_WIDTH - 20 , height : 150 } }
31
+ style = { styles . image }
37
32
resizeMode = { Image . resizeMode . stretch } />
38
- < View style = { { flex : 1 , justifyContent : 'space-around' , alignSelf : 'stretch' , alignItems : 'flex-start' , paddingVertical : 20 , marginHorizontal : 20 } } >
39
- < Text style = { { textAlign : 'left' , backgroundColor : 'yellow' } } > { name } </ Text >
40
- < Text style = { { textAlign : 'left' , backgroundColor : 'yellow' } } > { full_name } </ Text >
33
+ < View style = { styles . insideView } >
34
+ < Text style = { styles . insideText } > { name } </ Text >
35
+ < Text style = { styles . insideText } > { full_name } </ Text >
41
36
</ View >
42
37
</ View >
43
38
</ TouchableOpacity >
44
39
</ View >
45
40
) ;
46
41
}
47
- }
42
+ }
43
+
44
+ const styles = StyleSheet . create ( {
45
+ container : { alignItems : 'stretch' , justifyContent : 'center' , backgroundColor : 'white' , paddingHorizontal : 10 , paddingTop : 10 , } ,
46
+ touchable : {
47
+ backgroundColor : 'yellow' , alignItems : 'stretch' , justifyContent : 'center' ,
48
+ height : 250 ,
49
+ } ,
50
+ touchableInside : {
51
+ flex : 1 , justifyContent : 'flex-start' , alignItems : 'center' ,
52
+ backgroundColor : 'orange' , borderRadius : 10 , overflow : 'hidden'
53
+ } ,
54
+ image : { borderTopLeftRadius : 10 , borderTopRightRadius : 10 , backgroundColor : 'red' , width : SCREEN_WIDTH - 20 , height : 150 } ,
55
+ insideView : { flex : 1 , justifyContent : 'space-around' , alignSelf : 'stretch' , alignItems : 'flex-start' , paddingVertical : 20 , marginHorizontal : 20 } ,
56
+ insideText : { textAlign : 'left' , backgroundColor : 'yellow' } ,
57
+ } ) ;
0 commit comments