-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.android.js
More file actions
103 lines (89 loc) · 2.32 KB
/
index.android.js
File metadata and controls
103 lines (89 loc) · 2.32 KB
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
/**
* @providesModule CameraViewAndroid
*/
'use strict';
var React = require('react-native');
var Subscribable = require('Subscribable');
var {
PropTypes,
requireNativeComponent,
UIManager,
DeviceEventEmitter
} = React;
var RN_CAMERA_REF = 'cameraview';
var CameraView = React.createClass({
mixins: [Subscribable.Mixin],
onChange: function(event) {
if (!this.props.onBarCodeRead) return;
this.props.onBarCodeRead({
type: event.nativeEvent.type,
data: event.nativeEvent.data,
});
},
onPictureTaken: function(event) {
console.log(event);
if (!this.props.onPictureTaken) return;
this.props.onPictureTaken({
type: event.type,
message: event.message
})
},
componentWillMount: function() {
this.addListenerOn(
DeviceEventEmitter,
'cameraResult',
this.onPictureTaken
);
},
render: function() {
return (
<RNCameraView
{...this.props}
ref={RN_CAMERA_REF}
onChange={this.onChange}
/>
);
},
takePicture: function() {
UIManager.dispatchViewManagerCommand(
this._getCameraLayoutHandle(),
UIManager.RNCameraView.Commands.takePicture,
null
);
},
_getCameraLayoutHandle: function() {
return React.findNodeHandle(this.refs[RN_CAMERA_REF]);
}
})
CameraView.propTypes = {
autoFocus: PropTypes.bool,
torchMode: PropTypes.string,
type: PropTypes.string,
onLayout: PropTypes.bool,
onBarCodeRead: PropTypes.func,
onPictureTaken: PropTypes.func,
viewFinderDisplay: PropTypes.bool,
viewFinderBackgroundColor: PropTypes.string,
viewFinderBorderColor: PropTypes.string,
viewFinderBorderWidth: PropTypes.number,
viewFinderBorderLength: PropTypes.number,
viewFinderDrawLaser: PropTypes.bool,
viewFinderLaserColor: PropTypes.string,
rotation: PropTypes.number,
scaleX: PropTypes.number,
scaleY: PropTypes.number,
translateX: PropTypes.number,
translateY: PropTypes.number,
importantForAccessibility: PropTypes.string,
accessibilityLabel: PropTypes.string,
testID: PropTypes.string,
renderToHardwareTextureAndroid: PropTypes.string
};
var RNCameraView = requireNativeComponent('RNCameraView', CameraView, {
nativeOnly: {
onChange: true,
accessibilityLiveRegion: 'none',
accessibilityComponentType: 'button'
}
});
module.exports = CameraView;