2015-01-30 01:10:49 +00:00
|
|
|
/**
|
2015-03-23 22:07:33 +00:00
|
|
|
* 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
|
2015-01-30 01:10:49 +00:00
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2015-03-23 17:06:16 +00:00
|
|
|
var React = require('react-native');
|
2015-01-30 01:10:49 +00:00
|
|
|
var {
|
2015-03-20 15:43:51 +00:00
|
|
|
ListView,
|
2015-01-30 01:10:49 +00:00
|
|
|
PixelRatio,
|
|
|
|
ScrollView,
|
|
|
|
StyleSheet,
|
|
|
|
Text,
|
2015-03-20 15:43:51 +00:00
|
|
|
TextInput,
|
2015-01-30 01:10:49 +00:00
|
|
|
TouchableHighlight,
|
|
|
|
View,
|
|
|
|
} = React;
|
|
|
|
|
|
|
|
var createExamplePage = require('./createExamplePage');
|
|
|
|
|
2015-03-20 15:43:51 +00:00
|
|
|
var COMPONENTS = [
|
|
|
|
require('./ActivityIndicatorExample'),
|
|
|
|
require('./DatePickerExample'),
|
2015-01-30 01:10:49 +00:00
|
|
|
require('./ImageExample'),
|
2015-02-19 01:39:09 +00:00
|
|
|
require('./ListViewPagingExample'),
|
2015-03-20 15:43:51 +00:00
|
|
|
require('./ListViewSimpleExample'),
|
|
|
|
require('./MapViewExample'),
|
2015-01-30 01:10:49 +00:00
|
|
|
require('./NavigatorIOSExample'),
|
2015-03-11 02:11:28 +00:00
|
|
|
require('./PickerExample'),
|
2015-03-20 15:43:51 +00:00
|
|
|
require('./ScrollViewExample'),
|
2015-03-18 22:57:49 +00:00
|
|
|
require('./SliderIOSExample'),
|
2015-03-20 15:43:51 +00:00
|
|
|
require('./SwitchExample'),
|
|
|
|
require('./TabBarExample'),
|
|
|
|
require('./TextExample.ios'),
|
|
|
|
require('./TextInputExample'),
|
|
|
|
require('./TouchableExample'),
|
|
|
|
require('./ViewExample'),
|
2015-03-14 17:52:40 +00:00
|
|
|
require('./WebViewExample'),
|
2015-03-20 15:43:51 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
var APIS = [
|
|
|
|
require('./ActionSheetIOSExample'),
|
2015-03-11 02:11:28 +00:00
|
|
|
require('./AdSupportIOSExample'),
|
2015-03-20 15:43:51 +00:00
|
|
|
require('./AlertIOSExample'),
|
|
|
|
require('./AppStateIOSExample'),
|
|
|
|
require('./AsyncStorageExample'),
|
|
|
|
require('./CameraRollExample.ios'),
|
|
|
|
require('./GeolocationExample'),
|
|
|
|
require('./LayoutExample'),
|
|
|
|
require('./NetInfoExample'),
|
|
|
|
require('./PointerEventsExample'),
|
2015-03-24 16:26:16 +00:00
|
|
|
require('./PushNotificationIOSExample'),
|
2015-03-20 15:43:51 +00:00
|
|
|
require('./StatusBarIOSExample'),
|
|
|
|
require('./TimerExample'),
|
2015-03-17 20:42:44 +00:00
|
|
|
require('./VibrationIOSExample'),
|
2015-01-30 01:10:49 +00:00
|
|
|
];
|
|
|
|
|
2015-03-20 15:43:51 +00:00
|
|
|
var ds = new ListView.DataSource({
|
|
|
|
rowHasChanged: (r1, r2) => r1 !== r2,
|
|
|
|
sectionHeaderHasChanged: (h1, h2) => h1 !== h2,
|
|
|
|
});
|
|
|
|
|
|
|
|
class UIExplorerList extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
dataSource: ds.cloneWithRowsAndSections({
|
|
|
|
components: COMPONENTS,
|
|
|
|
apis: APIS,
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2015-01-30 01:10:49 +00:00
|
|
|
return (
|
2015-03-20 15:43:51 +00:00
|
|
|
<View style={styles.listContainer}>
|
|
|
|
<View style={styles.searchRow}>
|
|
|
|
<TextInput
|
|
|
|
autoCapitalize="none"
|
|
|
|
autoCorrect={false}
|
|
|
|
clearButtonMode="always"
|
|
|
|
onChangeText={this._search.bind(this)}
|
|
|
|
placeholder="Search..."
|
|
|
|
style={styles.searchTextInput}
|
|
|
|
/>
|
2015-01-30 01:10:49 +00:00
|
|
|
</View>
|
2015-03-20 15:43:51 +00:00
|
|
|
<ListView
|
|
|
|
style={styles.list}
|
|
|
|
dataSource={this.state.dataSource}
|
|
|
|
renderRow={this._renderRow.bind(this)}
|
|
|
|
renderSectionHeader={this._renderSectionHeader}
|
|
|
|
automaticallyAdjustContentInsets={false}
|
|
|
|
/>
|
|
|
|
</View>
|
2015-01-30 01:10:49 +00:00
|
|
|
);
|
2015-03-20 15:43:51 +00:00
|
|
|
}
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2015-03-20 15:43:51 +00:00
|
|
|
_renderSectionHeader(data, section) {
|
|
|
|
return (
|
|
|
|
<View style={styles.sectionHeader}>
|
|
|
|
<Text style={styles.sectionHeaderTitle}>
|
|
|
|
{section.toUpperCase()}
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_renderRow(example, i) {
|
2015-01-30 01:10:49 +00:00
|
|
|
return (
|
2015-02-08 01:23:25 +00:00
|
|
|
<View key={i}>
|
2015-01-30 01:10:49 +00:00
|
|
|
<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>
|
|
|
|
);
|
2015-03-20 15:43:51 +00:00
|
|
|
}
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2015-03-20 15:43:51 +00:00
|
|
|
_search(text) {
|
|
|
|
var regex = new RegExp(text, 'i');
|
|
|
|
var filter = (component) => regex.test(component.title);
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
dataSource: ds.cloneWithRowsAndSections({
|
|
|
|
components: COMPONENTS.filter(filter),
|
|
|
|
apis: APIS.filter(filter),
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_onPressRow(example) {
|
2015-01-30 01:10:49 +00:00
|
|
|
var Component = example.examples ?
|
|
|
|
createExamplePage(null, example) :
|
|
|
|
example;
|
|
|
|
this.props.navigator.push({
|
|
|
|
title: Component.title,
|
|
|
|
component: Component,
|
|
|
|
});
|
2015-03-20 15:43:51 +00:00
|
|
|
}
|
|
|
|
}
|
2015-01-30 01:10:49 +00:00
|
|
|
|
|
|
|
var styles = StyleSheet.create({
|
2015-03-20 15:43:51 +00:00
|
|
|
listContainer: {
|
|
|
|
flex: 1,
|
|
|
|
},
|
2015-01-30 01:10:49 +00:00
|
|
|
list: {
|
|
|
|
backgroundColor: '#eeeeee',
|
|
|
|
},
|
2015-03-20 15:43:51 +00:00
|
|
|
sectionHeader: {
|
|
|
|
padding: 5,
|
|
|
|
},
|
2015-01-30 01:10:49 +00:00
|
|
|
group: {
|
|
|
|
backgroundColor: 'white',
|
|
|
|
},
|
2015-03-20 15:43:51 +00:00
|
|
|
sectionHeaderTitle: {
|
|
|
|
fontWeight: 'bold',
|
|
|
|
fontSize: 11,
|
2015-01-30 01:10:49 +00: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,
|
|
|
|
},
|
2015-03-20 15:43:51 +00:00
|
|
|
searchRow: {
|
|
|
|
backgroundColor: '#eeeeee',
|
|
|
|
paddingTop: 75,
|
|
|
|
paddingLeft: 10,
|
|
|
|
paddingRight: 10,
|
|
|
|
paddingBottom: 10,
|
|
|
|
},
|
|
|
|
searchTextInput: {
|
|
|
|
backgroundColor: 'white',
|
|
|
|
borderColor: '#cccccc',
|
|
|
|
borderRadius: 3,
|
|
|
|
borderWidth: 1,
|
|
|
|
height: 30,
|
|
|
|
paddingLeft: 8,
|
|
|
|
},
|
2015-01-30 01:10:49 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = UIExplorerList;
|