|
@@ -0,0 +1,101 @@
|
|
1
|
+import React, {Component, PropTypes} from 'react';
|
|
2
|
+import {
|
|
3
|
+ Text,
|
|
4
|
+ View,
|
|
5
|
+ ScrollView,
|
|
6
|
+ TouchableOpacity,
|
|
7
|
+ StyleSheet,
|
|
8
|
+ ListView,
|
|
9
|
+} from 'react-native';
|
|
10
|
+import {connect} from 'react-redux';
|
|
11
|
+import * as counterActions from '../reducers/counter/actions';
|
|
12
|
+
|
|
13
|
+const LOREM_IPSUM = 'Lorem ipsum dolor sit amet, ius ad pertinax oportere accommodare, an vix civibus corrumpit referrentur. Te nam case ludus inciderint, te mea facilisi adipiscing. Sea id integre luptatum. In tota sale consequuntur nec. Erat ocurreret mei ei. Eu paulo sapientem vulputate est, vel an accusam intellegam interesset. Nam eu stet pericula reprimique, ea vim illud modus, putant invidunt reprehendunt ne qui.';
|
|
14
|
+const hashCode = function(str) {
|
|
15
|
+ var hash = 15;
|
|
16
|
+ for (var ii = str.length - 1; ii >= 0; ii--) {
|
|
17
|
+ hash = ((hash << 5) - hash) + str.charCodeAt(ii);
|
|
18
|
+ }
|
|
19
|
+ return hash;
|
|
20
|
+};
|
|
21
|
+
|
|
22
|
+class ListScreen extends Component {
|
|
23
|
+
|
|
24
|
+ static navigatorStyle = {
|
|
25
|
+ statusBarColor: '#7CB342',
|
|
26
|
+ toolBarColor: '#8BC34A',
|
|
27
|
+ navigationBarColor: '#8BC34A'
|
|
28
|
+ };
|
|
29
|
+
|
|
30
|
+ constructor(props) {
|
|
31
|
+ super(props);
|
|
32
|
+
|
|
33
|
+ var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
|
|
34
|
+ this.state = {
|
|
35
|
+ dataSource: ds.cloneWithRows(this._genRows({}))
|
|
36
|
+ }
|
|
37
|
+ }
|
|
38
|
+
|
|
39
|
+ componentWillMount() {
|
|
40
|
+ this._pressData = {};
|
|
41
|
+ }
|
|
42
|
+
|
|
43
|
+ render() {
|
|
44
|
+ return (
|
|
45
|
+ <ListView
|
|
46
|
+ dataSource={this.state.dataSource}
|
|
47
|
+ renderRow={this._renderRow}/>
|
|
48
|
+ );
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ _renderRow(rowData, sectionID, rowID) {
|
|
52
|
+ const rowHash = Math.abs(hashCode(rowData));
|
|
53
|
+ return (
|
|
54
|
+ <View style={styles.row}>
|
|
55
|
+ <Text style={styles.text}>
|
|
56
|
+ {rowData + ' - ' + LOREM_IPSUM.substr(0, rowHash % 301 + 10)}
|
|
57
|
+ </Text>
|
|
58
|
+ </View>
|
|
59
|
+ );
|
|
60
|
+ }
|
|
61
|
+
|
|
62
|
+ _genRows() {
|
|
63
|
+ var dataBlob = [];
|
|
64
|
+ for (var ii = 0; ii < 100; ii++) {
|
|
65
|
+ dataBlob.push('Row ' + ii + ' ');
|
|
66
|
+ }
|
|
67
|
+ return dataBlob;
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ _renderSeparator(sectionID, rowID) {
|
|
71
|
+ return (
|
|
72
|
+ <View
|
|
73
|
+ key={`${sectionID}-${rowID}`}
|
|
74
|
+ style={{
|
|
75
|
+ height: 1,
|
|
76
|
+ backgroundColor: rowID % 2 == 0 ? '#3B5998' : '#CCCCCC'
|
|
77
|
+ }}
|
|
78
|
+ />
|
|
79
|
+ );
|
|
80
|
+ }
|
|
81
|
+}
|
|
82
|
+
|
|
83
|
+export default connect()(ListScreen);
|
|
84
|
+
|
|
85
|
+const styles = StyleSheet.create({
|
|
86
|
+ row: {
|
|
87
|
+ flexDirection: 'row',
|
|
88
|
+ justifyContent: 'center',
|
|
89
|
+ padding: 10,
|
|
90
|
+ backgroundColor: '#F6F6F6'
|
|
91
|
+ },
|
|
92
|
+ thumb: {
|
|
93
|
+ width: 64,
|
|
94
|
+ height: 64
|
|
95
|
+ },
|
|
96
|
+ text: {
|
|
97
|
+ flex: 1
|
|
98
|
+ }
|
|
99
|
+});
|
|
100
|
+
|
|
101
|
+
|