react-native-scanbot-barcode-scanner-sdk 3.1.0-alpha1 → 3.1.0-beta10

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.
Files changed (145) hide show
  1. package/Libraries.txt +352 -283
  2. package/RNScanbotBarcodeSDK.podspec +1 -1
  3. package/android/.gradle/7.0-rc-1/dependencies-accessors/dependencies-accessors.lock +0 -0
  4. package/android/.gradle/{6.1.1 → 7.0-rc-1/dependencies-accessors}/gc.properties +0 -0
  5. package/android/.gradle/{6.1.1 → 7.0-rc-1}/fileChanges/last-build.bin +0 -0
  6. package/android/.gradle/7.0-rc-1/fileHashes/fileHashes.lock +0 -0
  7. package/android/.gradle/7.0-rc-1/gc.properties +0 -0
  8. package/android/.gradle/7.1.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  9. package/android/.gradle/7.1.1/dependencies-accessors/gc.properties +0 -0
  10. package/android/.gradle/7.1.1/fileChanges/last-build.bin +0 -0
  11. package/android/.gradle/7.1.1/fileHashes/fileHashes.lock +0 -0
  12. package/android/.gradle/7.1.1/gc.properties +0 -0
  13. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  14. package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
  15. package/android/.gradle/checksums/checksums.lock +0 -0
  16. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  17. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  18. package/android/.gradle/configuration-cache/gc.properties +0 -0
  19. package/android/.project +28 -0
  20. package/android/.settings/org.eclipse.buildship.core.prefs +13 -0
  21. package/android/build.gradle +1 -1
  22. package/android/local.properties +8 -0
  23. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/JSONUtils.java +36 -2
  24. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ObjectMapper.java +5 -0
  25. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkConfiguration.java +37 -1
  26. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule.java +37 -20
  27. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewFragment.java +15 -1
  28. package/index.d.ts +7 -10
  29. package/ios/Components/BarcodeCameraView/RNScanbotBarcodeCameraView.h +1 -0
  30. package/ios/Components/BarcodeCameraView/RNScanbotBarcodeCameraView.m +14 -4
  31. package/ios/ScanbotBarcodeSdk.m +86 -16
  32. package/ios/Utils/BarcodeMapping.h +18 -1
  33. package/package.json +6 -3
  34. package/src/components/barcode-camera-view/scanbot-barcode-camera-view-types.tsx +121 -0
  35. package/src/components/barcode-camera-view/scanbot-barcode-camera-view.tsx +163 -0
  36. package/src/components/barcode-camera-view/scanbot-native-barcode-camera-view.tsx +6 -0
  37. package/src/configuration.ts +357 -300
  38. package/src/enum.ts +2 -0
  39. package/src/model.ts +38 -1
  40. package/android/.gradle/6.1.1/executionHistory/executionHistory.bin +0 -0
  41. package/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
  42. package/android/.gradle/6.1.1/fileHashes/fileHashes.bin +0 -0
  43. package/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
  44. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  45. package/android/.idea/caches/build_file_checksums.ser +0 -0
  46. package/android/.idea/compiler.xml +0 -6
  47. package/android/.idea/gradle.xml +0 -22
  48. package/android/.idea/jarRepositories.xml +0 -50
  49. package/android/.idea/libraries/Gradle__androidx_activity_activity_1_2_3_aar.xml +0 -16
  50. package/android/.idea/libraries/Gradle__androidx_annotation_annotation_1_2_0.xml +0 -11
  51. package/android/.idea/libraries/Gradle__androidx_annotation_annotation_experimental_1_1_0_rc01_aar.xml +0 -13
  52. package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_3_0_aar.xml +0 -16
  53. package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_3_0_aar.xml +0 -13
  54. package/android/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0.xml +0 -11
  55. package/android/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_1_0_aar.xml +0 -13
  56. package/android/.idea/libraries/Gradle__androidx_asynclayoutinflater_asynclayoutinflater_1_0_0_aar.xml +0 -13
  57. package/android/.idea/libraries/Gradle__androidx_camera_camera_camera2_1_0_0_aar.xml +0 -16
  58. package/android/.idea/libraries/Gradle__androidx_camera_camera_core_1_0_0_aar.xml +0 -16
  59. package/android/.idea/libraries/Gradle__androidx_camera_camera_lifecycle_1_0_0_aar.xml +0 -13
  60. package/android/.idea/libraries/Gradle__androidx_camera_camera_view_1_0_0_alpha24_aar.xml +0 -16
  61. package/android/.idea/libraries/Gradle__androidx_cardview_cardview_1_0_0_aar.xml +0 -13
  62. package/android/.idea/libraries/Gradle__androidx_collection_collection_1_1_0.xml +0 -11
  63. package/android/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_2_0_4_aar.xml +0 -11
  64. package/android/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_solver_2_0_4.xml +0 -9
  65. package/android/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml +0 -16
  66. package/android/.idea/libraries/Gradle__androidx_core_core_1_5_0_aar.xml +0 -16
  67. package/android/.idea/libraries/Gradle__androidx_core_core_ktx_1_3_2_aar.xml +0 -13
  68. package/android/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml +0 -13
  69. package/android/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml +0 -13
  70. package/android/.idea/libraries/Gradle__androidx_databinding_viewbinding_4_2_1_aar.xml +0 -13
  71. package/android/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml +0 -13
  72. package/android/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml +0 -16
  73. package/android/.idea/libraries/Gradle__androidx_dynamicanimation_dynamicanimation_1_0_0_aar.xml +0 -13
  74. package/android/.idea/libraries/Gradle__androidx_fragment_fragment_1_3_4_aar.xml +0 -16
  75. package/android/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml +0 -13
  76. package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_ui_1_0_0_aar.xml +0 -13
  77. package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml +0 -13
  78. package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_v4_1_0_0_aar.xml +0 -13
  79. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_3_1.xml +0 -11
  80. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_1_0_aar.xml +0 -13
  81. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_3_1_aar.xml +0 -13
  82. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_3_1_aar.xml +0 -13
  83. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_ktx_2_3_1_aar.xml +0 -13
  84. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_3_1_aar.xml +0 -13
  85. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_3_1_aar.xml +0 -13
  86. package/android/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml +0 -13
  87. package/android/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml +0 -13
  88. package/android/.idea/libraries/Gradle__androidx_media_media_1_0_0_aar.xml +0 -16
  89. package/android/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml +0 -16
  90. package/android/.idea/libraries/Gradle__androidx_recyclerview_recyclerview_1_1_0_aar.xml +0 -16
  91. package/android/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_1_0_aar.xml +0 -13
  92. package/android/.idea/libraries/Gradle__androidx_slidingpanelayout_slidingpanelayout_1_0_0_aar.xml +0 -13
  93. package/android/.idea/libraries/Gradle__androidx_swiperefreshlayout_swiperefreshlayout_1_0_0_aar.xml +0 -16
  94. package/android/.idea/libraries/Gradle__androidx_transition_transition_1_2_0_aar.xml +0 -16
  95. package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml +0 -13
  96. package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml +0 -13
  97. package/android/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_1_aar.xml +0 -13
  98. package/android/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml +0 -16
  99. package/android/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml +0 -13
  100. package/android/.idea/libraries/Gradle__com_commonsware_cwac_camera_camera_0_6_41_aar.xml +0 -11
  101. package/android/.idea/libraries/Gradle__com_facebook_fresco_drawee_2_0_0_aar.xml +0 -15
  102. package/android/.idea/libraries/Gradle__com_facebook_fresco_fbcore_2_0_0_aar.xml +0 -18
  103. package/android/.idea/libraries/Gradle__com_facebook_fresco_fresco_2_0_0_aar.xml +0 -18
  104. package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_2_0_0_aar.xml +0 -18
  105. package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_base_2_0_0_aar.xml +0 -18
  106. package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp3_2_0_0_aar.xml +0 -15
  107. package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagefilters_2_0_0_aar.xml +0 -15
  108. package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagetranscoder_2_0_0_aar.xml +0 -15
  109. package/android/.idea/libraries/Gradle__com_facebook_infer_annotation_infer_annotation_0_11_2.xml +0 -13
  110. package/android/.idea/libraries/Gradle__com_facebook_react_react_native_0_60_6_aar.xml +0 -18
  111. package/android/.idea/libraries/Gradle__com_facebook_soloader_soloader_0_6_0_aar.xml +0 -13
  112. package/android/.idea/libraries/Gradle__com_google_android_material_material_1_3_0_aar.xml +0 -16
  113. package/android/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2.xml +0 -13
  114. package/android/.idea/libraries/Gradle__com_google_code_gson_gson_2_8_6.xml +0 -13
  115. package/android/.idea/libraries/Gradle__com_google_dagger_dagger_2_35.xml +0 -13
  116. package/android/.idea/libraries/Gradle__com_google_guava_listenablefuture_1_0.xml +0 -13
  117. package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_3_12_1.xml +0 -13
  118. package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_urlconnection_3_12_1.xml +0 -13
  119. package/android/.idea/libraries/Gradle__com_squareup_okio_okio_1_15_0.xml +0 -13
  120. package/android/.idea/libraries/Gradle__commons_io_commons_io_2_4.xml +0 -13
  121. package/android/.idea/libraries/Gradle__io_reactivex_rxjava2_rxandroid_2_0_1_aar.xml +0 -15
  122. package/android/.idea/libraries/Gradle__io_reactivex_rxjava2_rxjava_2_1_5.xml +0 -13
  123. package/android/.idea/libraries/Gradle__io_scanbot_scanbot_barcode_scanner_sdk_3_0_1_aar.xml +0 -11
  124. package/android/.idea/libraries/Gradle__io_scanbot_scanbot_barcode_scanner_sdk_ui_3_0_1_aar.xml +0 -11
  125. package/android/.idea/libraries/Gradle__io_scanbot_scanbot_sdk_barcode_3_0_1_aar.xml +0 -11
  126. package/android/.idea/libraries/Gradle__io_scanbot_scanbot_sdk_base_3_0_1_aar.xml +0 -11
  127. package/android/.idea/libraries/Gradle__io_scanbot_scanbot_sdk_ui_barcode_3_0_1_aar.xml +0 -11
  128. package/android/.idea/libraries/Gradle__io_scanbot_scanbot_sdk_ui_base_3_0_1_aar.xml +0 -11
  129. package/android/.idea/libraries/Gradle__io_scanbot_sdk_barcode_assets_3_0_1_aar.xml +0 -11
  130. package/android/.idea/libraries/Gradle__io_scanbot_sdk_core_barcode_3_0_1_aar.xml +0 -11
  131. package/android/.idea/libraries/Gradle__io_scanbot_sdk_core_barcode_native_3_0_1_aar.xml +0 -11
  132. package/android/.idea/libraries/Gradle__io_scanbot_sdk_core_sap_3_0_1_aar.xml +0 -11
  133. package/android/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml +0 -13
  134. package/android/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml +0 -13
  135. package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_4_20.xml +0 -13
  136. package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_4_20.xml +0 -13
  137. package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_4_20.xml +0 -13
  138. package/android/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_android_1_4_1.xml +0 -13
  139. package/android/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_core_jvm_1_4_1.xml +0 -13
  140. package/android/.idea/libraries/Gradle__org_reactivestreams_reactive_streams_1_0_1.xml +0 -13
  141. package/android/.idea/misc.xml +0 -9
  142. package/android/.idea/modules/android.iml +0 -133
  143. package/android/.idea/modules.xml +0 -8
  144. package/android/.idea/vcs.xml +0 -6
  145. package/android/.idea/workspace.xml +0 -62
