-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ios.js
133 lines (119 loc) · 2.82 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import React, { Component } from 'react';
import { AppRegistry,
StyleSheet,
Text,
View,
TouchableOpacity,
requireNativeComponent,
findNodeHandle,
TextInput,
NativeModules,
Dimensions
} from 'react-native';
import SyncRegistry from './lib/SyncRegistry';
const RNInfiniteScrollViewChildren = requireNativeComponent('RNInfiniteScrollViewChildren', null);
const dataObj = [{
name: "Row 1",
width: 850,
height: 150,
},{
name: "Row 2",
width: 150,
height: 30,
},{
name: "Row 3",
width: 500,
height: 150,
},{
name: "Row 4",
width: 750,
height: 150,
},{
name: "Row 5",
width: 150,
height: 150,
},{
name: "Row 6",
width: 150,
height: 150,
},{
name: "Row 7",
width: 150,
height: 150,
},{
name: "Row 8",
width: 150,
height: 150,
},{
name: "Row 9",
width: 150,
height: 150,
},{
name: "Row 10",
width: 150,
height: 150,
}];
class RNInfiniteScrollViewRowTemplate extends Component {
render() {
return (
<View style={{padding: 10, width: this.props['item.width'], height: this.props['item.height'], backgroundColor: '#AAAA3377'}}>
<TextInput
style={{ backgroundColor: '#FFFFFF88', flexGrow: 1 }}
editable={false}
value={this.props['item.name']}
/>
</View>
);
}
}
SyncRegistry.registerComponent('RNInfiniteScrollViewRowTemplate', () => RNInfiniteScrollViewRowTemplate, ['item.name','item.width','item.height', 'index']);
var IScrollManager = NativeModules.RNInfiniteScrollViewChildrenManager;
class example extends Component {
componentWillMount() {
setTimeout(() => {
IScrollManager.prepareRows();
}, 500);
// setTimeout(() => {
// IScrollManager.prependDataToDataSource(['Row -4', 'Row -3', 'Row -2', 'Row -1', 'Row 0']);
// }, 1000);
// setTimeout(() => {
// IScrollManager.appendDataToDataSource(["Row 16", "Row 17", "Row 18"]);
// }, 1000);
// setTimeout(() => {
// IScrollManager.updateDataAtIndex(1, "row 33");
// }, 1000);
// setTimeout(() => {
// IScrollManager.setScrollerZoom(0.4, true);
// }, 1000);
}
render() {
/**
* 3 loopModes supported:
*
* no-loop,
* repeat-empty,
* repeat-edge,
*/
return (
<View style={styles.container}>
<RNInfiniteScrollViewChildren
style={{ top: 0, width: Dimensions.get('window').width, height: Dimensions.get('window').height, backgroundColor: 'pink' }}
horizontal
rowHeight={150}
rowWidth={Dimensions.get('window').width}
dynamicViewSizes
numRenderRows={10}
data={dataObj}
loopMode="no-loop"
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#D5D7FF',
},
});
AppRegistry.registerComponent('example', () => example);