Skip to content

Commit ba922a0

Browse files
committed
下拉刷新
1 parent 6574eb9 commit ba922a0

File tree

6 files changed

+52
-19
lines changed

6 files changed

+52
-19
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.

views/StoryList.react.js

+37-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var {
88
Image,
99
ListView,
1010
Platform,
11+
RefreshControl,
1112
ActivityIndicatorIOS,
1213
TouchableHighlight,
1314
} = React;
@@ -24,6 +25,7 @@ module.exports = React.createClass({
2425
currentPage: 0,
2526
totalCount: 0,//总数量
2627
pageSize: 10,
28+
isRefreshing: false,
2729
};
2830
},
2931
componentDidMount: function(){
@@ -41,7 +43,8 @@ module.exports = React.createClass({
4143
totalCount: data.TotalCount,
4244
pageSize: data.PageSize,
4345
loaded: true,
44-
isloadingNextPage: false
46+
isloadingNextPage: false,
47+
isRefreshing: false,
4548
});
4649
},
4750
_getStoryList: function(page, callback) {
@@ -60,6 +63,19 @@ module.exports = React.createClass({
6063
if(!this.state.loaded){
6164
return this._renderLoadingView();
6265
}
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+
}
6379
return (
6480
<ListView
6581
dataSource={this.state.dataSource}
@@ -69,12 +85,28 @@ module.exports = React.createClass({
6985
showsVerticalScrollIndicator={false}
7086
renderFooter={this._renderFooter}
7187
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+
/>
7699
);
77100
},
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+
},
78110
_renderRow: function(rowData) {
79111
return (
80112
<TouchableHighlight

web/output/bundle.js

+14-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/output/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
6-
<title>Webpack App</title>
6+
<title>我的webApp</title>
77

88

99
</head>

0 commit comments

Comments
 (0)