@@ -24,6 +24,8 @@ void runInBackground(void (^function)(void)) {
24
24
 
25
25
  @implementation ScanbotBarcodeSdk
26
26
 
27
+ static UIViewController* activeViewController = nil;
28
+
27
29
  RCT_EXPORT_MODULE()
28
30
 
29
31
  // Necessary so that the start* methods get called on the UI thread.
@@ -45,7 +47,17 @@ RCT_EXPORT_METHOD(initializeSdk:(NSDictionary *)configuration
45
47
  @"engineMode": @{
46
48
  @"LEGACY": @(SBSDKBarcodeEngineModeLegacy),
47
49
  @"NEXT_GEN": @(SBSDKBarcodeEngineModeNextGen)
48
- }
50
+ },
51
+ @"allowedInterfaceOrientations": @{
52
+ @"NONE": @(UIInterfaceOrientationMaskAll),
53
+ @"PORTRAIT": @(UIInterfaceOrientationMaskPortrait),
54
+ @"PORTRAIT_UPSIDE_DOWN": @(UIInterfaceOrientationMaskPortraitUpsideDown),
55
+ @"LANDSCAPE_LEFT": @(UIInterfaceOrientationMaskLandscapeLeft),
56
+ @"LANDSCAPE_RIGHT": @(UIInterfaceOrientationMaskLandscapeRight),
57
+ @"LANDSCAPE": @(UIInterfaceOrientationMaskLandscape),
58
+ @"ALL": @(UIInterfaceOrientationMaskAll),
59
+ @"ALL_BUT_UPSIDE_DOWN": @(UIInterfaceOrientationMaskAllButUpsideDown)
60
+ },
49
61
  }];
