Message.js
3.35 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
'use strict';
import React from 'react-native';
let {
Component,
View,
Text,
ListView,
TouchableHighlight,
Dimensions,
StyleSheet,
Platform,
TouchableOpacity
} = React;
export default class Meassage extends Component {
static propTypes = {
items: React.PropTypes.arrayOf(
React.PropTypes.shape({
type:React.PropTypes.string,
title: React.PropTypes.string,
time: React.PropTypes.string,
content: React.PropTypes.string,
})
),
onPressItem: React.PropTypes.func,
};
constructor(props) {
super(props);
this.renderItem = this.renderItem.bind(this);
this.ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
}
renderName(item) {
if (item.type!=='1') {
return (
<Text style={{color:'#B0B0B0',fontSize: 10,marginLeft:8, }}>尊敬的用户:</Text>
);
} else {
return null;
}
}
renderItem(item, sectionID, rowID) {
return (
<TouchableOpacity activeOpacity={0.5} onPress={() => this.props.onPressItem(rowID)}>
<View style={styles.row}>
<View style={styles.row_top}>
<Text style={styles.title}>{item.title}</Text>
<Text style={styles.time}>{item.time}</Text>
</View>
<View style={styles.line}/>
{this.renderName(item)}
<Text style={styles.subtitle} numberOfLines={1}>{item.content}</Text>
<Text style={styles.text_detail}>查看详情</Text>
</View>
</TouchableOpacity>
);
}
render() {
return (
<View style={styles.listContainer}>
<ListView style={styles.list}
dataSource={this.ds.cloneWithRows(this.props.items)}
renderRow={this.renderItem}
renderSeparator={(sectionID, rowID) => <View key={`${sectionID}-${rowID}`} style={styles.separator}/>}
/>
</View>
);
}
nextPage(){
}
}
let {height, width} = Dimensions.get('window');
const styles = StyleSheet.create({
listContainer:{
flex: 1,
alignItems: 'center',
},
list:{
flex: 1,
},
row: {
flexDirection: 'column',
height: 100,
width: width,
backgroundColor: '#F5FCFF',
},
row_top: {
flexDirection: 'row',
height: 40,
width: width,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
title: {
flex: 1,
color: '#444444',
fontSize: 14,
marginLeft: 10,
},
time: {
width: 60,
color: '#B0B0B0',
fontSize: 10,
},
subtitle: {
fontSize: 10,
marginLeft:8,
color: '#B0B0B0',
},
text_detail: {
fontSize: 10,
alignSelf: 'flex-end',
marginRight:10,
color: '#B0B0B0',
},
listView: {
marginTop: 120,
},
line: {
height: 1,
backgroundColor: '#B0B0B0',
marginLeft:8,
marginBottom:8,
},
separator: {
height: 8,
},
});