-
Notifications
You must be signed in to change notification settings - Fork 141
/
SMXIconImage.android.js
70 lines (57 loc) · 1.86 KB
/
SMXIconImage.android.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
/**
*
* @providesModule SMXIconImage
* @flow
*/
'use strict';
var React = require('react-native');
var { StyleSheet, View, requireNativeComponent, processColor} = React;
var shimAssert = require('./shim-assert');
var ICON_REF = 'icon';
class IconImage extends React.Component {
setNativeProps(props:Object) {
this.refs[ICON_REF].setNativeProps(props);
}
render() {
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');
if(name.indexOf('|') == -1) {
throw Error('icon name "' + name + '" doesn\'t specify a font name prefix. ex. "ion|beer"');
}
var color = this.props.color;
var nativeProps = Object.assign({},this.props);
if(!color && style.color) {
nativeProps.color = processColor(style.color);
}
nativeProps.style = style;
return <RCTMyCustomView {...nativeProps} ref={ICON_REF} />;
}
}
var styles = StyleSheet.create({
base: {
overflow: 'hidden'
}
});
IconImage.propTypes = {
name: React.PropTypes.string,
color: React.PropTypes.string,
size: React.PropTypes.number,
scaleX: React.PropTypes.number,
scaleY: React.PropTypes.number,
translateX: React.PropTypes.number,
translateY: React.PropTypes.number,
rotation: React.PropTypes.number,
renderToHardwareTextureAndroid: React.PropTypes.bool,
onLayout: React.PropTypes.bool,
accessibilityLiveRegion: React.PropTypes.string,
accessibilityComponentType: React.PropTypes.string,
importantForAccessibility: React.PropTypes.string,
accessibilityLabel: React.PropTypes.string,
testID: React.PropTypes.string,
};
var RCTMyCustomView = requireNativeComponent('SMXIconImage', IconImage);
module.exports = IconImage;