forked from Michaelvilleneuve/react-native-document-scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathios.js
61 lines (52 loc) · 1.81 KB
/
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
import React from 'react';
import { requireNativeComponent, NativeModules } from 'react-native';
import PropTypes from 'prop-types';
const RNPdfScanner = requireNativeComponent('RNPdfScanner', PdfScanner);
class PdfScanner extends React.Component {
sendOnPictureTakenEvent(event) {
return this.props.onPictureTaken(event.nativeEvent);
}
sendOnRectanleDetectEvent(event) {
if (!this.props.onRectangleDetect) return null;
return this.props.onRectangleDetect(event.nativeEvent);
}
getImageQuality() {
if (!this.props.quality) return 0.8;
if (this.props.quality > 1) return 1;
if (this.props.quality < 0.1) return 0.1;
return this.props.quality;
}
capture() {
NativeModules.RNPdfScannerManager.capture();
}
render() {
return (
<RNPdfScanner
{...this.props}
onPictureTaken={this.sendOnPictureTakenEvent.bind(this)}
onRectangleDetect={this.sendOnRectanleDetectEvent.bind(this)}
useFrontCam={this.props.useFrontCam||false}
brightness={this.props.brightness||0}
saturation={this.props.saturation||1}
contrast={this.props.contrast||1}
quality={this.getImageQuality()}
detectionCountBeforeCapture={this.props.detectionCountBeforeCapture||5}
detectionRefreshRateInMS={this.props.detectionRefreshRateInMS||50}
/>
);
}
}
PdfScanner.propTypes = {
onPictureTaken: PropTypes.func,
onRectangleDetect: PropTypes.func,
overlayColor: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
enableTorch: PropTypes.bool,
useFrontCam: PropTypes.bool,
saturation: PropTypes.number,
brightness: PropTypes.number,
contrast: PropTypes.number,
detectionCountBeforeCapture: PropTypes.number,
detectionRefreshRateInMS: PropTypes.number,
quality: PropTypes.number,
};
export default PdfScanner;