Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 169da2a

Browse files
Martin Konicekfacebook-github-bot-2
Martin Konicek
authored and
facebook-github-bot-2
committed
Add simple ScrollView example to UI Explorer
Reviewed By: @foghina Differential Revision: D2434588
1 parent d5bce33 commit 169da2a

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/**
2+
* The examples provided by Facebook are for non-commercial testing and
3+
* evaluation purposes only.
4+
*
5+
* Facebook reserves all rights not expressly granted.
6+
*
7+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9+
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
10+
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
11+
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
12+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13+
*
14+
* @flow
15+
*/
16+
'use strict';
17+
18+
var React = require('react-native');
19+
var {
20+
ScrollView,
21+
StyleSheet,
22+
Text,
23+
TouchableOpacity
24+
} = React;
25+
26+
var NUM_ITEMS = 20;
27+
28+
var ScrollViewSimpleExample = React.createClass({
29+
statics: {
30+
title: '<ScrollView>',
31+
description: 'Component that enables scrolling through child components.'
32+
},
33+
makeItems: function(nItems, styles) {
34+
var items = [];
35+
for (var i = 0; i < nItems; i++) {
36+
items[i] = (
37+
<TouchableOpacity key={i} style={styles}>
38+
<Text>{'Item ' + i}</Text>
39+
</TouchableOpacity>
40+
);
41+
}
42+
return items;
43+
},
44+
45+
render: function() {
46+
// One of the items is a horizontal scroll view
47+
var items = this.makeItems(NUM_ITEMS, styles.itemWrapper);
48+
items[4] = (
49+
<ScrollView key={'scrollView'} horizontal={true}>
50+
{this.makeItems(NUM_ITEMS, [styles.itemWrapper, styles.horizontalItemWrapper])}
51+
</ScrollView>
52+
);
53+
54+
var verticalScrollView = (
55+
<ScrollView style={styles.verticalScrollView}>
56+
{items}
57+
</ScrollView>
58+
);
59+
60+
return verticalScrollView;
61+
}
62+
});
63+
64+
var styles = StyleSheet.create({
65+
verticalScrollView: {
66+
margin: 10,
67+
},
68+
itemWrapper: {
69+
backgroundColor: '#dddddd',
70+
alignItems: 'center',
71+
borderRadius: 5,
72+
borderWidth: 5,
73+
borderColor: '#a52a2a',
74+
padding: 30,
75+
margin: 5,
76+
},
77+
horizontalItemWrapper: {
78+
padding: 50
79+
}
80+
});
81+
82+
module.exports = ScrollViewSimpleExample;

0 commit comments

Comments
 (0)