react-native-rectangle-doc-scanner 3.7.0 → 3.9.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.7.0",
3
+ "version": "3.9.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -1,13 +1,16 @@
1
1
  #import "DocumentScannerView.h"
2
2
  #import "IPDFCameraViewController.h"
3
3
 
4
- @implementation DocumentScannerView
4
+ @implementation DocumentScannerView {
5
+ BOOL _hasSetupCamera;
6
+ }
5
7
 
6
8
  - (instancetype)init {
7
9
  self = [super init];
8
10
  if (self) {
9
11
  [self setEnableBorderDetection:YES];
10
12
  [self setDelegate: self];
13
+ _hasSetupCamera = NO;
11
14
  }
12
15
 
13
16
  return self;
@@ -15,9 +18,14 @@
15
18
 
16
19
  - (void)didMoveToWindow {
17
20
  [super didMoveToWindow];
18
- if (self.window) {
21
+ if (self.window && !_hasSetupCamera) {
22
+ // Only setup camera once when view is added to window
19
23
  [self setupCameraView];
20
24
  [self start];
25
+ _hasSetupCamera = YES;
26
+ } else if (!self.window && _hasSetupCamera) {
27
+ // Stop camera when view is removed from window
28
+ [self stop];
21
29
  }
22
30
  }
23
31
 
@@ -70,6 +70,16 @@
70
70
  [[NSNotificationCenter defaultCenter] removeObserver:self];
71
71
  }
72
72
 
73
+ - (void)layoutSubviews
74
+ {
75
+ [super layoutSubviews];
76
+
77
+ // Update GLKView frame to match parent bounds
78
+ if (_glkView) {
79
+ _glkView.frame = self.bounds;
80
+ }
81
+ }
82
+
73
83
  - (void)createGLKView
74
84
  {
75
85
  if (self.context) return;