|
@@ -0,0 +1,101 @@
|
|
1
|
+import _ from 'lodash';
|
|
2
|
+import React, { Component } from 'react';
|
|
3
|
+import {
|
|
4
|
+ View,
|
|
5
|
+ ScrollView,
|
|
6
|
+ Dimensions,
|
|
7
|
+ Text,
|
|
8
|
+ StyleSheet,
|
|
9
|
+ Button
|
|
10
|
+} from 'react-native';
|
|
11
|
+
|
|
12
|
+const Colors = [
|
|
13
|
+ "#1abc9c",
|
|
14
|
+ "#2ecc71",
|
|
15
|
+ "#3498db",
|
|
16
|
+ "#9b59b6",
|
|
17
|
+ "#34495e",
|
|
18
|
+ "#16a085",
|
|
19
|
+ "#27ae60",
|
|
20
|
+ "#2980b9",
|
|
21
|
+ "#8e44ad",
|
|
22
|
+ "#2c3e50",
|
|
23
|
+ "#f1c40f",
|
|
24
|
+ "#e67e22",
|
|
25
|
+ "#e74c3c",
|
|
26
|
+ "#ecf0f1",
|
|
27
|
+ "#95a5a6",
|
|
28
|
+ "#f39c12",
|
|
29
|
+ "#d35400",
|
|
30
|
+ "#c0392b",
|
|
31
|
+ "#bdc3c7",
|
|
32
|
+ "#7f8c8d"
|
|
33
|
+];
|
|
34
|
+const {height, width} = Dimensions.get('window');
|
|
35
|
+
|
|
36
|
+class ListScreen extends Component {
|
|
37
|
+ constructor(props){
|
|
38
|
+ super(props);
|
|
39
|
+ this.data = [];
|
|
40
|
+ const numberOfItems = 100;
|
|
41
|
+ for (i = 0; i < numberOfItems; i++) {
|
|
42
|
+ this.data.push({text:`cell ${i}`, tapCount: 0, id: i});
|
|
43
|
+ }
|
|
44
|
+ }
|
|
45
|
+
|
|
46
|
+ _onButtonPressed(i, color) {
|
|
47
|
+ this.props.navigator.push({
|
|
48
|
+ screen: 'example.Types.DummyScreen',
|
|
49
|
+ title: 'Dummy',
|
|
50
|
+ passProps: {
|
|
51
|
+ text: i,
|
|
52
|
+ bgColor: color
|
|
53
|
+ }
|
|
54
|
+ });
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+ render(){
|
|
58
|
+ return (
|
|
59
|
+ <ScrollView
|
|
60
|
+ style={[{flex: 1, backgroundColor: 'transparent',}]}
|
|
61
|
+ scrollEnabled={true}
|
|
62
|
+ scrollsToTop={false}
|
|
63
|
+ scrollEventThrottle={100}
|
|
64
|
+ automaticallyAdjustContentInsets={false}
|
|
65
|
+ directionalLockEnabled={true}
|
|
66
|
+ showsHorizontalScrollIndicator={false}
|
|
67
|
+ showsVerticalScrollIndicator={false}>
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+ {_.map(this.data, (o, i) => {
|
|
71
|
+ const color = getRandomColor(i);
|
|
72
|
+ return (
|
|
73
|
+ <View key={o.id} style={[styles.cellContainer, {backgroundColor: color}]}>
|
|
74
|
+ <Button title={o.text} onPress={() => {
|
|
75
|
+ this._onButtonPressed(i, color);
|
|
76
|
+ }}>
|
|
77
|
+ </Button>
|
|
78
|
+ </View>
|
|
79
|
+ );
|
|
80
|
+ })}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+ </ScrollView>
|
|
84
|
+ );
|
|
85
|
+ }
|
|
86
|
+}
|
|
87
|
+
|
|
88
|
+function getRandomColor(index) {
|
|
89
|
+ return Colors[index % Colors.length];
|
|
90
|
+}
|
|
91
|
+
|
|
92
|
+const styles = StyleSheet.create({
|
|
93
|
+ cellContainer: {
|
|
94
|
+ flex: 1,
|
|
95
|
+ paddingVertical: 30,
|
|
96
|
+ }
|
|
97
|
+});
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+module.exports = ListScreen;
|