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