forked from maxs15/react-native-spinkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·57 lines (45 loc) · 1.28 KB
/
index.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
import React, {PropTypes} from 'react'
import ReactNative from 'react-native'
var {
requireNativeComponent,
NativeModules,
View
} = ReactNative;
var RNSpinkit = null;
class Spinkit extends React.Component {
static propTypes = {
type: React.PropTypes.string,
color: React.PropTypes.string,
size: React.PropTypes.number,
isVisible: React.PropTypes.bool,
testID:React.PropTypes.string,
accessibilityComponentType:PropTypes.string,
accessibilityLabel:PropTypes.string,
accessibilityLiveRegion:PropTypes.string,
renderToHardwareTextureAndroid:PropTypes.bool,
importantForAccessibility:PropTypes.string,
onLayout:PropTypes.func,
};
static defaultProps = {
size: 37,
color: "#000000",
isVisible: true
};
render() {
var size = {height: this.props.size, width: this.props.size};
if (!this.props.isVisible) return <View/>;
return (
<RNSpinkit
type={String(this.props.type)}
size={parseInt(this.props.size)}
color={this.props.color}
style={[size, this.props.style]}/>
);
}
}
// Since RNPM does not recognize `requireNativeComponent`, so we have to
// add this line, and RNPM will link native modules automatically
NativeModules.RNSpinkit;
// Native component
RNSpinkit = requireNativeComponent('RNSpinkit', Spinkit);
module.exports = Spinkit;