User.js
1.83 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
'use strict';
import React from 'react-native';
let {
StyleSheet,
Component,
View,
Text,
ListView,
Image,
TouchableHighlight,
} = React;
export default class User extends Component {
constructor(props) {
super(props);
this.ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
}
componentWillMount() {
this._renderRow = this._renderRow.bind(this);
}
render() {
let items = this.props.items;
return (
<ListView
dataSource={this.ds.cloneWithRows(this.props.items)}
renderRow={this._renderRow}
renderSeparator={(sectionID, rowID) => <View key={`${sectionID}-${rowID}`} style={styles.separator}/>}
style={styles.listView}/>
);
}
_renderRow(item) {
let icon = item.icon;
return (
<TouchableHighlight underlayColor={'white'} onPress={() => this.props.onItemPressed(item)}>
<View style={styles.row}>
<Image source={item.icon}/>
<Text style={styles.title}>{item.title}</Text>
<Text>{item.subtitle}</Text>
<Image source={item.arrow} />
</View>
</TouchableHighlight>
);
}
}
const styles = StyleSheet.create({
row: {
flexDirection: 'row',
height: 45,
justifyContent: 'center',
alignItems: 'center',
paddingLeft: 10,
paddingRight: 10,
backgroundColor: '#F5FCFF',
},
title: {
flex: 1,
color: '#444444',
fontSize: 14,
marginLeft: 10,
},
subtitle: {
padding: 5,
},
image: {
padding: 10,
},
listView: {
marginTop: 56,
},
separator: {
height: 1,
},
});