Skip to content

Commit d3db3b5

Browse files
committed
update Example
1 parent d75275c commit d3db3b5

File tree

2 files changed

+41
-23
lines changed

2 files changed

+41
-23
lines changed

Example/App.js

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
Easing
1616
} from 'react-native';
1717
import HuaWeiRefreshControl from './HuaWeiRefreshControl'
18+
import ListViewExample from './ListViewExample'
1819
const instructions = Platform.select({
1920
ios: 'Press Cmd+R to reload,\n' +
2021
'Cmd+D or shake for dev menu',
@@ -39,31 +40,9 @@ Date.prototype.Format = function (fmt) { // author: meizz
3940
}
4041
type Props = {};
4142
export default class App extends Component<Props> {
42-
_onRefresh=()=>{
43-
setTimeout(()=>{
44-
this._hw && this._hw.finishRefresh()
45-
},1000)
46-
}
4743
render() {
4844
return (
49-
<ScrollView
50-
style={{flex:1}}
51-
refreshControl={
52-
<HuaWeiRefreshControl
53-
ref={ref=>this._hw = ref}
54-
onRefresh={this._onRefresh}
55-
/>
56-
}
57-
>
58-
<View style={styles.container}>
59-
<Text style={styles.instructions}>
60-
To get started, edit App.js
61-
</Text>
62-
<Text style={styles.instructions}>
63-
{instructions}
64-
</Text>
65-
</View>
66-
</ScrollView>
45+
<ListViewExample/>
6746
);
6847
}
6948
}

Example/ListViewExample.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React, {Component} from 'react';
2+
import {StyleSheet, View, Text,ListView,ScrollView} from 'react-native';
3+
import PropTypes from 'prop-types';
4+
import HuaWeiRefreshControl from './HuaWeiRefreshControl';
5+
6+
export default class ListViewExample extends Component {
7+
constructor(props){
8+
super(props);
9+
var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
10+
this.state = {
11+
dataSource: ds.cloneWithRows(['row 1', 'row 2','row 3','row 4','row 5','row 6','row 7','row 8']),
12+
};
13+
}
14+
_onRefresh=()=>{
15+
setTimeout(()=>{
16+
this._hw && this._hw.finishRefresh()
17+
},1000)
18+
}
19+
render() {
20+
return (
21+
<View style={{flex: 1}}>
22+
<ListView
23+
dataSource={this.state.dataSource}
24+
renderRow={(rowData) => <Text onPress={()=>alert(111)} style={{height:100}}>{rowData}</Text>}
25+
renderScrollComponent={props=><ScrollView
26+
style={{flex:1}}
27+
refreshControl={
28+
<HuaWeiRefreshControl
29+
ref={ref=>this._hw = ref}
30+
onRefresh={this._onRefresh}
31+
/>
32+
}
33+
{...props}
34+
/>}
35+
/>
36+
</View>
37+
)
38+
}
39+
}

0 commit comments

Comments
 (0)