8
8
Image,
9
9
ListView,
10
10
Platform,
11
+ RefreshControl,
11
12
ActivityIndicatorIOS,
12
13
TouchableHighlight,
13
14
} = React ;
@@ -24,6 +25,7 @@ module.exports = React.createClass({
24
25
currentPage : 0 ,
25
26
totalCount : 0 , //总数量
26
27
pageSize : 10 ,
28
+ isRefreshing : false ,
27
29
} ;
28
30
} ,
29
31
componentDidMount : function ( ) {
@@ -41,7 +43,8 @@ module.exports = React.createClass({
41
43
totalCount : data . TotalCount ,
42
44
pageSize : data . PageSize ,
43
45
loaded : true ,
44
- isloadingNextPage : false
46
+ isloadingNextPage : false ,
47
+ isRefreshing : false ,
45
48
} ) ;
46
49
} ,
47
50
_getStoryList : function ( page , callback ) {
@@ -60,6 +63,19 @@ module.exports = React.createClass({
60
63
if ( ! this . state . loaded ) {
61
64
return this . _renderLoadingView ( ) ;
62
65
}
66
+ if ( Platform . OS == 'web' ) {
67
+ return (
68
+ < ListView
69
+ dataSource = { this . state . dataSource }
70
+ renderRow = { this . _renderRow }
71
+ onEndReachedThreshold = { 66 }
72
+ automaticallyAdjustContentInsets = { false }
73
+ showsVerticalScrollIndicator = { false }
74
+ renderFooter = { this . _renderFooter }
75
+ onEndReached = { this . _loadMore }
76
+ style = { styles . listView } />
77
+ ) ;
78
+ }
63
79
return (
64
80
< ListView
65
81
dataSource = { this . state . dataSource }
@@ -69,12 +85,28 @@ module.exports = React.createClass({
69
85
showsVerticalScrollIndicator = { false }
70
86
renderFooter = { this . _renderFooter }
71
87
onEndReached = { this . _loadMore }
72
- onRefreshStart = { ( endRefreshing ) => {
73
- setTimeout ( ( ) => { console . log ( endRefreshing ) } , 1000 ) ;
74
- } }
75
- style = { styles . listView } />
88
+ style = { styles . listView }
89
+ refreshControl = {
90
+ < RefreshControl
91
+ refreshing = { this . state . isRefreshing }
92
+ onRefresh = { this . _onRefresh }
93
+ tintColor = '#ccc'
94
+ title = '正在刷新'
95
+ colors = { [ '#bbb' , '#ccc' , '#333' ] }
96
+ progressBackgroundColor = '#f9f9f9' />
97
+ }
98
+ />
76
99
) ;
77
100
} ,
101
+ _onRefresh : function ( ) {
102
+ var This = this ;
103
+ this . setState ( { isRefreshing : true } ) ;
104
+ setTimeout ( function ( ) {
105
+ This . _getStoryList ( 1 , function ( data ) {
106
+ This . _setNewData ( data ) ;
107
+ } ) ;
108
+ } , 1000 ) ;
109
+ } ,
78
110
_renderRow : function ( rowData ) {
79
111
return (
80
112
< TouchableHighlight
0 commit comments