-
Notifications
You must be signed in to change notification settings - Fork 9
/
AndroidSwipeRefreshLayout.js
47 lines (39 loc) · 1.03 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
import React, {
Component,
} from 'react'
import {
View,
requireNativeComponent,
Platform,
} from 'react-native'
import PropTypes from 'prop-types';
export default class AndroidSwipeRefreshLayout extends Component {
static propTypes = {
...View.propTypes,
refreshing: PropTypes.bool,
enabledPullUp: PropTypes.bool,
enabledPullDown: PropTypes.bool,
onSwipe: PropTypes.func,
onRefresh: PropTypes.func,
}
setNativeProps(props) {
this._nativeSwipeRefreshLayout.setNativeProps(props)
}
_onSwipe = (e) => {
this.props.onSwipe(e.nativeEvent.movement)
}
_onRefresh = () => {
this.props.onRefresh()
}
render() {
return (
<NativeSwipeRefreshLayout
{...this.props}
ref={ (component) => this._nativeSwipeRefreshLayout = component }
onSwipe={this._onSwipe}
onSwipeRefresh={this._onRefresh}
/>
);
}
}
const NativeSwipeRefreshLayout = Platform.OS == 'ios' ? View : requireNativeComponent('RCTSwipeRefreshLayout', AndroidSwipeRefreshLayout)