-
Notifications
You must be signed in to change notification settings - Fork 51
/
AndroidSwipeRefreshLayout.js
50 lines (40 loc) · 1.16 KB
/
AndroidSwipeRefreshLayout.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import React, {
Component,
} from 'react'
import PropTypes from 'prop-types';
import {
View,
requireNativeComponent,
Platform,
ViewPropTypes,
} from 'react-native'
export default class AndroidSwipeRefreshLayout extends Component {
static propTypes = {
...ViewPropTypes,
refreshing: PropTypes.bool,
enabledPullUp: PropTypes.bool,
enabledPullDown: PropTypes.bool,
onSwipe: PropTypes.func,
onRefresh: PropTypes.func,
}
setNativeProps(props) {
this._nativeSwipeRefreshLayout.setNativeProps(props)
}
render() {
return (
<NativeSwipeRefreshLayout
{...this.props}
ref={ (component) => this._nativeSwipeRefreshLayout = component }
onSwipe={this._onSwipe}
onSwipeRefresh={this._onRefresh}
/>
);
}
_onSwipe = (e) => {
this.props.onSwipe(e.nativeEvent.movement)
}
_onRefresh = () => {
this.props.onRefresh()
}
}
const NativeSwipeRefreshLayout = Platform.OS == 'ios' ? View : requireNativeComponent('RCTSwipeRefreshLayout', AndroidSwipeRefreshLayout)