62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
|
var React = require('React');
|
||
|
var NativeModules = require('NativeModules');
|
||
|
var ReactIOSViewAttributes = require('ReactIOSViewAttributes');
|
||
|
var StyleSheet = require('StyleSheet');
|
||
|
var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass');
|
||
|
var PropTypes = require('ReactPropTypes');
|
||
|
var StyleSheetPropType = require('StyleSheetPropType');
|
||
|
var NativeMethodsMixin = require('NativeMethodsMixin');
|
||
|
var flattenStyle = require('flattenStyle');
|
||
|
var merge = require('merge');
|
||
|
|
||
|
var Camera = React.createClass({
|
||
|
propTypes: {
|
||
|
orientation: PropTypes.integer,
|
||
|
},
|
||
|
|
||
|
mixins: [NativeMethodsMixin],
|
||
|
|
||
|
viewConfig: {
|
||
|
uiViewClassName: 'UIView',
|
||
|
validAttributes: ReactIOSViewAttributes.UIView
|
||
|
},
|
||
|
|
||
|
getInitialState: function() {
|
||
|
return {
|
||
|
isAuthorized: false
|
||
|
};
|
||
|
},
|
||
|
|
||
|
componentWillMount: function() {
|
||
|
NativeModules.CameraManager.checkDeviceAuthorizationStatus((function(err, isAuthorized) {
|
||
|
this.state.isAuthorized = isAuthorized;
|
||
|
this.setState(this.state);
|
||
|
}).bind(this));
|
||
|
},
|
||
|
|
||
|
render: function() {
|
||
|
var style = flattenStyle([styles.base, this.props.style]);
|
||
|
var orientation = this.props.orientation;
|
||
|
|
||
|
var nativeProps = merge(this.props, {
|
||
|
style,
|
||
|
orientation: orientation,
|
||
|
});
|
||
|
|
||
|
return <RCTCamera {... nativeProps} />
|
||
|
},
|
||
|
});
|
||
|
|
||
|
var RCTCamera = createReactIOSNativeComponentClass({
|
||
|
validAttributes: merge(ReactIOSViewAttributes.UIView, { orientation: true }),
|
||
|
uiViewClassName: 'RCTCamera',
|
||
|
});
|
||
|
|
||
|
var styles = StyleSheet.create({
|
||
|
base: {
|
||
|
overflow: 'hidden'
|
||
|
},
|
||
|
});
|
||
|
|
||
|
module.exports = Camera;
|