forked from corymsmith/react-native-icons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FAKIconImage.ios.js
106 lines (88 loc) · 2.91 KB
/
FAKIconImage.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
106
/**
*
* @providesModule FAKIconImage
* @flow
*/
'use strict';
var EdgeInsetsPropType = require('EdgeInsetsPropType');
var NativeMethodsMixin = require('NativeMethodsMixin');
var NativeModules = require('NativeModules');
var PropTypes = require('ReactPropTypes');
var ImageResizeMode = require('ImageResizeMode');
var ImageStylePropTypes = require('ImageStylePropTypes');
var React = require('React');
var ReactIOSViewAttributes = require('ReactIOSViewAttributes');
var StyleSheet = require('StyleSheet');
var StyleSheetPropType = require('StyleSheetPropType');
var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass');
var flattenStyle = require('flattenStyle');
var insetsDiffer = require('insetsDiffer');
var invariant = require('invariant');
var merge = require('merge');
var warning = require('warning');
var deepDiffer = require('deepDiffer');
var FAKIconImage = React.createClass({
propTypes: {
name: PropTypes.string,
size: PropTypes.number,
color: PropTypes.string,
/**
* accessible - Whether this element should be revealed as an accessible
* element.
*/
accessible: PropTypes.bool,
/**
* accessibilityLabel - Custom string to display for accessibility.
*/
accessibilityLabel: PropTypes.string,
style: StyleSheetPropType(ImageStylePropTypes),
/**
* testID - A unique identifier for this element to be used in UI Automation
* testing scripts.
*/
testID: PropTypes.string,
},
mixins: [NativeMethodsMixin],
///**
// * `NativeMethodsMixin` will look for this when invoking `setNativeProps`. We
// * make `this` look like an actual native component class.
// */
viewConfig: {
uiViewClassName: 'UIView',
validAttributes: ReactIOSViewAttributes.UIView
},
render: function() {
var style = flattenStyle([styles.base, this.props.style]);
invariant(style, "style must be initialized");
var name = this.props.name;
invariant(name, "name must be initialized");
var size = this.props.size;
invariant(size, "size must be initialized");
var color = this.props.color;
var nativeProps = merge(this.props, {
style,
icon : {
name: name,
size: size,
color: color
}
});
return <FAKIconImageView {...nativeProps} />;
}
});
var styles = StyleSheet.create({
base: {
overflow: 'hidden'
}
});
var CommonImageViewAttributes = merge(ReactIOSViewAttributes.UIView, {
accessible: true,
accessibilityLabel: true,
icon: {diff: deepDiffer},
testID: PropTypes.string
});
var FAKIconImageView = createReactIOSNativeComponentClass({
validAttributes: CommonImageViewAttributes,
uiViewClassName: 'FAKIconImage'
});
module.exports = FAKIconImage;