-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathASCIImage.js
41 lines (32 loc) · 1.13 KB
/
ASCIImage.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
var React = require('react-native');
var ASCIImage = React.createClass({
propTypes: {
ascii: React.PropTypes.arrayOf(React.PropTypes.string),
color: React.PropTypes.string,
contextOptions: React.PropTypes.arrayOf(React.PropTypes.object),
style: React.View.propTypes.style,
},
getInitialState: function() {
return { defaultDimensions: [0, 0] }
},
updateDimensions: function(dimensions) {
this.setState({ defaultDimensions: dimensions });
},
componentWillMount: function() {
ASCIImage.Common.defaultImageDimensionsFromASCII(this.props.ascii, this.updateDimensions);
},
render: function() {
return (
<RNASCIImage
style={[{ width: this.state.defaultDimensions[0], height: this.state.defaultDimensions[1]}, this.props.style]}
ascii={this.props.ascii}
color={this.props.color}
contextOptions={this.props.contextOptions}
/>
);
}
});
var RNASCIImage = React.requireNativeComponent('RCTASCIImage', ASCIImage);
ASCIImage.Writer = require('NativeModules').ASCIImageWriter;
ASCIImage.Common = require('NativeModules').ASCIImageCommon;
module.exports = ASCIImage;