-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathRefreshView.js
43 lines (35 loc) · 989 Bytes
/
RefreshView.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
import React, {
Component,
} from 'react'
import PropTypes from 'prop-types';
import {
View,
ViewPropTypes,
} from 'react-native'
import constants from './constants'
export default class RefreshView extends Component {
static defaultProps = {
renderRefreshContent: () => null,
}
static propTypes = {
...ViewPropTypes,
renderRefreshContent: PropTypes.func,
}
constructor (props) {
super(props)
this.state = {
pullState: props.viewType == constants.refreshViewType.header ? constants.viewState.refresh_none : constants.viewState.load_more_none,
pullDistancePercent: 0,
}
}
setNativeProps (props) {
this._refreshView.setNativeProps(props)
}
render () {
return (
<View ref={ component => this._refreshView = component } {...this.props}>
{this.props.renderRefreshContent(this.state)}
</View>
)
}
}