SPHeaderCell.js
2.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
import React, {Component} from 'react';
import {
View,
Text,
Image,
StyleSheet,
} from 'react-native'
export default class SPHeaderCell extends Component {
constructor(props) {
super(props);
}
renderName() {
if (this.props.data.owner) {
return(
<Text style={styles.nameLabel}>
{this.props.data.name + ' | '}
<Text style={styles.ownerColor}>楼主</Text>
</Text>
);
} else {
return(
<Text style={styles.nameLabel}>this.props.data.name</Text>
);
}
}
renderDelete() {
if (this.props.data.owner) {
return(
<Text style={[styles.nameLabel, styles.ownerColor, styles.deletePosition]}>
删除本帖
</Text>
);
}
}
render() {
return(
<View style={styles.container}>
<Image
style={styles.avatar}
source={{uri:this.props.data.avatar}}
/>
<Text style={styles.timeLabel}>{this.props.data.time}</Text>
{this.renderName()}
{this.renderDelete()}
<Text style={styles.fromLabel}>{this.props.data.templete}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flexDirection: 'row',
},
avatar: {
top: 15,
left: 15,
width: 30,
height: 30,
borderRadius: 15,
backgroundColor: 'grey',
},
//来自哪个模块
fromLabel: {
top:15,
right:15,
height: 20,
backgroundColor: '#aaaaaa',
fontSize: 15,
textAlign: 'center'
},
nameLabel: {
top: 15,
marginLeft: 15,
height: 20,
fontSize: 12,
color: 'black',
backgroundColor: 'red',
textAlign: 'left',
bottom: 10,
},
ownerColor: {
color: '#4a90e2',
},
deletePosition: {
left: 0,
top: 60,
},
timeLabel: {
top: 32,
height: 12,
left: 15,
fontSize: 10,
color: '#999999',
},
});