50
62
 
51
63
  // map config parameters and normalize some fields
@@ -121,11 +133,11 @@ RCT_EXPORT_METHOD(startBarcodeScanner:(NSDictionary*)configuration
121
133
  return;
122
134
  }
123
135
 
124
- // Need to manully extract because of naming disparity between iOS and Android
125
- // Also, it is nullable, 'true' by default, so wrap it in an NSNumber
136
+ // Need to manually extract because of naming disparity between iOS and Android
137
+ // Also, it is nullable, 'true' by default, so we wrap it in an NSNumber
126
138
  NSNumber* gs1Decoding = [configuration objectForKey:@"gs1DecodingEnabled"];
127
139
  if (gs1Decoding != nil) {
128
- additionalParameters.enableGS1Decoding = gs1Decoding;
140
+ additionalParameters.enableGS1Decoding = [gs1Decoding boolValue];
129
141
  }
130
142
 
131
143
  additionalParameters.msiPlesseyChecksumAlgorithm = extractPlesseyChecksumAlgorithmFromConfiguration(configuration);
@@ -137,7 +149,10 @@ RCT_EXPORT_METHOD(startBarcodeScanner:(NSDictionary*)configuration
137
149
 
138
150
  SBSDKUIBarcodeScannerConfiguration* config = [[SBSDKUIBarcodeScannerConfiguration alloc] initWithUIConfiguration:uiConfig textConfiguration:textConfig behaviorConfiguration:behaviorConfig];
139
151
 
140
- uiConfig.allowedInterfaceOrientations = [ObjectMapper orientationLockModeToUIInterfaceOrientationMask:configuration];
152
+ SBSDKUICameraConfiguration* cameraConfiguration = extractCameraConfiguration(configuration);
153
+ if (cameraConfiguration) {
154
+ config.cameraConfiguration.camera = cameraConfiguration.camera;
155
+ }
141
156
 
142
157
  bool shouldWaitForGeneratedImage = behaviorConfig.barcodeImageGenerationType != SBSDKBarcodeImageGenerationTypeNone;
143
158
  BarcodeScannerPromiseProxy* delegate = [[BarcodeScannerPromiseProxy alloc] initWithResolver: resolve
@@ -151,9 +166,13 @@ RCT_EXPORT_METHOD(startBarcodeScanner:(NSDictionary*)configuration
151
166
  viewController = [SBSDKUIBarcodeScannerViewController createNewWithAcceptedMachineCodeTypes:machineCodeTypes configuration:config andDelegate:delegate];
152
167
  }
153
168
 
154
- [viewController setModalPresentationStyle:UIModalPresentationFullScreen];
155
- UIViewController* rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
156
- [rootViewController presentViewController:viewController animated:true completion:nil];
169
+ [self presentActiveViewController:viewController];
170
+ }
171
+
172
+ RCT_EXPORT_METHOD(closeBarcodeScanner:(RCTPromiseResolveBlock)resolve
173
+ failure:(RCTPromiseRejectBlock)reject) {
174
+ [self dismissActiveViewController: [SBSDKUIBarcodeScannerViewController class]];
175
+ resolve(nil);
157
176
  }
158
177
 
159
178
  RCT_EXPORT_METHOD(startBatchBarcodeScanner:(NSDictionary*)configuration
@@ -179,28 +198,52 @@ RCT_EXPORT_METHOD(startBatchBarcodeScanner:(NSDictionary*)configuration
179
198
  }
180
199
 
181
200
  // Need to manully extract because of naming disparity between iOS and Android
182
- // Also, it is nullable, 'true' by default, so wrap it in an NSNumber
201
+ // Also, it is nullable, 'true' by default, so we wrap it in an NSNumber
183
202
  NSNumber* gs1Decoding = [configuration objectForKey:@"gs1DecodingEnabled"];
184
203
  if (gs1Decoding != nil) {
185
- additionalParameters.enableGS1Decoding = gs1Decoding;
204
+ additionalParameters.enableGS1Decoding = [gs1Decoding boolValue];
186
205
  }
187
206
 
188
207
  additionalParameters.msiPlesseyChecksumAlgorithm = extractPlesseyChecksumAlgorithmFromConfiguration(configuration);
189
208
 
190
209
  behavior.additionalDetectionParameters = additionalParameters;
191
210
 
192
- SBSDKUIBarcodesBatchScannerConfiguration *config = [[SBSDKUIBarcodesBatchScannerConfiguration alloc] initWithUIConfiguration:ui textConfiguration:text behaviorConfiguration:behavior];
211
+ SBSDKUIBarcodesBatchScannerConfiguration *config = [[SBSDKUIBarcodesBatchScannerConfiguration alloc]
212
+ initWithUIConfiguration:ui
213
+ textConfiguration:text
214
+ behaviorConfiguration:behavior];
193
215
 
194
216
  NSArray* machineCodeTypes = extractBarcodeTypesFromConfiguration(configuration);
217
+ NSArray* acceptedDocumentTypes = extractBarcodeDocumentTypesFromConfiguration(configuration);
218
+
219
+ SBSDKUICameraConfiguration* cameraConfiguration = extractCameraConfiguration(configuration);
220
+ if (cameraConfiguration) {
221
+ config.cameraConfiguration.camera = cameraConfiguration.camera;
222
+ }
223
+
195
224
  BatchBarcodeScannerPromiseProxy* delegate = [[BatchBarcodeScannerPromiseProxy alloc] initWithResolver:resolve];
196
- SBSDKUIBarcodesBatchScannerViewController* controller =
197
- [SBSDKUIBarcodesBatchScannerViewController createNewWithAcceptedMachineCodeTypes: machineCodeTypes configuration:config andDelegate:delegate];
225
+
226
+ SBSDKUIBarcodesBatchScannerViewController* viewController = NULL;
227
+
228
+ if (acceptedDocumentTypes && acceptedDocumentTypes.count > 0) {
229
+ viewController = [SBSDKUIBarcodesBatchScannerViewController createNewWithAcceptedMachineCodeTypes:machineCodeTypes
230
+ withAcceptedDocumentTypes:acceptedDocumentTypes
231
+ configuration:config
232
+ andDelegate:delegate];
233
+ } else {
234
+ viewController = [SBSDKUIBarcodesBatchScannerViewController createNewWithAcceptedMachineCodeTypes:machineCodeTypes
235
+ configuration:config
236
+ andDelegate:delegate];
237
+ }
198
238
 
199
- [controller setModalPresentationStyle:UIModalPresentationFullScreen];
200
- UIViewController* rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
201
- [rootViewController presentViewController:controller animated:true completion:nil];
239
+ [self presentActiveViewController:viewController];
202
240
  }
203
241
 
242
+ RCT_EXPORT_METHOD(closeBatchBarcodeScanner:(RCTPromiseResolveBlock)resolve
243
+ failure:(RCTPromiseRejectBlock)reject) {
244
+ [self dismissActiveViewController: [SBSDKUIBarcodesBatchScannerViewController class]];
245
+ resolve(nil);
246
+ }
204
247
 
205
248
  RCT_EXPORT_METHOD(detectBarcodesOnImage:(NSDictionary *)configuration
206
249
  resolve:(RCTPromiseResolveBlock)resolve
@@ -334,6 +377,33 @@ RCT_EXPORT_METHOD(cleanup:(RCTPromiseResolveBlock)resolve
334
377
  return nil;
335
378
  }
336
379
 
380
+ - (void) presentActiveViewController:(UIViewController*) viewController {
381
+ if (!viewController) {
382
+ return;
383
+ }
384
+
385
+ UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
386
+ [viewController setModalPresentationStyle:UIModalPresentationFullScreen];
387
+ [rootViewController presentViewController:viewController animated:YES completion:nil];
388
+
389
+ activeViewController = viewController;
390
+ }
391
+
392
+ - (_Bool) dismissActiveViewController:(Class _Nullable)vcClass {
393
+ if (!activeViewController) {
394
+ return false;
395
+ }
396
+
397
+ if (vcClass && ![activeViewController isKindOfClass:vcClass]) {
398
+ return false;
399
+ }
400
+
401
+ [activeViewController dismissViewControllerAnimated:true completion:nil];
402
+ activeViewController = nil;
403
+
404
+ return true;
405
+ }
406
+
337
407
  @end
338
408
 
339
409
  /// Barcode Scanner Delegate
@@ -128,9 +128,9 @@ static inline SBSDKBarcodeMSIPlesseyChecksumAlgorithm extractPlesseyChecksumAlgo
128
128
  if (algorithm != nil) {
129
129
  if ([algorithm isEqualToString:@"None"]) return SBSDKBarcodeMSIPlesseyChecksumAlgorithmNone;
130
130
  if ([algorithm isEqualToString:@"Mod10"]) return SBSDKBarcodeMSIPlesseyChecksumAlgorithmMod10;
131
+ if ([algorithm isEqualToString:@"Mod1010"]) return SBSDKBarcodeMSIPlesseyChecksumAlgorithmMod1010;
131
132
  if ([algorithm isEqualToString:@"Mod11IBM"]) return SBSDKBarcodeMSIPlesseyChecksumAlgorithmMod11IBM;
132
133
  if ([algorithm isEqualToString:@"Mod11NCR"]) return SBSDKBarcodeMSIPlesseyChecksumAlgorithmMod11NCR;
133
- if ([algorithm isEqualToString:@"Mod1010"]) return SBSDKBarcodeMSIPlesseyChecksumAlgorithmMod1010;
134
134
  if ([algorithm isEqualToString:@"Mod1110IBM"]) return SBSDKBarcodeMSIPlesseyChecksumAlgorithmMod1110IBM;
135
135
  if ([algorithm isEqualToString:@"Mod1110NCR"]) return SBSDKBarcodeMSIPlesseyChecksumAlgorithmMod1110NCR;
136
136
  }
@@ -138,4 +138,21 @@ static inline SBSDKBarcodeMSIPlesseyChecksumAlgorithm extractPlesseyChecksumAlgo
138
138
  return SBSDKBarcodeMSIPlesseyChecksumAlgorithmMod10;
139
139
  }
140
140
 
141
+ static inline SBSDKUICameraConfiguration* extractCameraConfiguration(NSDictionary* configuration) {
142
+ SBSDKUICameraConfiguration* cameraConfiguration = [[SBSDKUICameraConfiguration alloc] init];
143
+
144
+ NSString* cameraModule = [configuration objectForKey:@"cameraModule"];
145
+ if(!cameraModule) {
146
+ return nil;
147
+ }
148
+
149
+ if ([cameraModule isEqualToString:@"FRONT"]) {
150
+ cameraConfiguration.camera = SBSDKCameraDevice.defaultFrontFacingCamera;
151
+ } else if ([cameraModule isEqualToString:@"BACK"]) {
152
+ cameraConfiguration.camera = SBSDKCameraDevice.defaultBackFacingCamera;
153
+ }
154
+
155
+ return cameraConfiguration;
156
+ }
157
+
141
158
  #endif /* BarcodeMapping_h */
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "react-native-scanbot-barcode-scanner-sdk",
3
3
  "title": "Scanbot Barcode Scanner SDK for React Native",
4
- "version": "3.1.0-alpha1",
4
+ "version": "3.1.0-beta10",
5
5
  "description": "React Native plugin for the Scanbot Barcode Scanner SDK on Android and iOS",
6
6
  "main": "index.js",
7
7
  "files": [
8
8
  "src/*.js",
9
9
  "src/*.ts",
10
+ "src/components/**/*.ts",
11
+ "src/components/**/*.tsx",
12
+ "src/components/**/*.js",
10
13
  "android/**",
11
14
  "ios/**",
12
15
  "index.d.ts",
@@ -43,8 +46,8 @@
43
46
  "react-native": ">=0.60 <1.0.x"
44
47
  },
45
48
  "devDependencies": {
46
- "react": "^16.8.3",
47
- "react-native": "^0.60"
49
+ "react": "^17.0.2",
50
+ "react-native": "^0.65"
48
51
  },
49
52
  "contributors": [
50
53
  {
@@ -0,0 +1,121 @@
1
+ import { StyleProp, ViewStyle } from 'react-native';
2
+ import {
3
+ BarcodeDocumentFormat,
4
+ BarcodeFormat,
5
+ EngineMode,
6
+ MSIPlesseyChecksumAlgorithm,
7
+ } from '../../enum';
8
+ import { FinderAspectRatio } from '../../model';
9
+
10
+ export interface ScanbotBarcodeCameraViewProperties {
11
+ onBarcodeScannerResult?: (result: ScanbotBarcodeCameraViewResult) => void;
12
+ requestComponentReload?: () => void;
13
+ configuration?: ScanbotBarcodeCameraViewConfiguration;
14
+ style: StyleProp<ViewStyle>;
15
+ }
16
+
17
+ export interface ScanbotBarcodeCameraViewBarcode {
18
+ text: string;
19
+ type: string;
20
+ }
21
+
22
+ export type ScanbotBarcodeCameraViewResult = {
23
+ status: 'OK' | 'CANCELED';
24
+ barcodes: ScanbotBarcodeCameraViewBarcode[];
25
+ };
26
+
27
+ export interface ScanbotBarcodeCameraViewConfiguration {
28
+ /**
29
+ * The finder view is a rectangular overlay view that clips the camera view,
30
+ * so that the detection will focus just a specific area. You can specify
31
+ * the size and positioning, as well as other UI properties.
32
+ * Set this property to `true` if you want to use the Finder View, `false` otherwise (default: false)
33
+ */
34
+ shouldUseFinderView?: boolean;
35
+ /**
36
+ * The finder view rectangular overlay border width
37
+ */
38
+ finderLineWidth?: number;
39
+ /**
40
+ * The finder view rectangular overlay border color
41
+ */
42
+ finderLineColor?: string;
43
+ /**
44
+ * The overlay background color, around the finder view rectangle
45
+ */
46
+ finderBackgroundColor?: string;
47
+ /**
48
+ * The overlay background color opacity, around the finder view rectangle
49
+ */
50
+ finderBackgroundOpacity?: number;
51
+ /**
52
+ * The finder view rectangle aspect ratio
53
+ */
54
+ finderAspectRatio?: FinderAspectRatio;
55
+ /**
56
+ * The finder view minimum padding from the bounds of the screen
57
+ */
58
+ finderMinimumPadding?: number;
59
+ /**
60
+ * How many pixel units the finder view should be moved vertically;
61
+ *
62
+ * Positive values -> (UP); Negative values -> (DOWN)
63
+ */
64
+ finderVerticalOffset?: number;
65
+ /**
66
+ * Whether flash is toggled on or off.
67
+ */
68
+ flashEnabled?: boolean;
69
+ /**
70
+ * List of accepted Barcode Formats; any formats that are not included in this
71
+ * list will not be detected by the `BarcodeCameraView`. By default, the list
72
+ * includes all supported barcode types.
73
+ */
74
+ barcodeFormats?: BarcodeFormat[];
75
+ /**
76
+ * List of accepted Document Formats; any document formats that are not included
77
+ * in this list will be ignored by the `BarcodeCameraView`. By default, the list
78
+ * includes all supported document types.
79
+ */
80
+ acceptedDocumentFormats?: BarcodeDocumentFormat[];
81
+ /**
82
+ * The checksum algorithm for MSI Plessey barcodes.
83
+ * The default value is `Mod10'
84
+ */
85
+ msiPlesseyChecksumAlgorithm?: MSIPlesseyChecksumAlgorithm;
86
+ /**
87
+ * The engine mode of the barcode recognizer. Defaults to NEXT_GEN.
88
+ * To use legacy recognizer, please specify LEGACY
89
+ */
90
+ engineMode?: EngineMode;
91
+ /**
92
+ * The relative initial zoom level of the camera in the range [0,1], where 0 is zoomed out and 1 is zoomed in.
93
+ * The default value is 0.
94
+ */
95
+ cameraZoomFactor?: number;
96
+ /**
97
+ * When set to `true`, the scanner assumes that the barcode can be a GS1 barcode.
98
+ * Turn it off, if you don't want to see decoded FNC1 characters ("]C1" and ASCII char 29).
99
+ * The default value is `true`.
100
+ * NOTE: Currently works for CODE128 barcodes only.
101
+ */
102
+ gs1DecodingEnabled?: boolean;
103
+ /**
104
+ * Optional minimum required text length of the detected barcode.
105
+ * The default is 0 (setting is turned off).
106
+ * NOTE: This feature works on ITF barcodes only.
107
+ */
108
+ minimumTextLength?: number;
109
+ /**
110
+ * Optional maximum required text length of the detected barcode.
111
+ * The default is 0 (setting is turned off).
112
+ * NOTE: This feature works on ITF barcodes only.
113
+ */
114
+ maximumTextLength?: number;
115
+ /**
116
+ * With this option enabled, the scanner removes checks digits for UPC, EAN and MSI Plessey codes.
117
+ * Has no effect if both single and double digit MSI Plessey checksums are enabled.
118
+ * The default is `false`
119
+ */
120
+ stripCheckDigits?: boolean;
121
+ }
@@ -0,0 +1,163 @@
1
+ import React from 'react';
2
+ import {Platform} from 'react-native';
3
+ import {Dimensions} from 'react-native';
4
+ import {ScanbotBarcodeCameraViewProperties} from './scanbot-barcode-camera-view-types';
5
+ import ScanbotNativeBarcodeCameraView from './scanbot-native-barcode-camera-view';
6
+
7
+ const Device = {
8
+ isPortrait: () => {
9
+ const dim = Dimensions.get('screen');
10
+ return dim.height >= dim.width;
11
+ },
12
+ isLandscape: () => {
13
+ const dim = Dimensions.get('screen');
14
+ return dim.width >= dim.height;
15
+ },
16
+ };
17
+
18
+ interface ScanbotBarcodeCameraViewState {
19
+ orientation: string;
20
+ }
21
+
22
+ type Properties = ScanbotBarcodeCameraViewProperties;
23
+ export class ScanbotBarcodeCameraView extends React.Component<Properties, {}> {
24
+ // String length of auto-generated component key
25
+ static UNIQUE_VIEW_KEY_LENGTH = 6;
26
+
27
+ // This attribute allows us to retrieve a key for the component depending on the current state.
28
+ // If the component has been invalidated, it returns a new key and the view gets recreated,
29
+ // otherwise it uses the last generated one
30
+ _cameraKey = '';
31
+ get cameraKey(): string {
32
+ if (!this.isDirty) {
33
+ return this._cameraKey;
34
+ }
35
+ this.isDirty = false;
36
+ this._cameraKey = ScanbotBarcodeCameraView.getRandomId(
37
+ ScanbotBarcodeCameraView.UNIQUE_VIEW_KEY_LENGTH,
38
+ );
39
+ return this._cameraKey;
40
+ }
41
+
42
+ // We keep track of the state of children components, so that we can re-render the component
43
+ // in some special cases (Android)
44
+ previousChildrenIds: string[] = [];
45
+ get childrenIds(): string[] {
46
+ const children = this.props.children
47
+ ? React.Children.map(this.props.children, child => child)
48
+ : [];
49
+
50
+ return children?.map((c: any) => `${c.type.name}-${c.key}`) ?? [];
51
+ }
52
+
53
+ // When true, a new component key will be generated on the next render,
54
+ // causing the component to be recreated
55
+ isDirty = true;
56
+
57
+ state: ScanbotBarcodeCameraViewState = {
58
+ orientation: Device.isPortrait() ? 'portrait' : 'landscape',
59
+ };
60
+
61
+ // Returns a random string ID of the given length
62
+ static getRandomId(
63
+ length: number = ScanbotBarcodeCameraView.UNIQUE_VIEW_KEY_LENGTH,
64
+ ): string {
65
+ let result = '';
66
+ const characters =
67
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
68
+ const charactersLength = characters.length;
69
+ for (let i = 0; i < length; i++) {
70
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
71
+ }
72
+ return result;
73
+ }
74
+
75
+ // Event Listener for orientation changes
76
+ orientationChangeHandler = () => {
77
+ this.isDirty = true;
78
+ this.setState({
79
+ orientation: Device.isPortrait() ? 'portrait' : 'landscape',
80
+ });
81
+ };
82
+
83
+ // Maps the native bridge callback event from the Barcode Scanner
84
+ _onBarcodeScannerResult = (event: any) => {
85
+ if (!this.props.onBarcodeScannerResult) {
86
+ return;
87
+ }
88
+
89
+ this.props.onBarcodeScannerResult(event.nativeEvent.result);
90
+ };
91
+
92
+ render() {
93
+ this.evaluateComponentState();
94
+
95
+ const style = this.preprocessStyle();
96
+ const props = this.preprocessProps();
97
+
98
+ return (
99
+ <ScanbotNativeBarcodeCameraView
100
+ {...props}
101
+ style={style}
102
+ key={this.cameraKey}
103
+ requestComponentReload={this._invalidate}
104
+ onBarcodeScannerResult={this._onBarcodeScannerResult}
105
+ />
106
+ );
107
+ }
108
+
109
+ componentDidMount() {
110
+ Dimensions.addEventListener('change', this.orientationChangeHandler);
111
+ this.previousChildrenIds = this.childrenIds;
112
+ }
113
+
114
+ componentWillUnmount() {
115
+ Dimensions.removeEventListener('change', this.orientationChangeHandler);
116
+ this.previousChildrenIds = [];
117
+ }
118
+
119
+ evaluateComponentState = () => {
120
+ // We want to force a re-layout every time new children are added or removed
121
+ // from the BarcodeCameraView on Android; this will allow the native code to
122
+ // re-compute the size of every view inside the layout
123
+ if (Platform.OS === 'android') {
124
+ const currentChildrenIds = this.childrenIds;
125
+
126
+ const invalidate = () => {
127
+ this._invalidate();
128
+ this.previousChildrenIds = currentChildrenIds;
129
+ };
130
+ if (currentChildrenIds.length !== this.previousChildrenIds.length) {
131
+ invalidate();
132
+ return;
133
+ }
134
+
135
+ for (let i = 0; i < this.previousChildrenIds.length; i++) {
136
+ const previous = this.previousChildrenIds[i];
137
+ const current = currentChildrenIds[i];
138
+ if (previous !== current) {
139
+ invalidate();
140
+ return;
141
+ }
142
+ }
143
+ }
144
+ };
145
+
146
+ preprocessStyle = () => {
147
+ const style = this.props.style as any;
148
+ const newStyle = {...style} || {};
149
+ // Override / Define styles here
150
+ return newStyle;
151
+ };
152
+
153
+ preprocessProps = () => {
154
+ const props = {...this.props};
155
+ delete props.style;
156
+ return props;
157
+ };
158
+
159
+ // Invalidates the component so that it gets recreated on the next render
160
+ _invalidate = () => {
161
+ this.isDirty = true;
162
+ };
163
+ }
@@ -0,0 +1,6 @@
1
+ import {requireNativeComponent} from 'react-native';
2
+ import {ScanbotBarcodeCameraViewProperties} from './scanbot-barcode-camera-view-types';
3
+
4
+ export default requireNativeComponent<ScanbotBarcodeCameraViewProperties>(
5
+ 'ScanbotBarcodeCameraView',
6
+ );