/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react');
var {
StyleSheet,
Text,
View,
TouchableHighlight,
Platform
} = require('react-native');
var GiftedListView = require('react-native-gifted-listview');
var GiftedSpinner = require('react-native-gifted-spinner');
var Example = React.createClass({
/**
* Will be called when refreshing
* Should be replaced by your own logic
* @param {number} page Requested page to fetch
* @param {function} callback Should pass the rows
* @param {object} options Inform if first load
*/
_onFetch(page = 1, callback, options) {
setTimeout(() => {
var header = 'Header '+page;
var rows = {};
rows[header] = ['row '+((page - 1) * 3 + 1), 'row '+((page - 1) * 3 + 2), 'row '+((page - 1) * 3 + 3)];
if (page === 5) {
callback(rows, {
allLoaded: true, // the end of the list is reached
});
} else {
callback(rows);
}
}, 1000); // simulating network fetching
},
/**
* When a row is touched
* @param {object} rowData Row data
*/
_onPress(rowData) {
console.log(rowData+' pressed');
},
/**
* Render a row
* @param {object} rowData Row data
*/
_renderRowView(rowData) {
return (
this._onPress(rowData)}
>
{rowData}
);
},
/**
* Render a row
* @param {object} rowData Row data
*/
_renderSectionHeaderView(sectionData, sectionID) {
return (
{sectionID}
);
},
/**
* Render the refreshable view when waiting for refresh
* On Android, the view should be touchable to trigger the refreshCallback
* @param {function} refreshCallback The function to call to refresh the listview
*/
_renderRefreshableWaitingView(refreshCallback) {
if (Platform.OS !== 'android') {
return (
↓
);
} else {
return (
↻
);
}
},
/**
* Render the refreshable view when the pull to refresh has been activated
* @platform ios
*/
_renderRefreshableWillRefreshView() {
return (
↻
);
},
/**
* Render the refreshable view when fetching
*/
_renderRefreshableFetchingView() {
return (
);
},
/**
* Render the pagination view when waiting for touch
* @param {function} paginateCallback The function to call to load more rows
*/
_renderPaginationWaitingView(paginateCallback) {
return (
Load more
);
},
/**
* Render the pagination view when fetching
*/
_renderPaginationFetchingView() {
return (
);
},
/**
* Render the pagination view when end of list is reached
*/
_renderPaginationAllLoadedView() {
return (
~
);
},
/**
* Render a view when there is no row to display at the first fetch
* @param {function} refreshCallback The function to call to refresh the listview
*/
_renderEmptyView(refreshCallback) {
return (
Sorry, there is no content to display
↻
);
},
/**
* Render a separator between rows
*/
_renderSeparatorView() {
return (
);
},
render() {
return (
Gifted ListView
{
r1.id !== r2.id
}}
distinctRows={(rows)=>{
var indentitis = {};
var newRows = [];
for(var i = 0;i
);
}
});
var customStyles = {
separator: {
height: 1,
backgroundColor: '#CCC'
},
refreshableView: {
height: 50,
backgroundColor: '#fff',
justifyContent: 'center',
alignItems: 'center',
},
actionsLabel: {
fontSize: 20,
color: '#007aff',
},
paginationView: {
height: 44,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#FFF',
},
defaultView: {
justifyContent: 'center',
alignItems: 'center',
padding: 20,
},
defaultViewTitle: {
fontSize: 16,
fontWeight: 'bold',
marginBottom: 15,
},
row: {
padding: 10,
height: 44,
},
header: {
backgroundColor: '#50a4ff',
padding: 10,
},
headerTitle: {
color: '#fff',
},
};
var screenStyles = {
container: {
flex: 1,
backgroundColor: '#FFF',
},
navBar: {
height: 64,
backgroundColor: '#007aff',
justifyContent: 'center',
alignItems: 'center',
},
navBarTitle: {
color: '#fff',
fontSize: 16,
marginTop: 12,
}
};
module.exports = Example;