-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitemDetail.js
87 lines (80 loc) · 2.05 KB
/
itemDetail.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
/**
* Created by zhanjiyuan on 15/11/7.
*/
'use strict';
var React = require('react-native');
var {
StyleSheet,
Text,
TouchableHighlight,
View,
} = React;
var ItemDetail = React.createClass({
render: function() {
var type = this.props.data.item_type;
if (type == 'member') return null;
var header = ((type=='assignment')?('Assignments'):((type=='material')?('Materials'):('Notifications')));
var color = ((type=='assignment')?('#FF3B30'):((type=='material')?('#FFCC00'):('#007AFF')));
var title = type=='assignment'?this.props.data.name_with_namespace:
type=='material'?this.props.data.name:this.props.data.title;
var content = type=='assignment'?this.props.data.description:
type=='material'?this.props.data.type:this.props.data.description;
return (
<TouchableHighlight
onPress={this.props.onSelect}>
<View style={styles.container}>
<View style={styles.top}>
<View style={[styles.circle, {backgroundColor: color}]}></View>
<Text style={styles.header}>{header}</Text>
</View>
<Text style={styles.title} numberOfLines = {1}>{title}</Text>
<Text style={styles.content} numberOfLines = {1}>{content}</Text>
<View style={styles.separator}/>
</View>
</TouchableHighlight>
);
}
});
var styles = StyleSheet.create({
container: {
paddingTop: 10,
paddingLeft: 10,
paddingRight: 10,
backgroundColor: 'white',
},
header: {
fontSize: 15,
fontWeight: 'bold',
},
circle: {
height: 15,
width: 15,
borderRadius: 7.5,
margin: 7.5,
},
top: {
flexDirection: 'row',
height: 30,
alignItems: 'center',
},
title: {
paddingLeft: 30,
paddingRight: 7.5,
fontSize: 14,
lineHeight: 20,
paddingBottom: 2.5,
},
content: {
fontSize: 12,
paddingLeft: 30,
paddingRight: 7.5,
paddingTop: 2.5,
},
separator: {
backgroundColor: 'rgba(0, 0, 0, 0.1)',
height: 1,
marginLeft: 4,
marginTop: 20,
}
});
module.exports = ItemDetail;