Header.js
3.24 KB
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
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import Immutable, {Map} from 'immutable';
const {
AppRegistry,
StyleSheet,
Text,
View,
Image,
ListView,
Dimensions,
TouchableOpacity,
} = ReactNative;
export default class Header extends React.Component {
constructor(props) {
super(props);
}
shouldComponentUpdate(nextProps){
if (Immutable.is(nextProps.resource, this.props.resource)) {
return false;
} else {
return true;
}
}
render() {
let {resource} = this.props;
let {author,article} = resource;
let author_data = author.get('data');
let article_data = article.get('data');
if (!author_data || !article_data) {
return null;
}
let author_desc = author_data.get('author_desc');
let author_avatar = author_data.get('avatar');
let author_name = author_data.get('name');
let author_url = author_data.get('url');
let article_title = article_data.get('article_title');
let pageViews = article_data.get('pageViews');
let publishTime = article_data.get('publishTime');
return(
<View style={styles.contentContainer}>
<TouchableOpacity activeOpacity={0.5} onPress={() => {
// this.props.onPressBrandItem && this.props.onPressBrandItem(rowData.url, rowID);
}}>
<View style={styles.header}>
<Image source={{uri: author_avatar}} style={styles.thumb}></Image>
<Text style={styles.name}>{author_name}</Text>
<Text style={styles.desc}>{author_desc}</Text>
</View>
</TouchableOpacity>
<View style={{width: width,height: 0.5,backgroundColor: '#e5e5e5',}}/>
<Text style={styles.article_title}>{article_title}</Text>
<View style={styles.time}>
<Image source={require('../../image/time_icon.png')} style={styles.timeThumb}resizeMode={'contain'}></Image>
<Text style={styles.text}>{publishTime}</Text>
<Image source={require('../../image/shared_view_icon.png')} style={styles.timeThumb}resizeMode={'contain'}></Image>
<Text style={styles.text}>{pageViews}</Text>
</View>
<View style={{width: width,height: 10}}/>
</View>
);
}
};
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
contentContainer: {
width:width,
backgroundColor: 'white',
},
header: {
flexDirection: 'row',
height: 47.5,
width:width,
alignItems: 'center',
},
thumb: {
width: 25,
height: 25,
marginLeft: 20,
borderRadius: 12,
},
name: {
marginLeft: 20,
},
desc: {
marginLeft: 20,
color: '#e5e5e5',
},
article_title: {
marginLeft: 20,
marginRight: 10,
fontSize: 23,
fontWeight: 'bold',
lineHeight: 35,
},
time: {
flexDirection: 'row',
height: 20,
width:width,
alignItems: 'center',
marginTop: 5,
},
timeThumb: {
marginLeft: 20,
height: 12,
width:20,
},
text: {
marginLeft: 5,
fontSize: 12,
color: 'gray'
},
});