mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-12 22:50:10 +08:00
Re-license and rename UIExplorer integration test app as RNTester
Reviewed By: yungsters Differential Revision: D4950085 fbshipit-source-id: 44574b5d0ef0d2ad5dfc714309b18dc69cbad9ff
This commit is contained in:
committed by
Facebook Github Bot
parent
82c4b9f0b7
commit
4a80dceac7
78
RNTester/js/ScrollViewSimpleExample.js
Normal file
78
RNTester/js/ScrollViewSimpleExample.js
Normal file
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @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 = '<ScrollView>';
|
||||
static description = 'Component that enables scrolling through child components.';
|
||||
|
||||
makeItems = (nItems: number, styles): Array<any> => {
|
||||
var items = [];
|
||||
for (var i = 0; i < nItems; i++) {
|
||||
items[i] = (
|
||||
<TouchableOpacity key={i} style={styles}>
|
||||
<Text>{'Item ' + i}</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
return items;
|
||||
};
|
||||
|
||||
render() {
|
||||
// One of the items is a horizontal scroll view
|
||||
var items = this.makeItems(NUM_ITEMS, styles.itemWrapper);
|
||||
items[4] = (
|
||||
<ScrollView key={'scrollView'} horizontal={true}>
|
||||
{this.makeItems(NUM_ITEMS, [styles.itemWrapper, styles.horizontalItemWrapper])}
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
var verticalScrollView = (
|
||||
<ScrollView style={styles.verticalScrollView}>
|
||||
{items}
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
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
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = ScrollViewSimpleExample;
|
||||
Reference in New Issue
Block a user