-
Notifications
You must be signed in to change notification settings - Fork 0
/
cccamera.js
105 lines (81 loc) · 2.73 KB
/
cccamera.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
import React, { Component, PropTypes } from 'react';
import {
requireNativeComponent,
View,
} from 'react-native';
const normalizePhotoOrigin = (photoOrigin) => {
const validPhotoOrigin = (
photoOrigin === 'STANDARD_CAMERA' ||
photoOrigin === 'STANDARD_CAMERA_FASTCAM' ||
photoOrigin === 'STANDARD_CAMERA_DOCSCAN'
);
return validPhotoOrigin ? photoOrigin : 'STANDARD_CAMERA';
};
class CCCamera extends Component {
_onClose = (event) => {
console.log('_onClose called in cccamera.js');
if (!this.props.onClose) { return; }
const errmsg = event.nativeEvent.errmsg;
const button = event.nativeEvent.button;
this.props.onClose(errmsg, button);
}
_onPhotoAccepted = (event) => {
if (!this.props.onPhotoAccepted) { return; }
const { filename, imgWidth, imgHeight, photoOrigin } = event.nativeEvent;
const origin = normalizePhotoOrigin(photoOrigin);
console.log(`_onPhotoAccepted called in cccamera.js (dims: ${imgWidth}x${imgHeight}, origin: ${origin})`);
this.props.onPhotoAccepted(filename, [imgWidth, imgHeight], origin);
}
_onPhotoTaken = (event) => {
if (!this.props.onPhotoTaken) { return; }
const { filename, imgWidth, imgHeight, photoOrigin } = event.nativeEvent;
const origin = normalizePhotoOrigin(photoOrigin);
console.log(`_onPhotoTaken called in cccamera.js (dims: ${imgWidth}x${imgHeight}, origin: ${origin})`);
this.props.onPhotoTaken(filename, [imgWidth, imgHeight], origin);
}
_onAuxModeClicked = () => {
console.log('_onAuxModeClicked called in cccamera.js');
if (!this.props.onAuxModeClicked) { return; }
this.props.onAuxModeClicked();
}
render() {
return (
<RNCCCamera
{...this.props}
projectName={this.props.projectName || ''}
projectAddress={this.props.projectAddress || ''}
onClose={this._onClose}
onPhotoAccepted={this._onPhotoAccepted}
onPhotoTaken={this._onPhotoTaken}
onAuxModeClicked={this._onAuxModeClicked}
/>
);
}
}
CCCamera.propTypes = {
storagePath: PropTypes.string,
projectName: PropTypes.string,
projectAddress: PropTypes.string,
exifLat: PropTypes.number,
exifLon: PropTypes.number,
exifLocTimestamp: PropTypes.number,
auxModeCaption: PropTypes.string,
onAuxModeClicked: PropTypes.func,
hideNativeUI: PropTypes.bool,
onClose: PropTypes.func,
onPhotoAccepted: PropTypes.func,
onPhotoTaken: PropTypes.func,
...View.propTypes,
};
CCCamera.defaultProps = {
projectName: '',
projectAddress: '',
exifLat: 0,
exifLon: 0,
exifLocTimestamp: 0,
auxModeCaption: '',
onAuxModeClicked: () => {},
hideNativeUI: false,
};
const RNCCCamera = requireNativeComponent('CompanyCamCamera', CCCamera);
export default CCCamera;