[ReactNative] Expose ListView.DataSource instead of a top domain ListViewDataSource

This commit is contained in:
Christopher Chedeau 2015-03-02 16:02:42 -08:00
Родитель 39475de388
Коммит a39024928e
4 изменённых файлов: 8 добавлений и 7 удалений

Просмотреть файл

@ -7,7 +7,6 @@
var React = require('react-native'); var React = require('react-native');
var { var {
ListView, ListView,
ListViewDataSource,
ScrollView, ScrollView,
ActivityIndicatorIOS, ActivityIndicatorIOS,
StyleSheet, StyleSheet,
@ -44,7 +43,7 @@ var SearchScreen = React.createClass({
return { return {
isLoading: false, isLoading: false,
isLoadingTail: false, isLoadingTail: false,
dataSource: new ListViewDataSource({ dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2, rowHasChanged: (row1, row2) => row1 !== row2,
}), }),
filter: '', filter: '',
@ -192,7 +191,7 @@ var SearchScreen = React.createClass({
}); });
}, },
getDataSource: function(movies: Array<any>): ListViewDataSource { getDataSource: function(movies: Array<any>): ListView.DataSource {
return this.state.dataSource.cloneWithRows(movies); return this.state.dataSource.cloneWithRows(movies);
}, },

Просмотреть файл

@ -11,7 +11,6 @@ var {
Image, Image,
LayoutAnimation, LayoutAnimation,
ListView, ListView,
ListViewDataSource,
StyleSheet, StyleSheet,
Text, Text,
TouchableOpacity, TouchableOpacity,
@ -72,7 +71,7 @@ var ListViewPagingExample = React.createClass({
return dataBlob[rowID]; return dataBlob[rowID];
}; };
var dataSource = new ListViewDataSource({ var dataSource = new ListView.DataSource({
getRowData: getRowData, getRowData: getRowData,
getSectionHeaderData: getSectionData, getSectionHeaderData: getSectionData,
rowHasChanged: (row1, row2) => row1 !== row2, rowHasChanged: (row1, row2) => row1 !== row2,

Просмотреть файл

@ -9,7 +9,6 @@ var React = require('react-native');
var { var {
Image, Image,
ListView, ListView,
ListViewDataSource,
TouchableHighlight, TouchableHighlight,
StyleSheet, StyleSheet,
Text, Text,
@ -25,7 +24,7 @@ var ListViewSimpleExample = React.createClass({
}, },
getInitialState: function() { getInitialState: function() {
var ds = new ListViewDataSource({rowHasChanged: (r1, r2) => r1 !== r2}); var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
return { return {
dataSource: ds.cloneWithRows(this._genRows({})), dataSource: ds.cloneWithRows(this._genRows({})),
}; };

Просмотреть файл

@ -77,6 +77,10 @@ var SCROLLVIEW_REF = 'listviewscroll';
var ListView = React.createClass({ var ListView = React.createClass({
mixins: [ScrollResponder.Mixin, TimerMixin], mixins: [ScrollResponder.Mixin, TimerMixin],
statics: {
DataSource: ListViewDataSource,
},
/** /**
* You must provide a renderRow function. If you omit any of the other render * You must provide a renderRow function. If you omit any of the other render
* functions, ListView will simply skip rendering them. * functions, ListView will simply skip rendering them.