react-native-scanbot-barcode-scanner-sdk 4.0.4-beta.3 → 4.0.4-beta.4

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.
@@ -211,6 +211,10 @@ public class ScanbotBarcodeCameraView extends FrameLayout implements BarcodeDete
211
211
 
212
212
  return Unit.INSTANCE;
213
213
  });
214
+
215
+ if (frameHandler != null) {
216
+ frameHandler.setEnabled(config.isScanningEnabled());
217
+ }
214
218
  });
215
219
  }
216
220
 
@@ -39,6 +39,7 @@ public class ScanbotBarcodeCameraViewConfiguration {
39
39
  private float finderBackgroundOpacity = 0.66f;
40
40
  private float cameraZoomFactor = -1;
41
41
  private boolean flashEnabled = false;
42
+ private boolean scanningEnabled = true;
42
43
 
43
44
  private AspectRatio finderAspectRatio = new AspectRatio(1, 1);
44
45
 
@@ -74,6 +75,10 @@ public class ScanbotBarcodeCameraViewConfiguration {
74
75
  this.flashEnabled = flashEnabled;
75
76
  }
76
77
 
78
+ public void setScanningEnabled(boolean enabled) {
79
+ this.scanningEnabled = enabled;
80
+ }
81
+
77
82
  public boolean shouldUseFinderView() {
78
83
  return shouldUseFinderView;
79
84
  }
@@ -106,6 +111,10 @@ public class ScanbotBarcodeCameraViewConfiguration {
106
111
  return finderAspectRatio;
107
112
  }
108
113
 
114
+ public boolean isScanningEnabled() {
115
+ return scanningEnabled;
116
+ }
117
+
109
118
  /**
110
119
  * Checks if finder inset available, then populates the finder inset from readable map(json) object
111
120
  *
@@ -171,6 +180,10 @@ public class ScanbotBarcodeCameraViewConfiguration {
171
180
  nativeConfig.barcodeFilter = JSONUtils.extractBarcodeFilter(jsonConfig);
172
181
  }
173
182
 
183
+ if (jsonConfig.hasKey("scanningEnabled")) {
184
+ nativeConfig.setScanningEnabled(jsonConfig.getBoolean("scanningEnabled"));
185
+ }
186
+
174
187
  nativeConfig.additionalConfiguration = JSONUtils.extractBarcodeScannerAdditionalConfig(jsonConfig);
175
188
  nativeConfig.engineMode = JSONUtils.extractEngineMode(jsonConfig);
176
189
 
@@ -36,6 +36,7 @@ static inline bool isUndefined(facebook::react::Float value) {
36
36
  @property(nonatomic, strong) SBSDKUIBarcodeFilter *barcodeFilter;
37
37
  @property(nonatomic) CGFloat userDefinedCameraZoomFactor;
38
38
  @property(nonatomic) BOOL isFirstLaunch;
39
+ @property(nonatomic) BOOL scanningEnabled;
39
40
  @end
40
41
 
41
42
  @implementation RTNScanbotBarcodeCameraView
@@ -54,6 +55,7 @@ static inline bool isUndefined(facebook::react::Float value) {
54
55
 
55
56
  self.barcodes = [[NSMutableArray alloc] init];
56
57
  _userDefinedCameraZoomFactor = -1;
58
+ _scanningEnabled = true;
57
59
  }
58
60
  return self;
59
61
  }
@@ -294,6 +296,8 @@ static inline bool isUndefined(facebook::react::Float value) {
294
296
  if (forceUpdate || oldViewProps.configuration.barcodeFilter != newViewProps.configuration.barcodeFilter) {
295
297
  _barcodeFilter = extractBarcodeFilter(toNSString(newViewProps.configuration.barcodeFilter));
296
298
  }
299
+
300
+ _scanningEnabled = newViewProps.configuration.scanningEnabled;
297
301
  }
298
302
 
299
303
  - (void)updateProps:(const facebook::react::Props::Shared &)props oldProps:(const facebook::react::Props::Shared &)oldProps {
@@ -328,7 +332,7 @@ static inline bool isUndefined(facebook::react::Float value) {
328
332
  }
329
333
 
330
334
  - (BOOL)barcodeScannerControllerShouldDetectBarcodes:(SBSDKBarcodeScannerViewController *)controller {
331
- return true;
335
+ return _scanningEnabled;
332
336
  }
333
337
 
334
338
  - (void)barcodeScannerController:(nonnull SBSDKBarcodeScannerViewController *)controller didDetectBarcodes:(nonnull NSArray<SBSDKBarcodeScannerResult *> *)codes {
@@ -43,6 +43,7 @@
43
43
  @property (nonatomic) UIColor* _Nonnull finderBackgroundColor;
44
44
  @property (nonatomic) CGFloat finderBackgroundOpacity;
45
45
  @property (nonatomic) SBSDKAspectRatio* _Nonnull finderAspectRatio;
46
+ @property (nonatomic) BOOL scanningEnabled;
46
47
 
47
48
  // Nullable Properties (-1 for enums)
48
49
  @property (nonatomic, copy) NSNumber* _Nullable shouldUseFinderView;
@@ -19,6 +19,7 @@
19
19
  @property(nonatomic, strong) SBSDKBarcodeScannerViewController* viewController;
20
20
  @property(nonatomic, strong) RNScanbotCameraViewConfiguration* mCameraViewConfiguration;
21
21
  @property(nonatomic) CGFloat mUserDefinedCameraZoomFactor;
22
+ @property(nonatomic) BOOL scanningEnabled;
22
23
  @end
23
24
 
24
25
  @implementation RNScanbotBarcodeCameraView
@@ -30,6 +31,7 @@
30
31
  _shouldUseFinderView = false;
31
32
  _mCameraViewConfiguration = [[RNScanbotCameraViewConfiguration alloc] init];
32
33
  _mUserDefinedCameraZoomFactor = -1;
34
+ _scanningEnabled = true;
33
35
  }
34
36
  return self;
35
37
  }
@@ -162,6 +164,8 @@
162
164
  self.viewController.flashLightEnabled = [self.mCameraViewConfiguration.flashEnabled boolValue];
163
165
  }
164
166
  }
167
+
168
+ _scanningEnabled = self.mCameraViewConfiguration.scanningEnabled;
165
169
  }
166
170
 
167
171
 
@@ -233,7 +237,7 @@
233
237
  }
234
238
 
235
239
  - (BOOL)barcodeScannerControllerShouldDetectBarcodes:(SBSDKBarcodeScannerViewController *)controller {
236
- return true;
240
+ return _scanningEnabled;
237
241
  }
238
242
 
239
243
  - (void)barcodeScannerController:(nonnull SBSDKBarcodeScannerViewController *)controller didDetectBarcodes:(nonnull NSArray<SBSDKBarcodeScannerResult *> *)codes {
@@ -279,6 +283,7 @@
279
283
  self.engineMode = SBSDKBarcodeEngineModeNextGen;
280
284
  self.flashEnabled = nil;
281
285
  self.finderInset = UIEdgeInsetsMake(32, 32, 32, 32);
286
+ self.scanningEnabled = true;
282
287
  }
283
288
  return self;
284
289
  }
@@ -62,7 +62,12 @@ export interface ScanbotBarcodeCameraViewConfiguration extends FinderConfig, Bar
62
62
  /**
63
63
  * Use a filter to determine which type of barcode can be detected; see `BarcodeFilter`
64
64
  */
65
- barcodeFilter?: string; // TODO: Should be BarcodeFilter
65
+ barcodeFilter?: string; // TODO: Should be BarcodeFilter,
66
+ /**
67
+ * Enable or disable barcode detecting. If disabled, camera preview will be active but not barcodes will be scanned.
68
+ * Default is enabled.
69
+ */
70
+ scanningEnabled?: boolean;
66
71
  }
67
72
 
68
73
  export type NativeComponentBarcodeFormat =
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-scanbot-barcode-scanner-sdk",
3
3
  "title": "Scanbot Barcode Scanner SDK for React Native",
4
- "version": "4.0.4-beta.3",
4
+ "version": "4.0.4-beta.4",
5
5
  "scanbot": {
6
6
  "iosVersion": "4.0.2"
7
7
  },
@@ -64,6 +64,11 @@ export interface ScanbotBarcodeCameraViewConfiguration extends FinderConfig, Bar
64
64
  * Use a filter to determine which type of barcode can be detected; see `BarcodeFilter`
65
65
  */
66
66
  barcodeFilter?: BarcodeFilter;
67
+ /**
68
+ * Enable or disable barcode detecting. If disabled, camera preview will be active but not barcodes will be scanned.
69
+ * Default is enabled.
70
+ */
71
+ scanningEnabled?: boolean;
67
72
  }
68
73
 
69
74
  /**