1- import React from 'react' ;
2- import { requireNativeComponent , NativeModules , View , Platform , DeviceEventEmitter } from 'react-native' ;
3- import PropTypes from 'prop-types' ;
1+ import React from "react" ;
2+ import {
3+ requireNativeComponent ,
4+ NativeModules ,
5+ View ,
6+ Platform ,
7+ DeviceEventEmitter
8+ } from "react-native" ;
9+ import PropTypes from "prop-types" ;
410
5- const RNPdfScanner = requireNativeComponent ( ' RNPdfScanner' , PdfScanner ) ;
11+ const RNPdfScanner = requireNativeComponent ( " RNPdfScanner" , PdfScanner ) ;
612const CameraManager = NativeModules . RNPdfScannerManager || { } ;
713
814class PdfScanner extends React . Component {
9-
1015 static defaultProps = {
11- onPictureTaken : ( ) => { } ,
12- onProcessing : ( ) => { } ,
13- }
16+ onPictureTaken : ( ) => { } ,
17+ onProcessing : ( ) => { }
18+ } ;
1419
1520 sendOnPictureTakenEvent ( event ) {
1621 return this . props . onPictureTaken ( event . nativeEvent ) ;
1722 }
1823
19- sendOnRectanleDetectEvent ( event ) {
24+ sendOnRectangleDetectEvent ( event ) {
2025 if ( ! this . props . onRectangleDetect ) return null ;
2126 return this . props . onRectangleDetect ( event . nativeEvent ) ;
2227 }
@@ -28,19 +33,19 @@ class PdfScanner extends React.Component {
2833 return this . props . quality ;
2934 }
3035
31- componentWillMount ( ) {
32- if ( Platform . OS === ' android' ) {
36+ componentWillMount ( ) {
37+ if ( Platform . OS === " android" ) {
3338 const { onPictureTaken, onProcessing } = this . props ;
34- DeviceEventEmitter . addListener ( ' onPictureTaken' , onPictureTaken ) ;
35- DeviceEventEmitter . addListener ( ' onProcessingChange' , onProcessing ) ;
39+ DeviceEventEmitter . addListener ( " onPictureTaken" , onPictureTaken ) ;
40+ DeviceEventEmitter . addListener ( " onProcessingChange" , onProcessing ) ;
3641 }
3742 }
38-
39- componentWillUnmount ( ) {
40- if ( Platform . OS === ' android' ) {
43+
44+ componentWillUnmount ( ) {
45+ if ( Platform . OS === " android" ) {
4146 const { onPictureTaken, onProcessing } = this . props ;
42- DeviceEventEmitter . removeListener ( ' onPictureTaken' , onPictureTaken ) ;
43- DeviceEventEmitter . removeListener ( ' onProcessingChange' , onProcessing ) ;
47+ DeviceEventEmitter . removeListener ( " onPictureTaken" , onPictureTaken ) ;
48+ DeviceEventEmitter . removeListener ( " onProcessingChange" , onProcessing ) ;
4449 }
4550 }
4651
@@ -54,14 +59,16 @@ class PdfScanner extends React.Component {
5459 < RNPdfScanner
5560 { ...this . props }
5661 onPictureTaken = { this . sendOnPictureTakenEvent . bind ( this ) }
57- onRectangleDetect = { this . sendOnRectanleDetectEvent . bind ( this ) }
58- useFrontCam = { this . props . useFrontCam || false }
59- brightness = { this . props . brightness || 0 }
60- saturation = { this . props . saturation || 1 }
61- contrast = { this . props . contrast || 1 }
62+ onRectangleDetect = { this . sendOnRectangleDetectEvent . bind ( this ) }
63+ useFrontCam = { this . props . useFrontCam || false }
64+ brightness = { this . props . brightness || 0 }
65+ saturation = { this . props . saturation || 1 }
66+ contrast = { this . props . contrast || 1 }
6267 quality = { this . getImageQuality ( ) }
63- detectionCountBeforeCapture = { this . props . detectionCountBeforeCapture || 5 }
64- detectionRefreshRateInMS = { this . props . detectionRefreshRateInMS || 50 }
68+ detectionCountBeforeCapture = {
69+ this . props . detectionCountBeforeCapture || 5
70+ }
71+ detectionRefreshRateInMS = { this . props . detectionRefreshRateInMS || 50 }
6572 />
6673 ) ;
6774 }
@@ -79,11 +86,10 @@ PdfScanner.propTypes = {
7986 detectionCountBeforeCapture : PropTypes . number ,
8087 detectionRefreshRateInMS : PropTypes . number ,
8188 quality : PropTypes . number ,
82-
83- documentAnimation : PropTypes . bool ,
89+ documentAnimation : PropTypes . bool ,
8490 noGrayScale : PropTypes . bool ,
8591 manualOnly : PropTypes . bool ,
86- ...View . propTypes // include the default view properties
92+ ...View . propTypes // include the default view properties
8793} ;
8894
8995export default PdfScanner ;
0 commit comments