2015-02-19 20:10:52 -08:00
|
|
|
/**
|
|
|
|
* Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var React = require('react-native/addons');
|
|
|
|
var {
|
2015-03-18 18:16:09 -07:00
|
|
|
ListView,
|
2015-02-19 20:10:52 -08:00
|
|
|
PixelRatio,
|
|
|
|
ScrollView,
|
|
|
|
StyleSheet,
|
|
|
|
Text,
|
|
|
|
TouchableHighlight,
|
|
|
|
View,
|
|
|
|
} = React;
|
|
|
|
|
|
|
|
var createExamplePage = require('./createExamplePage');
|
|
|
|
|
2015-03-18 18:16:09 -07:00
|
|
|
var COMPONENTS = [
|
|
|
|
require('./ActivityIndicatorExample'),
|
|
|
|
require('./DatePickerExample'),
|
2015-02-19 20:10:52 -08:00
|
|
|
require('./ImageExample'),
|
|
|
|
require('./ListViewPagingExample'),
|
2015-03-18 18:16:09 -07:00
|
|
|
require('./ListViewSimpleExample'),
|
|
|
|
require('./MapViewExample'),
|
2015-02-19 20:10:52 -08:00
|
|
|
require('./NavigatorIOSExample'),
|
2015-03-10 09:32:20 -07:00
|
|
|
require('./PickerExample'),
|
2015-03-18 18:16:09 -07:00
|
|
|
require('./ScrollViewExample'),
|
2015-03-18 08:56:49 -07:00
|
|
|
require('./SliderIOSExample'),
|
2015-03-18 18:16:09 -07:00
|
|
|
require('./SwitchExample'),
|
|
|
|
require('./TabBarExample'),
|
|
|
|
require('./TextExample.ios'),
|
|
|
|
require('./TextInputExample'),
|
|
|
|
require('./TouchableExample'),
|
|
|
|
require('./ViewExample'),
|
2015-03-14 01:22:25 -07:00
|
|
|
require('./WebViewExample'),
|
2015-03-18 18:16:09 -07:00
|
|
|
];
|
|
|
|
|
|
|
|
var APIS = [
|
|
|
|
require('./ActionSheetIOSExample'),
|
2015-03-10 12:09:35 -07:00
|
|
|
require('./AdSupportIOSExample'),
|
2015-03-18 18:16:09 -07:00
|
|
|
require('./AlertIOSExample'),
|
2015-03-11 13:53:30 -07:00
|
|
|
require('./AppStateExample'),
|
2015-03-18 18:16:09 -07:00
|
|
|
require('./AppStateIOSExample'),
|
|
|
|
require('./AsyncStorageExample'),
|
|
|
|
require('./CameraRollExample.ios'),
|
|
|
|
require('./GeolocationExample'),
|
|
|
|
require('./LayoutExample'),
|
|
|
|
require('./NetInfoExample'),
|
|
|
|
require('./PointerEventsExample'),
|
|
|
|
require('./StatusBarIOSExample'),
|
|
|
|
require('./TimerExample'),
|
2015-03-16 21:02:57 -07:00
|
|
|
require('./VibrationIOSExample'),
|
2015-02-19 20:10:52 -08:00
|
|
|
];
|
|
|
|
|
|
|
|
var UIExplorerList = React.createClass({
|
2015-03-18 18:16:09 -07:00
|
|
|
|
|
|
|
getInitialState: function() {
|
|
|
|
var ds = new ListView.DataSource({
|
|
|
|
rowHasChanged: (r1, r2) => r1 !== r2,
|
|
|
|
sectionHeaderHasChanged: (h1, h2) => h1 !== h2,
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
dataSource: ds.cloneWithRowsAndSections({
|
|
|
|
components: COMPONENTS,
|
|
|
|
apis: APIS,
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2015-02-19 20:10:52 -08:00
|
|
|
render: function() {
|
|
|
|
return (
|
2015-03-18 18:16:09 -07:00
|
|
|
<ListView
|
|
|
|
style={styles.list}
|
|
|
|
dataSource={this.state.dataSource}
|
|
|
|
renderRow={this._renderRow}
|
|
|
|
renderSectionHeader={this._renderSectionHeader}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
_renderSectionHeader: function(data, section) {
|
|
|
|
return (
|
|
|
|
<View style={styles.sectionHeader}>
|
|
|
|
<Text style={styles.sectionHeaderTitle}>
|
|
|
|
{section.toUpperCase()}
|
|
|
|
</Text>
|
|
|
|
</View>
|
2015-02-19 20:10:52 -08:00
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
_renderRow: function(example, i) {
|
|
|
|
return (
|
|
|
|
<View key={i}>
|
|
|
|
<TouchableHighlight onPress={() => this._onPressRow(example)}>
|
|
|
|
<View style={styles.row}>
|
|
|
|
<Text style={styles.rowTitleText}>
|
|
|
|
{example.title}
|
|
|
|
</Text>
|
|
|
|
<Text style={styles.rowDetailText}>
|
|
|
|
{example.description}
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
</TouchableHighlight>
|
|
|
|
<View style={styles.separator} />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
_onPressRow: function(example) {
|
|
|
|
var Component = example.examples ?
|
|
|
|
createExamplePage(null, example) :
|
|
|
|
example;
|
|
|
|
this.props.navigator.push({
|
|
|
|
title: Component.title,
|
|
|
|
component: Component,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
var styles = StyleSheet.create({
|
|
|
|
list: {
|
|
|
|
backgroundColor: '#eeeeee',
|
|
|
|
},
|
2015-03-18 18:16:09 -07:00
|
|
|
sectionHeader: {
|
|
|
|
padding: 5,
|
2015-02-19 20:10:52 -08:00
|
|
|
},
|
2015-03-18 18:16:09 -07:00
|
|
|
sectionHeaderTitle: {
|
|
|
|
fontWeight: 'bold',
|
|
|
|
fontSize: 11,
|
2015-02-19 20:10:52 -08:00
|
|
|
},
|
|
|
|
row: {
|
|
|
|
backgroundColor: 'white',
|
|
|
|
justifyContent: 'center',
|
|
|
|
paddingHorizontal: 15,
|
|
|
|
paddingVertical: 8,
|
|
|
|
},
|
|
|
|
separator: {
|
|
|
|
height: 1 / PixelRatio.get(),
|
|
|
|
backgroundColor: '#bbbbbb',
|
|
|
|
marginLeft: 15,
|
|
|
|
},
|
|
|
|
rowTitleText: {
|
|
|
|
fontSize: 17,
|
|
|
|
fontWeight: 'bold',
|
|
|
|
},
|
|
|
|
rowDetailText: {
|
|
|
|
fontSize: 15,
|
|
|
|
color: '#888888',
|
|
|
|
lineHeight: 20,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = UIExplorerList;
|