react-native-rectangle-doc-scanner 3.44.4 → 3.45.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.44.4",
3
+ "version": "3.45.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -32,8 +32,22 @@ RCT_EXPORT_VIEW_PROPERTY(quality, float)
32
32
  RCT_EXPORT_VIEW_PROPERTY(brightness, float)
33
33
  RCT_EXPORT_VIEW_PROPERTY(contrast, float)
34
34
 
35
- RCT_EXPORT_METHOD(capture) {
36
- NSLog(@"[RNPdfScannerManager] capture called, scannerView: %@", _scannerView ? @"YES" : @"NO");
35
+ RCT_EXPORT_METHOD(capture:(nonnull NSNumber *)reactTag) {
36
+ NSLog(@"[RNPdfScannerManager] capture called with reactTag: %@", reactTag);
37
+ [self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
38
+ DocumentScannerView *view = (DocumentScannerView *)viewRegistry[reactTag];
39
+ if (!view || ![view isKindOfClass:[DocumentScannerView class]]) {
40
+ NSLog(@"[RNPdfScannerManager] Cannot find DocumentScannerView with tag #%@", reactTag);
41
+ return;
42
+ }
43
+ NSLog(@"[RNPdfScannerManager] Calling capture on view: %@", view);
44
+ [view capture];
45
+ }];
46
+ }
47
+
48
+ // Deprecated - kept for backward compatibility
49
+ RCT_EXPORT_METHOD(captureGlobal) {
50
+ NSLog(@"[RNPdfScannerManager] captureGlobal called (deprecated), scannerView: %@", _scannerView ? @"YES" : @"NO");
37
51
  [_scannerView capture];
38
52
  }
39
53
 
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { requireNativeComponent, NativeModules } from 'react-native';
2
+ import { requireNativeComponent, NativeModules, findNodeHandle } from 'react-native';
3
3
  import PropTypes from 'prop-types';
4
4
 
5
5
  const RNPdfScanner = requireNativeComponent('RNPdfScanner', PdfScanner);
@@ -7,6 +7,7 @@ const RNPdfScanner = requireNativeComponent('RNPdfScanner', PdfScanner);
7
7
  class PdfScanner extends React.Component {
8
8
  constructor(props) {
9
9
  super(props);
10
+ this.scannerRef = React.createRef();
10
11
  }
11
12
 
12
13
  sendOnPictureTakenEvent(event) {
@@ -26,13 +27,22 @@ class PdfScanner extends React.Component {
26
27
  }
27
28
 
28
29
  capture() {
29
- console.log('[PdfScanner/ios.js] capture called');
30
- return NativeModules.RNPdfScannerManager.capture();
30
+ console.log('[PdfScanner/ios.js] capture called, ref:', this.scannerRef.current);
31
+ const handle = findNodeHandle(this.scannerRef.current);
32
+ console.log('[PdfScanner/ios.js] node handle (reactTag):', handle);
33
+ if (handle) {
34
+ // Call native method with reactTag
35
+ return NativeModules.RNPdfScannerManager.capture(handle);
36
+ }
37
+ // Fallback to old method
38
+ console.log('[PdfScanner/ios.js] No handle, using fallback');
39
+ return NativeModules.RNPdfScannerManager.captureGlobal();
31
40
  }
32
41
 
33
42
  render() {
34
43
  return (
35
44
  <RNPdfScanner
45
+ ref={this.scannerRef}
36
46
  {...this.props}
37
47
  onPictureTaken={this.sendOnPictureTakenEvent.bind(this)}
38
48
  onRectangleDetect={this.sendOnRectanleDetectEvent.bind(this)}