-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.ios.js
98 lines (93 loc) · 2.47 KB
/
index.ios.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
/**
* Sample React Native App
* https://github.com./facebook/react-native
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
Image,
ListView,
StyleSheet,
Text,
View,
} = React;
var Listitem = require('react-native-listitem')
var listitemExample = React.createClass({
getInitialState: function() {
return {
dataSource: new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2
})
}
}
, componentWillMount: function() {
this.updateDataSource([
{
text: "Simple listitem",
}, {
text: "With onPress",
onPress: function() {alert('listitem onPress fired')},
}, {
text: "With props style, styleText, indent, backgroundColor",
backgroundColor: '#0777fe',
indent: 0,
style: [styles.customLi],
styleText: [styles.customLiText]
}, {
children: <View>
<Image style={{height: 20, width: 20}} source={{uri: 'http://facebook.github.io/react/img/logo_og.png'}} />
<Text style={[{color: '#999', fontSize: 18, fontWeight: '600', paddingBottom: 4}]}>Custom component</Text>
<Text style={[{color: '#666', fontSize: 12, fontWeight: '200'}]}>You can pass any component via the 'children' prop.</Text>
</View>,
paddingTop: 10,
}
])
}
, updateDataSource: function(data){
this.setState({
dataSource: this.state.dataSource.cloneWithRows(data)
})
}
, renderRow: function (item){
return <Listitem
text={item.text}
children={item.children}
onPress={item.onPress}
backgroundColor={item.backgroundColor}
indent={item.indent}
style={item.style}
styleText={item.styleText}/>
}
, render: function() {
return (
<View style={styles.container}>
<ListView
dataSource={this.state.dataSource}
renderRow={this.renderRow}
style={styles.listview} />
</View>
);
}
});
var styles = StyleSheet.create({
container: {
alignItems: 'center',
backgroundColor: '#efeff4',
flex: 1,
flexDirection: 'row',
},
customLi: {
borderBottomColor: '#0044aa',
borderBottomWidth: 4,
paddingTop: 10,
paddingBottom: 12,
},
customLiText: {
color: '#fff',
fontSize: 12,
fontWeight: '600',
paddingLeft: 15,
},
});
AppRegistry.registerComponent('listitemExample', () => listitemExample);