This repository has been archived by the owner on Oct 31, 2024. It is now read-only.
forked from bogdantmm92/react-native-refreshable-listview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRefreshingIndicator.js
64 lines (59 loc) · 1.5 KB
/
RefreshingIndicator.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var React = require('react-native')
var {
View,
Text,
ActivityIndicatorIOS,
PropTypes,
StyleSheet,
isValidElement,
createElement,
} = React
var RefreshingIndicator = React.createClass({
propTypes: {
activityIndicatorComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.element]),
stylesheet: PropTypes.object,
description: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
},
getDefaultProps() {
return {
activityIndicatorComponent: ActivityIndicatorIOS,
}
},
renderActivityIndicator(style) {
var activityIndicator = this.props.activityIndicatorComponent
if (isValidElement(activityIndicator)) {
return activityIndicator
} else { // is a component class, not an element
return createElement(activityIndicator, {style})
}
},
render() {
var styles = Object.assign({}, stylesheet, this.props.stylesheet)
return (
<View style={[styles.container, styles.wrapper]}>
<View style={[styles.container, styles.loading, styles.content]}>
<Text style={styles.description}>
{this.props.description}
</Text>
{this.renderActivityIndicator(styles.activityIndicator)}
</View>
</View>
)
},
})
var stylesheet = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'space-around',
alignItems: 'center',
},
wrapper: {
height: 60,
marginTop: 10,
},
content: {
marginTop: 10,
height: 60,
},
})
module.exports = RefreshingIndicator