SectionHeader.js
2.51 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
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
const {
View,
Text,
Image,
TouchableOpacity,
StyleSheet,
Dimensions,
ImageBackground
} = ReactNative;
let {width, height} = Dimensions.get('window');
let thumbHeight = Math.ceil(276 / 750 * width);
export default class SectionHeader extends React.Component {
static propTypes = {
data: ImmutablePropTypes.contains({
uri: PropTypes.string.isRequired,
title: PropTypes.string,
desc: PropTypes.string.isRequired,
post: PropTypes.string.isRequired,
comment: PropTypes.string.isRequired,
like: PropTypes.string.isRequired,
}),
};
constructor(props) {
super (props);
}
render() {
let {uri, desc, post, comment, like} = this.props.data.toJS();
return (
<ImageBackground style={[styles.container, this.props.style]} source={{uri}} resizeMode={'cover'}>
<Text style={styles.desc}>{desc}</Text>
<View style={styles.stats}>
<Text style={[styles.content, {flex: 0.3}]} numberOfLines={1}>{'帖子' + post}</Text>
<Text style={styles.content}>|</Text>
<Text style={[styles.content, {flex: 0.3}]} numberOfLines={1}>{'回复' + comment}</Text>
<Text style={styles.content}>|</Text>
<Text style={[styles.content, {flex: 0.3}]} numberOfLines={1}>{'赞' + like}</Text>
</View>
</ImageBackground>
);
}
}
let styles = StyleSheet.create({
container: {
flexDirection: 'column',
// alignItems: 'center',
backgroundColor: '#b0b0b0',
width: width,
height: thumbHeight,
},
desc: {
color: 'white',
// fontFamily: 'SourceHanSansCN Normal',
fontSize: 24,
marginTop: 42,
textAlign: 'center',
backgroundColor: 'transparent',
},
stats: {
flex: 1,
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginTop: 18,
marginBottom: 44,
},
content: {
color: 'white',
// fontFamily: 'SourceHanSansCN Normal',
fontSize: 12,
textAlign: 'center',
backgroundColor: 'transparent',
},
line: {
color: 'white',
fontSize: 10,
},
});