react-native-scanbot-barcode-scanner-sdk 4.0.1-beta.1 → 4.0.1-beta.2

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.
@@ -32,15 +32,14 @@ static inline bool isUndefined(facebook::react::Float value) {
32
32
  }
33
33
 
34
34
  @interface RTNScanbotBarcodeCameraView () <RCTRTNScanbotBarcodeCameraViewViewProtocol>
35
+ @property(nonatomic, strong) RTNScanbotBarcodeCameraViewConfigurationStruct _configuration;
36
+ @property(nonatomic, strong) SBSDKBarcodeScannerViewController* viewController;
37
+ @property(nonatomic, strong) SBSDKUIBarcodeFilter* _barcodeFilter;
38
+ @property(nonatomic, strong) CGFloat _userDefinedCameraZoomFactor;
39
+ @property(nonatomic, strong) BOOL _isFirstLaunch;
35
40
  @end
36
41
 
37
- @implementation RTNScanbotBarcodeCameraView {
38
- RTNScanbotBarcodeCameraViewConfigurationStruct _configuration;
39
- SBSDKBarcodeScannerViewController* viewController;
40
- SBSDKUIBarcodeFilter* _barcodeFilter;
41
- CGFloat _userDefinedCameraZoomFactor;
42
- BOOL _isFirstLaunch;
43
- }
42
+ @implementation RTNScanbotBarcodeCameraView
44
43
 
45
44
  + (ComponentDescriptorProvider)componentDescriptorProvider
