-
Notifications
You must be signed in to change notification settings - Fork 141
/
SMXLoadingImage.ios.js
105 lines (84 loc) · 2.35 KB
/
SMXLoadingImage.ios.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
*
* @providesModule SMXLoadingImage
* @flow
*/
'use strict';
var React = require('react-native');
var { StyleSheet, View, requireNativeComponent, Animated, Easing, processColor } = React;
var shimAssert = require('./shim-assert');
var SMXLoadingImage = React.createClass({
propTypes: {
name: React.PropTypes.string,
size: React.PropTypes.number,
color: React.PropTypes.string,
/**
* accessible - Whether this element should be revealed as an accessible
* element.
*/
accessible: React.PropTypes.bool,
/**
* accessibilityLabel - Custom string to display for accessibility.
*/
accessibilityLabel: React.PropTypes.string,
/**
* testID - A unique identifier for this element to be used in UI Automation
* testing scripts.
*/
testID: React.PropTypes.string,
icon: React.PropTypes.object
},
getInitialState: function () {
return {
angle: new Animated.Value(0)
};
},
setNativeProps(props:Object) {
},
_animate: function () {
this.state.angle.setValue(0);
Animated.timing(this.state.angle, {
toValue: 360,
duration: 1200,
easing: Easing.linear
}).start(this._animate);
},
componentDidMount: function () {
this._animate();
},
render: function ():ReactElement {
var transformStyle = {
transform: [
{
rotate: this.state.angle.interpolate({
inputRange: [0, 360],
outputRange: ['0deg', '360deg']
})
}
]
};
var style = [styles.base, this.props.style];
shimAssert.basic(style, 'style must be initialized');
var name = this.props.name;
shimAssert.basic(name, 'name must be initialized');
var size = this.props.size;
shimAssert.basic(size, 'size must be initialized');
var color = this.props.color;
var nativeProps = Object.assign({},this.props);
nativeProps.icon = {
name: name,
size: size,
color: processColor(color)
};
return <Animated.View style={[styles.base, style, transformStyle]}>
<SMXLoadingImageView style={{backgroundColor: 'transparent'}} {...nativeProps} />
</Animated.View>;
}
});
var styles = StyleSheet.create({
base: {
overflow: 'hidden'
}
});
var SMXLoadingImageView = requireNativeComponent('FAKIconImage', SMXLoadingImage);
module.exports = SMXLoadingImage;