react-native-rectangle-doc-scanner 3.5.0 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.5.0",
3
+ "version": "3.6.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -34,14 +34,15 @@ try {
34
34
  // Files to copy
35
35
  const filesToCopy = [
36
36
  'ios/IPDFCameraViewController.m',
37
- 'ios/DocumentScannerView.m'
37
+ 'ios/DocumentScannerView.m',
38
+ 'ios.js'
38
39
  ];
39
40
 
40
41
  let copiedCount = 0;
41
42
 
42
- for (const iosFile of filesToCopy) {
43
- const sourcePath = path.join(VENDOR_PATH, iosFile);
44
- const targetPath = path.join(SCANNER_PATH, iosFile);
43
+ for (const file of filesToCopy) {
44
+ const sourcePath = path.join(VENDOR_PATH, file);
45
+ const targetPath = path.join(SCANNER_PATH, file);
45
46
 
46
47
  if (fs.existsSync(sourcePath)) {
47
48
  // Backup original if not already backed up
@@ -13,6 +13,14 @@
13
13
  return self;
14
14
  }
15
15
 
16
+ - (void)didMoveToWindow {
17
+ [super didMoveToWindow];
18
+ if (self.window) {
19
+ [self setupCameraView];
20
+ [self start];
21
+ }
22
+ }
23
+
16
24
 
17
25
  - (void) didDetectRectangle:(CIRectangleFeature *)rectangle withType:(IPDFRectangeType)type {
18
26
  switch (type) {
@@ -0,0 +1,8 @@
1
+
2
+ #import <React/RCTBridgeModule.h>
3
+
4
+ #import <React/RCTViewManager.h>
5
+
6
+ @interface RNPdfScannerManager : RCTViewManager <RCTBridgeModule>
7
+
8
+ @end
@@ -0,0 +1,45 @@
1
+
2
+ #import "RNPdfScannerManager.h"
3
+ #import "DocumentScannerView.h"
4
+
5
+ @interface RNPdfScannerManager()
6
+ @property (strong, nonatomic) DocumentScannerView *scannerView;
7
+ @end
8
+
9
+ @implementation RNPdfScannerManager
10
+
11
+ - (dispatch_queue_t)methodQueue
12
+ {
13
+ return dispatch_get_main_queue();
14
+ }
15
+
16
+ RCT_EXPORT_MODULE()
17
+
18
+ RCT_EXPORT_VIEW_PROPERTY(onPictureTaken, RCTDirectEventBlock)
19
+ RCT_EXPORT_VIEW_PROPERTY(onRectangleDetect, RCTBubblingEventBlock)
20
+
21
+
22
+ RCT_EXPORT_VIEW_PROPERTY(overlayColor, UIColor)
23
+ RCT_EXPORT_VIEW_PROPERTY(enableTorch, BOOL)
24
+ RCT_EXPORT_VIEW_PROPERTY(useFrontCam, BOOL)
25
+ RCT_EXPORT_VIEW_PROPERTY(useBase64, BOOL)
26
+ RCT_EXPORT_VIEW_PROPERTY(saveInAppDocument, BOOL)
27
+ RCT_EXPORT_VIEW_PROPERTY(captureMultiple, BOOL)
28
+ RCT_EXPORT_VIEW_PROPERTY(detectionCountBeforeCapture, NSInteger)
29
+ RCT_EXPORT_VIEW_PROPERTY(detectionRefreshRateInMS, NSInteger)
30
+ RCT_EXPORT_VIEW_PROPERTY(saturation, float)
31
+ RCT_EXPORT_VIEW_PROPERTY(quality, float)
32
+ RCT_EXPORT_VIEW_PROPERTY(brightness, float)
33
+ RCT_EXPORT_VIEW_PROPERTY(contrast, float)
34
+
35
+ RCT_EXPORT_METHOD(capture) {
36
+
37
+ [_scannerView capture];
38
+ }
39
+
40
+ - (UIView*) view {
41
+ _scannerView = [[DocumentScannerView alloc] init];
42
+ return _scannerView;
43
+ }
44
+
45
+ @end
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { requireNativeComponent, NativeModules } from 'react-native';
3
+ import PropTypes from 'prop-types';
4
+
5
+ const RNPdfScanner = requireNativeComponent('RNPdfScanner', PdfScanner);
6
+
7
+ class PdfScanner extends React.Component {
8
+ constructor(props) {
9
+ super(props);
10
+ }
11
+
12
+ sendOnPictureTakenEvent(event) {
13
+ return this.props.onPictureTaken(event.nativeEvent);
14
+ }
15
+
16
+ sendOnRectanleDetectEvent(event) {
17
+ if (!this.props.onRectangleDetect) return null;
18
+ return this.props.onRectangleDetect(event.nativeEvent);
19
+ }
20
+
21
+ getImageQuality() {
22
+ if (!this.props.quality) return 0.8;
23
+ if (this.props.quality > 1) return 1;
24
+ if (this.props.quality < 0.1) return 0.1;
25
+ return this.props.quality;
26
+ }
27
+
28
+ capture() {
29
+ NativeModules.RNPdfScannerManager.capture();
30
+ }
31
+
32
+ render() {
33
+ return (
34
+ <RNPdfScanner
35
+ {...this.props}
36
+ onPictureTaken={this.sendOnPictureTakenEvent.bind(this)}
37
+ onRectangleDetect={this.sendOnRectanleDetectEvent.bind(this)}
38
+ useFrontCam={this.props.useFrontCam||false}
39
+ brightness={this.props.brightness||0}
40
+ saturation={this.props.saturation||1}
41
+ contrast={this.props.contrast||1}
42
+ quality={this.getImageQuality()}
43
+ detectionCountBeforeCapture={this.props.detectionCountBeforeCapture||5}
44
+ detectionRefreshRateInMS={this.props.detectionRefreshRateInMS||50}
45
+ />
46
+ );
47
+ }
48
+ }
49
+
50
+ PdfScanner.propTypes = {
51
+ onPictureTaken: PropTypes.func,
52
+ onRectangleDetect: PropTypes.func,
53
+ overlayColor: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
54
+ enableTorch: PropTypes.bool,
55
+ useFrontCam: PropTypes.bool,
56
+ saturation: PropTypes.number,
57
+ brightness: PropTypes.number,
58
+ contrast: PropTypes.number,
59
+ detectionCountBeforeCapture: PropTypes.number,
60
+ detectionRefreshRateInMS: PropTypes.number,
61
+ quality: PropTypes.number,
62
+ };
63
+
64
+ export default PdfScanner;