Skip to content

Commit 595d200

Browse files
committed
add FlatListExample
1 parent d3db3b5 commit 595d200

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

Example/App.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
} from 'react-native';
1717
import HuaWeiRefreshControl from './HuaWeiRefreshControl'
1818
import ListViewExample from './ListViewExample'
19+
import FlatListExample from "./FlatListExample";
1920
const instructions = Platform.select({
2021
ios: 'Press Cmd+R to reload,\n' +
2122
'Cmd+D or shake for dev menu',
@@ -42,7 +43,7 @@ type Props = {};
4243
export default class App extends Component<Props> {
4344
render() {
4445
return (
45-
<ListViewExample/>
46+
<FlatListExample/>
4647
);
4748
}
4849
}

Example/FlatListExample.js

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

0 commit comments

Comments
 (0)