/** * Copyright (c) 2015-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow * @providesModule ScrollViewSimpleExample */ 'use strict'; var React = require('react'); var ReactNative = require('react-native'); var { ScrollView, StyleSheet, Text, TouchableOpacity } = ReactNative; var NUM_ITEMS = 20; class ScrollViewSimpleExample extends React.Component<{}> { static title = ''; static description = 'Component that enables scrolling through child components.'; makeItems = (nItems: number, styles): Array => { var items = []; for (var i = 0; i < nItems; i++) { items[i] = ( {'Item ' + i} ); } return items; }; render() { // One of the items is a horizontal scroll view var items = this.makeItems(NUM_ITEMS, styles.itemWrapper); items[4] = ( {this.makeItems(NUM_ITEMS, [styles.itemWrapper, styles.horizontalItemWrapper])} ); items.push( {this.makeItems(NUM_ITEMS, [ styles.itemWrapper, styles.horizontalItemWrapper, styles.horizontalPagingItemWrapper, ])} ); var verticalScrollView = ( {items} ); return verticalScrollView; } } var styles = StyleSheet.create({ verticalScrollView: { margin: 10, }, itemWrapper: { backgroundColor: '#dddddd', alignItems: 'center', borderRadius: 5, borderWidth: 5, borderColor: '#a52a2a', padding: 30, margin: 5, }, horizontalItemWrapper: { padding: 50 }, horizontalPagingItemWrapper: { width: 200, }, }); module.exports = ScrollViewSimpleExample;