// Module dependencies
const React = require('react-native');
const GiftedListView = require('react-native-gifted-listview');
const Spinner = require('react-native-spinkit');

const WeiboCell = require('../components/WeiboCell');
const config = require('../config');
const styles = require('./style');
const api = require('../api');

const {
  View,
  Text,
  AsyncStorage,
  TouchableOpacity
} = React;

module.exports = React.createClass({

  componentDidMount () {

  },

  async onFetch (page = 1, callback, options) {
    let accessToken = await AsyncStorage.getItem(config.token_store_key);
    let uid = await AsyncStorage.getItem(config.uid_store_key);
    let url = `${api.statuses.homeTimeline}?access_token=${accessToken}&uid=${uid}&page=${page}`;

    fetch(url)
      .then(resData => resData.json())
      .then(res => {
        callback(res.statuses);
      })
      .catch(err => console.error(err))
      .done();
  },

  renderFetchingView () {
    return (
      <View style={styles.loadingView}>
        <Spinner size={36} type="Bounce" color="#5ac8fb" />
      </View>
    );
  },

  renderAllLoadedView () {
    return (
      <View style={styles.loadingView}>
        <Text>加载完成</Text>
      </View>
    );
  },

  renderWaitingView (paginateCallback) {
    return (
      <View style={styles.loadingView}>
        <TouchableOpacity onPress={paginateCallback}>
          <Text style={{color:'#777',fontSize:14}}>点击加载更多</Text>
        </TouchableOpacity>
      </View>
    );
  },

  renderRefreshableFetchingView () {
    return (
      <View style={styles.loadingView}>
        <Spinner size={36} type="Wave" color="#5ac8fb" />
      </View>
    );
  },

  renderRefreshableWillRefreshView () {
    return (
      <View style={styles.loadingView}>
        <Text style={styles.pullText}>⇡ 释放更新</Text>
      </View>
    );
  },

  renderRefreshableWaitingView () {
    return (
      <View style={styles.loadingView}>
        <Text style={styles.pullText}>⇣ 下拉刷新</Text>
      </View>
    );
  },

  renderEmptyView () {
    return (
      <Text>No data yet.</Text>
    );
  },

  render () {
    return (
      <View style={styles.container}>
        <GiftedListView
          rowView={rowData=> <WeiboCell data={rowData} />}
          onFetch={this.onFetch}
          firstLoader={true}

          pagination={true}
          paginationFetchigView={this.renderFetchingView}
          paginationAllLoadedView={this.renderAllLoadedView}
          paginationWaitingView={this.renderWaitingView}

          refreshableFetchingView={this.renderRefreshableFetchingView}
          refreshableWillRefreshView={this.renderRefreshableWillRefreshView}
          refreshableWaitingView={this.renderRefreshableWaitingView}

          emptyView={this.renderEmptyView}

          refreshable={true}
        />
      </View>
    );
  }
});

@@ -65,131 +65,17 @@
 nst 
-GiftedListView = require('react-native-gifted-listview');%0Aconst Spinner = require('react-native-spinkit');%0A%0Aconst WeiboCell
+WeiboList
  = r
@@ -105,16 +105,17 @@
 eibo
-Cell
+List
 ');%0A
+%0A
 cons
@@ -151,43 +151,8 @@
 ');%0A
-const styles = require('./style');%0A
 cons
@@ -193,56 +193,20 @@
 %7B%0A  
-View,%0A  Text,%0A  AsyncStorage,%0A  TouchableOpacity
+AsyncStorage
 %0A%7D =
@@ -256,40 +256,8 @@
 (%7B%0A%0A
-  componentDidMount () %7B%0A%0A  %7D,%0A%0A
   as
@@ -722,28 +722,16 @@
   render
-FetchingView
  () %7B%0A  
@@ -743,1871 +743,44 @@
 urn 
-(%0A      %3CView style=%7Bstyles.loadingView%7D%3E%0A        %3CSpinner size=%7B36%7D type=%22Bounce%22 color=%22#5ac8fb%22 /%3E%0A      %3C/View%3E%0A    );%0A  %7D,%0A%0A  renderAllLoadedView () %7B%0A    return (%0A      %3CView style=%7Bstyles.loadingView%7D%3E%0A        %3CText%3E%E5%8A%A0%E8%BD%BD%E5%AE%8C%E6%88%90%3C/Text%3E%0A      %3C/View%3E%0A    );%0A  %7D,%0A%0A  renderWaitingView (paginateCallback) %7B%0A    return (%0A      %3CView style=%7Bstyles.loadingView%7D%3E%0A        %3CTouchableOpacity onPress=%7BpaginateCallback%7D%3E%0A          %3CText style=%7B%7Bcolor:'#777',fontSize:14%7D%7D%3E%E7%82%B9%E5%87%BB%E5%8A%A0%E8%BD%BD%E6%9B%B4%E5%A4%9A%3C/Text%3E%0A        %3C/TouchableOpacity%3E%0A      %3C/View%3E%0A    );%0A  %7D,%0A%0A  renderRefreshableFetchingView () %7B%0A    return (%0A      %3CView style=%7Bstyles.loadingView%7D%3E%0A        %3CSpinner size=%7B36%7D type=%22Wave%22 color=%22#5ac8fb%22 /%3E%0A      %3C/View%3E%0A    );%0A  %7D,%0A%0A  renderRefreshableWillRefreshView () %7B%0A    return (%0A      %3CView style=%7Bstyles.loadingView%7D%3E%0A        %3CText style=%7Bstyles.pullText%7D%3E%E2%87%A1 %E9%87%8A%E6%94%BE%E6%9B%B4%E6%96%B0%3C/Text%3E%0A      %3C/View%3E%0A    );%0A  %7D,%0A%0A  renderRefreshableWaitingView () %7B%0A    return (%0A      %3CView style=%7Bstyles.loadingView%7D%3E%0A        %3CText style=%7Bstyles.pullText%7D%3E%E2%87%A3 %E4%B8%8B%E6%8B%89%E5%88%B7%E6%96%B0%3C/Text%3E%0A      %3C/View%3E%0A    );%0A  %7D,%0A%0A  renderEmptyView () %7B%0A    return (%0A      %3CText%3ENo data yet.%3C/Text%3E%0A    );%0A  %7D,%0A%0A  render () %7B%0A    return (%0A      %3CView style=%7Bstyles.container%7D%3E%0A        %3CGiftedListView%0A          rowView=%7BrowData=%3E %3CWeiboCell data=%7BrowData%7D /%3E%7D%0A          onFetch=%7Bthis.onFetch%7D%0A          firstLoader=%7Btrue%7D%0A%0A          pagination=%7Btrue%7D%0A          paginationFetchigView=%7Bthis.renderFetchingView%7D%0A          paginationAllLoadedView=%7Bthis.renderAllLoadedView%7D%0A          paginationWaitingView=%7Bthis.renderWaitingView%7D%0A%0A          refreshableFetchingView=%7Bthis.renderRefreshableFetchingView%7D%0A          refreshableWillRefreshView=%7Bthis.renderRefreshableWillRefreshView%7D%0A          refreshableWaitingView=%7Bthis.renderRefreshableWaitingView%7D%0A%0A          emptyView=%7Bthis.renderEmptyView%7D%0A%0A          refreshable=%7Btrue%7D%0A        /%3E%0A      %3C/View%3E%0A    )
+%3CWeiboList onFetch=%7Bthis.onFetch%7D /%3E
 ;%0A  

Use WeiboList in Timeline