46
45
  {
@@ -80,11 +79,11 @@ static inline bool isUndefined(facebook::react::Float value) {
80
79
  }
81
80
 
82
81
  if (!_cameraViewController) {
83
- viewController = [[SBSDKBarcodeScannerViewController alloc] initWithParentViewController:parentViewController
82
+ self.viewController = [[SBSDKBarcodeScannerViewController alloc] initWithParentViewController:parentViewController
84
83
  parentView:self
85
84
  delegate:self];
86
85
 
87
- _cameraViewController = viewController;
86
+ self._cameraViewController = viewController;
88
87
  }
89
88
  }
90
89
 
@@ -122,7 +121,7 @@ static inline bool isUndefined(facebook::react::Float value) {
122
121
  return;
123
122
  }
124
123
 
125
- if (_barcodeFilter != nil) {
124
+ if (self._barcodeFilter != nil) {
126
125
  results = filterBarcodeResults(results, _barcodeFilter);
127
126
  }
128
127
 
@@ -145,7 +144,7 @@ static inline bool isUndefined(facebook::react::Float value) {
145
144
  /* TODO: A single property change requires us to create a new ViewFinder configuration */
146
145
  - (SBSDKBaseScannerViewFinderConfiguration*)createViewFinderConfigurationCopy
147
146
  {
148
- SBSDKBaseScannerViewFinderConfiguration* oldConfig = viewController.viewFinderConfiguration;
147
+ SBSDKBaseScannerViewFinderConfiguration* oldConfig = self.viewController.viewFinderConfiguration;
149
148
  SBSDKBaseScannerViewFinderConfiguration* newConfig = [SBSDKBaseScannerViewFinderConfiguration defaultConfiguration];
150
149
 
151
150
  newConfig.viewFinderEnabled = oldConfig.viewFinderEnabled;
@@ -196,7 +195,7 @@ static inline bool isUndefined(facebook::react::Float value) {
196
195
  }
197
196
 
198
197
  if (!isUndefined(newViewProps.configuration.finderBackgroundOpacity)) {
199
- UIColor* bgColor = viewController.viewFinderConfiguration.backgroundColor;
198
+ UIColor* bgColor = self.viewController.viewFinderConfiguration.backgroundColor;
200
199
  viewFinderConfiguration.backgroundColor = [bgColor colorWithAlphaComponent:newViewProps.configuration.finderBackgroundOpacity];
201
200
  }
202
201
 
@@ -220,7 +219,7 @@ static inline bool isUndefined(facebook::react::Float value) {
220
219
  newViewProps.configuration.finderInset.right);
221
220
  }
222
221
 
223
- viewController.viewFinderConfiguration = viewFinderConfiguration;
222
+ self.viewController.viewFinderConfiguration = viewFinderConfiguration;
224
223
  // ---------------------------------------
225
224
  // END OF ViewFinderConfiguration MAPPING
226
225
  // ---------------------------------------
@@ -231,40 +230,40 @@ static inline bool isUndefined(facebook::react::Float value) {
231
230
 
232
231
  if (forceUpdate || oldViewProps.configuration.minimumTextLength != newViewProps.configuration.minimumTextLength) {
233
232
  if (!isUndefined(newViewProps.configuration.minimumTextLength)) {
234
- viewController.additionalDetectionParameters.minimumTextLength = newViewProps.configuration.minimumTextLength;
233
+ self.viewController.additionalDetectionParameters.minimumTextLength = newViewProps.configuration.minimumTextLength;
235
234
  }
236
235
  }
237
236
 
238
237
  if (forceUpdate || oldViewProps.configuration.maximumTextLength != newViewProps.configuration.maximumTextLength) {
239
238
  if (!isUndefined(newViewProps.configuration.maximumTextLength)) {
240
- viewController.additionalDetectionParameters.maximumTextLength = newViewProps.configuration.maximumTextLength;
239
+ self.viewController.additionalDetectionParameters.maximumTextLength = newViewProps.configuration.maximumTextLength;
241
240
  }
242
241
  }
243
242
 
244
243
  if (forceUpdate || oldViewProps.configuration.minimum1DBarcodesQuietZone != newViewProps.configuration.minimum1DBarcodesQuietZone) {
245
244
  if (!isUndefined(newViewProps.configuration.minimum1DBarcodesQuietZone)) {
246
- viewController.additionalDetectionParameters.minimum1DBarcodesQuietZone = newViewProps.configuration.minimum1DBarcodesQuietZone;
245
+ self.viewController.additionalDetectionParameters.minimum1DBarcodesQuietZone = newViewProps.configuration.minimum1DBarcodesQuietZone;
247
246
  }
248
247
  }
249
248
 
250
249
  if (forceUpdate || oldViewProps.configuration.stripCheckDigits != newViewProps.configuration.stripCheckDigits) {
251
- viewController.additionalDetectionParameters.stripCheckDigits = newViewProps.configuration.stripCheckDigits;
250
+ self.viewController.additionalDetectionParameters.stripCheckDigits = newViewProps.configuration.stripCheckDigits;
252
251
  }
253
252
 
254
253
  if (forceUpdate || oldViewProps.configuration.gs1DecodingEnabled != newViewProps.configuration.gs1DecodingEnabled) {
255
- viewController.additionalDetectionParameters.enableGS1Decoding = newViewProps.configuration.gs1DecodingEnabled;
254
+ self.viewController.additionalDetectionParameters.enableGS1Decoding = newViewProps.configuration.gs1DecodingEnabled;
256
255
  }
257
256
 
258
257
  if (forceUpdate || oldViewProps.configuration.msiPlesseyChecksumAlgorithm != newViewProps.configuration.msiPlesseyChecksumAlgorithm) {
259
- viewController.additionalDetectionParameters.msiPlesseyChecksumAlgorithm = extractMsiPlesseyChecksumAlgorithm(toNSString(newViewProps.configuration.msiPlesseyChecksumAlgorithm));
258
+ self.viewController.additionalDetectionParameters.msiPlesseyChecksumAlgorithm = extractMsiPlesseyChecksumAlgorithm(toNSString(newViewProps.configuration.msiPlesseyChecksumAlgorithm));
260
259
  }
261
260
 
262
261
  if (forceUpdate || oldViewProps.configuration.codeDensity != newViewProps.configuration.codeDensity) {
263
- viewController.additionalDetectionParameters.codeDensity = extractBarcodeDensity(toNSString(newViewProps.configuration.codeDensity));
262
+ self.viewController.additionalDetectionParameters.codeDensity = extractBarcodeDensity(toNSString(newViewProps.configuration.codeDensity));
264
263
  }
265
264
 
266
265
  if (forceUpdate || oldViewProps.configuration.flashEnabled != newViewProps.configuration.flashEnabled) {
267
- viewController.flashLightEnabled = newViewProps.configuration.flashEnabled;
266
+ self.viewController.flashLightEnabled = newViewProps.configuration.flashEnabled;
268
267
  }
269
268
 
270
269
  if (forceUpdate || oldViewProps.configuration.barcodeFormats != newViewProps.configuration.barcodeFormats) {
@@ -276,12 +275,12 @@ static inline bool isUndefined(facebook::react::Float value) {
276
275
  [barcodeFormats addObject:type];
277
276
  }
278
277
  }
279
- viewController.acceptedBarcodeTypes = [barcodeFormats copy];
278
+ self.viewController.acceptedBarcodeTypes = [barcodeFormats copy];
280
279
  }
281
280
  }
282
281
 
283
282
  if (forceUpdate || oldViewProps.configuration.engineMode != newViewProps.configuration.engineMode) {
284
- viewController.engineMode = extractEngineMode(toNSString(newViewProps.configuration.engineMode));
283
+ self.viewController.engineMode = extractEngineMode(toNSString(newViewProps.configuration.engineMode));
285
284
  }
286
285
 
287
286
  if (forceUpdate || oldViewProps.configuration.cameraZoomFactor != newViewProps.configuration.cameraZoomFactor) {
@@ -301,7 +300,7 @@ static inline bool isUndefined(facebook::react::Float value) {
301
300
  - (void)updateProps:(const facebook::react::Props::Shared &)props oldProps:(const facebook::react::Props::Shared &)oldProps {
302
301
  const auto &newViewProps = *std::static_pointer_cast<RTNScanbotBarcodeCameraViewProps const>(props);
303
302
 
304
- _configuration = newViewProps.configuration;
303
+ self._configuration = newViewProps.configuration;
305
304
 
306
305
  [self applyProps:props oldProps:oldProps forceUpdate:_isFirstLaunch];
307
306
  _isFirstLaunch = false;
@@ -315,8 +314,8 @@ static inline bool isUndefined(facebook::react::Float value) {
315
314
  }
316
315
  - (void)componentDidUpdate {}
317
316
  - (void)componentWillUnmount {
318
- [_cameraViewController removeFromParentViewController];
319
- _cameraViewController = NULL;
317
+ [self._cameraViewController removeFromParentViewController];
318
+ self._cameraViewController = NULL;
320
319
  }
321
320
  - (void)orientationChanged {}
322
321
 
@@ -15,32 +15,28 @@
15
15
  #import <ScanbotBarcodeScannerSDK/ScanbotBarcodeScannerSDK.h>
16
16
  #import <Foundation/Foundation.h>
17
17
 
18
- @implementation RNScanbotBarcodeCameraView {
19
- SBSDKBarcodeScannerViewController* viewController;
20
- RNScanbotCameraViewConfiguration* _cameraViewConfiguration;
21
- CGFloat _userDefinedCameraZoomFactor;
22
- }
18
+ @interface RNScanbotBarcodeCameraView()
19
+ @property(nonatomic, strong) SBSDKBarcodeScannerViewController* viewController;
20
+ @property(nonatomic, strong) RNScanbotCameraViewConfiguration* mCameraViewConfiguration;
21
+ @property(nonatomic) CGFloat mUserDefinedCameraZoomFactor;
22
+ @end
23
+
24
+ @implementation RNScanbotBarcodeCameraView
23
25
 
24
26
  - (instancetype)initWithFrame:(CGRect)frame {
25
27
  self = [super initWithFrame:frame];
26
- self.barcodes = [[NSMutableArray alloc] init];
27
- self.shouldUseFinderView = false;
28
- _cameraViewConfiguration = [[RNScanbotCameraViewConfiguration alloc] init];
29
- _userDefinedCameraZoomFactor = -1;
28
+ if (self) {
29
+ _barcodes = [[NSMutableArray alloc] init];
30
+ _shouldUseFinderView = false;
31
+ _mCameraViewConfiguration = [[RNScanbotCameraViewConfiguration alloc] init];
32
+ _mUserDefinedCameraZoomFactor = -1;
33
+ }
30
34
  return self;
31
35
  }
32
36
 
33
- - (void)layoutSubviews {
34
- if (_cameraViewController) {
35
- _cameraViewController.view.frame = [self bounds];
36
- return;
37
- }
38
-
39
- __weak RNScanbotBarcodeCameraView* weakSelf = self;
40
-
41
- dispatch_async(dispatch_get_main_queue(), ^{
42
- [weakSelf createCameraViewController];
43
- });
37
+ - (void)didMoveToWindow {
38
+ [super didMoveToWindow];
39
+ [self createCameraViewController];
44
40
  }
45
41
 
46
42
  - (void)createCameraViewController {
@@ -49,14 +45,14 @@
49
45
  return;
50
46
  }
51
47
 
52
- if (!_cameraViewController) {
53
- viewController = [[SBSDKBarcodeScannerViewController alloc] initWithParentViewController:parentViewController
54
- parentView:self
55
- delegate:self];
56
- _cameraViewController = viewController;
48
+ if (!self.cameraViewController) {
49
+ self.viewController = [[SBSDKBarcodeScannerViewController alloc] initWithParentViewController:parentViewController
50
+ parentView:self
51
+ delegate:self];
52
+ self.cameraViewController = self.viewController;
53
+
54
+ [self updateWithConfiguration];
57
55
  }
58
-
59
- [self updateWithConfiguration];
60
56
  }
61
57
 
62
58
  - (void)setConfiguration:(NSDictionary *)configuration {
@@ -96,9 +92,9 @@
96
92
  return;
97
93
  }
98
94
 
99
- _cameraViewConfiguration = cameraViewConfiguration;
95
+ self.mCameraViewConfiguration = cameraViewConfiguration;
100
96
 
101
- if(viewController) {
97
+ if(self.viewController) {
102
98
  [self updateWithConfiguration];
103
99
  }
104
100
  }
@@ -106,62 +102,65 @@
106
102
  - (void)updateWithConfiguration {
107
103
 
108
104
  SBSDKBaseScannerViewFinderConfiguration *configuration = [[SBSDKBaseScannerViewFinderConfiguration alloc] init];
109
- configuration.lineWidth = _cameraViewConfiguration.finderLineWidth;
110
- configuration.lineColor = _cameraViewConfiguration.finderLineColor;
111
- configuration.backgroundColor = _cameraViewConfiguration.finderBackgroundColor;
112
- configuration.backgroundColor = [configuration.backgroundColor colorWithAlphaComponent:_cameraViewConfiguration.finderBackgroundOpacity];
113
- configuration.aspectRatio = _cameraViewConfiguration.finderAspectRatio;
105
+ configuration.lineWidth = self.mCameraViewConfiguration.finderLineWidth;
106
+ configuration.lineColor = self.mCameraViewConfiguration.finderLineColor;
107
+ configuration.backgroundColor = self.mCameraViewConfiguration.finderBackgroundColor;
108
+ configuration.backgroundColor = [configuration.backgroundColor colorWithAlphaComponent:self.mCameraViewConfiguration.finderBackgroundOpacity];
109
+ configuration.aspectRatio = self.mCameraViewConfiguration.finderAspectRatio;
114
110
  if (self.finderInsetAvailable) {
115
- configuration.minimumInset = UIEdgeInsetsMake(_cameraViewConfiguration.finderInset.top,
116
- _cameraViewConfiguration.finderInset.left,
117
- _cameraViewConfiguration.finderInset.bottom,
118
- _cameraViewConfiguration.finderInset.right);
111
+ configuration.minimumInset = UIEdgeInsetsMake(self.mCameraViewConfiguration.finderInset.top,
112
+ self.mCameraViewConfiguration.finderInset.left,
113
+ self.mCameraViewConfiguration.finderInset.bottom,
114
+ self.mCameraViewConfiguration.finderInset.right);
119
115
  }
120
116
  configuration.viewFinderEnabled = self.shouldUseFinderView;
121
- viewController.viewFinderConfiguration = configuration;
122
- if (_cameraViewConfiguration.barcodeFormats) {
123
- viewController.acceptedBarcodeTypes = _cameraViewConfiguration.barcodeFormats;
117
+ self.viewController.viewFinderConfiguration = configuration;
118
+ if (self.mCameraViewConfiguration.barcodeFormats) {
119
+ self.viewController.acceptedBarcodeTypes = self.mCameraViewConfiguration.barcodeFormats;
124
120
  }
125
- if (_cameraViewConfiguration.acceptedDocumentFormats) {
126
- viewController.acceptedDocumentTypes = _cameraViewConfiguration.acceptedDocumentFormats;
121
+ if (self.mCameraViewConfiguration.acceptedDocumentFormats) {
122
+ self.viewController.acceptedDocumentTypes = self.mCameraViewConfiguration.acceptedDocumentFormats;
127
123
  }
128
124
 
129
125
  // Map Additional Parameters
130
126
  SBSDKBarcodeAdditionalParameters* additionalParameters = [[SBSDKBarcodeAdditionalParameters alloc] init];
131
127
 
132
- if (_cameraViewConfiguration.gs1DecodingEnabled) {
133
- additionalParameters.enableGS1Decoding = [_cameraViewConfiguration.gs1DecodingEnabled boolValue];
128
+ if (self.mCameraViewConfiguration.gs1DecodingEnabled) {
129
+ additionalParameters.enableGS1Decoding = [self.mCameraViewConfiguration.gs1DecodingEnabled boolValue];
134
130
  }
135
- if (_cameraViewConfiguration.maximumTextLength) {
136
- additionalParameters.maximumTextLength = [_cameraViewConfiguration.maximumTextLength intValue];
131
+ if (self.mCameraViewConfiguration.maximumTextLength) {
132
+ additionalParameters.maximumTextLength = [self.mCameraViewConfiguration.maximumTextLength intValue];
137
133
  }
138
- if (_cameraViewConfiguration.minimumTextLength) {
139
- additionalParameters.minimumTextLength = [_cameraViewConfiguration.minimumTextLength intValue];
134
+ if (self.mCameraViewConfiguration.minimumTextLength) {
135
+ additionalParameters.minimumTextLength = [self.mCameraViewConfiguration.minimumTextLength intValue];
140
136
  }
141
- if (_cameraViewConfiguration.msiPlesseyChecksumAlgorithm != -1) {
142
- additionalParameters.msiPlesseyChecksumAlgorithm = _cameraViewConfiguration.msiPlesseyChecksumAlgorithm;
137
+ if (self.mCameraViewConfiguration.msiPlesseyChecksumAlgorithm != -1) {
138
+ additionalParameters.msiPlesseyChecksumAlgorithm = self.mCameraViewConfiguration.msiPlesseyChecksumAlgorithm;
143
139
  }
144
- if (_cameraViewConfiguration.stripCheckDigits) {
145
- additionalParameters.stripCheckDigits = [_cameraViewConfiguration.stripCheckDigits boolValue];
140
+ if (self.mCameraViewConfiguration.stripCheckDigits) {
141
+ additionalParameters.stripCheckDigits = [self.mCameraViewConfiguration.stripCheckDigits boolValue];
146
142
  }
147
- if (_cameraViewConfiguration.codeDensity) {
148
- additionalParameters.codeDensity = _cameraViewConfiguration.codeDensity;
143
+ if (self.mCameraViewConfiguration.codeDensity) {
144
+ additionalParameters.codeDensity = self.mCameraViewConfiguration.codeDensity;
149
145
  }
150
146
 
151
- viewController.additionalDetectionParameters = additionalParameters;
147
+ self.viewController.additionalDetectionParameters = additionalParameters;
152
148
 
153
- if (_cameraViewConfiguration.cameraZoomFactor) {
154
- CGFloat value = [_cameraViewConfiguration.cameraZoomFactor floatValue];
155
- if (value != _userDefinedCameraZoomFactor || _userDefinedCameraZoomFactor == -1) {
156
- viewController.cameraZoomFactor = value;
157
- _userDefinedCameraZoomFactor = value;
149
+ if (self.mCameraViewConfiguration.cameraZoomFactor) {
150
+ CGFloat value = [self.mCameraViewConfiguration.cameraZoomFactor floatValue];
151
+ if (value != self.mUserDefinedCameraZoomFactor || self.mUserDefinedCameraZoomFactor == -1) {
152
+ self.viewController.cameraZoomFactor = value;
153
+ self.mUserDefinedCameraZoomFactor = value;
158
154
  }
159
155
  }
160
- if (_cameraViewConfiguration.engineMode != -1) {
161
- viewController.engineMode = _cameraViewConfiguration.engineMode;
156
+ if (self.mCameraViewConfiguration.engineMode != -1) {
157
+ self.viewController.engineMode = self.mCameraViewConfiguration.engineMode;
162
158
  }
163
- if (_cameraViewConfiguration.flashEnabled) {
164
- viewController.flashLightEnabled = [_cameraViewConfiguration.flashEnabled boolValue];
159
+
160
+ if (self.mCameraViewConfiguration.flashEnabled) {
161
+ if (self.viewController.flashLightEnabled != [self.mCameraViewConfiguration.flashEnabled boolValue]) {
162
+ self.viewController.flashLightEnabled = [self.mCameraViewConfiguration.flashEnabled boolValue];
163
+ }
165
164
  }
166
165
  }
167
166
 
@@ -204,8 +203,8 @@
204
203
  return;
205
204
  }
206
205
 
207
- if (_cameraViewConfiguration.barcodeFilter != nil) {
208
- results = filterBarcodeResults(results, _cameraViewConfiguration.barcodeFilter);
206
+ if (self.mCameraViewConfiguration.barcodeFilter != nil) {
207
+ results = filterBarcodeResults(results, self.mCameraViewConfiguration.barcodeFilter);
209
208
  }
210
209
 
211
210
  NSDictionary* outResult = @{
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.1-beta.1",
4
+ "version": "4.0.1-beta.2",
5
5
  "scanbot": {
6
6
  "iosVersion": "4.0.2"
7
7
  },