-
Notifications
You must be signed in to change notification settings - Fork 8
/
DetailView.js
128 lines (118 loc) · 2.56 KB
/
DetailView.js
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
'use strict';
var React = require('react-native');
var Util = require('./Util');
var UserInfoView = require('./UserInfo');
var Reply = require('./Reply');
var {
StyleSheet,
Text,
View,
ScrollView,
Image,
AlertIOS,
TouchableHighlight,
PixelRatio,
ListView
} = React;
var {
formatTime
} = Util;
var DetailView = React.createClass({
gotoUserInfo(member) {
this.props.navigator.push({
title: '成员',
component: UserInfoView,
passProps: {
memberId: member.id
}
});
},
render () {
var item = this.props.item;
var dateTime = formatTime(item.created);
return (
<ScrollView style={[styles.container, styles.wrapper]}>
<View style={[styles.container, styles.titleContainer]}>
<View style={styles.titleWrapper}>
<Text style={styles.title}>{ item.title }</Text>
<View style={styles.info}>
<Text style={styles.username}>{ item.member.username }</Text>
<Text style={styles.dot}>·</Text>
<Text style={styles.datetime}>{ dateTime }</Text>
</View>
</View>
<TouchableHighlight style={styles.thumbnailWrapper} onPress={ this.gotoUserInfo.bind(this, item.member) }>
<Image
source={{uri: `http:${ item.member.avatar_large }`}}
style={styles.thumbnail}
/>
</TouchableHighlight>
</View>
<View style={styles.contentWrapper}>
<Text style={styles.content}>{ item.content }</Text>
</View>
<Reply id={item.id} />
</ScrollView>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
},
wrapper: {
paddingLeft: 10,
paddingRight: 10,
},
titleContainer: {
flexDirection: 'row',
justifyContent: 'center',
marginTop: 10,
marginBottom: 10,
paddingBottom: 10,
borderBottomColor: '#e2e2e2',
borderBottomWidth: 1 / PixelRatio.get(),
},
titleWrapper: {
flex: 1,
},
title: {
fontSize: 20,
lineHeight: 26,
},
info: {
marginTop: 10,
flex: 1,
flexDirection: 'row',
},
username: {
fontSize: 12,
color: 'rgb(119, 128, 135)',
fontWeight: '700'
},
dot: {
marginLeft: 6,
marginRight: 6,
color: 'rgb(204, 204, 204)'
},
datetime: {
fontSize: 12,
color: '#999'
},
thumbnailWrapper: {
width: 60,
height: 60,
marginLeft: 10
},
thumbnail: {
width: 60,
height: 60
},
contentWrapper: {
marginBottom: 20
},
content: {
lineHeight: 22,
}
});
module.exports = DetailView;