react-native-scanbot-barcode-scanner-sdk 3.7.0 → 3.7.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.
- package/RNScanbotBarcodeSDK.podspec +12 -9
- package/android/build.gradle +31 -27
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/reactlibrary/ScanbotBarcodeSdkModule.java +5 -12
- package/android/src/main/java/com/reactlibrary/ScanbotBarcodeSdkPackage.java +2 -2
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ObjectMapper.java +24 -17
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkConfiguration.java +5 -2
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule.java +92 -84
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkPackage.java +1 -2
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/StorageUtils.java +5 -69
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/barcode/ScanbotBarcodeDetectorAdditionalConfigBuilder.java +1 -1
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/barcode/ScanbotBarcodeDetectorConfigBuilder.java +1 -1
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraView.java +9 -15
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewConfiguration.java +6 -5
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/communication/ScanbotEventEmitter.java +5 -3
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/communication/ScanbotEventReceiver.java +15 -4
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/JSONUtils.java +29 -40
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/LogUtils.java +4 -1
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/ResponseUtils.java +2 -10
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/ScanbotViewUtils.java +0 -17
- package/android/src/new-architecture/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager.java +127 -0
- package/android/src/{main/java → old-architecture}/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager.java +1 -1
- package/index.js +1 -1
- package/ios/Categories/SBSDKPolygon+JSON.h +1 -1
- package/ios/Categories/SBSDKPolygon+JSON.m +1 -1
- package/ios/Categories/UIColor+JSON.h +1 -1
- package/ios/Categories/UIColor+JSON.m +1 -1
- package/ios/Components/BarcodeCameraView/NewArchitecture/RTNScanbotBarcodeCameraView.h +45 -0
- package/ios/Components/BarcodeCameraView/NewArchitecture/RTNScanbotBarcodeCameraView.mm +364 -0
- package/ios/Components/BarcodeCameraView/NewArchitecture/RTNScanbotBarcodeCameraViewManager.mm +71 -0
- package/ios/Components/BarcodeCameraView/{RNScanbotBarcodeCameraView.h → OldArchitecture/RNScanbotBarcodeCameraView.h} +9 -4
- package/ios/Components/BarcodeCameraView/{RNScanbotBarcodeCameraView.m → OldArchitecture/RNScanbotBarcodeCameraView.mm} +24 -34
- package/ios/Components/BarcodeCameraView/{RNScanbotBarcodeCameraViewManager.h → OldArchitecture/RNScanbotBarcodeCameraViewManager.h} +7 -1
- package/ios/Components/BarcodeCameraView/{RNScanbotBarcodeCameraViewManager.m → OldArchitecture/RNScanbotBarcodeCameraViewManager.mm} +25 -6
- package/ios/ScanbotBarcodeSDKConfiguration.h +1 -1
- package/ios/ScanbotBarcodeSDKConfiguration.m +1 -1
- package/ios/ScanbotBarcodeSdk.h +2 -2
- package/ios/ScanbotBarcodeSdk.m +24 -23
- package/ios/SharedConfiguration.h +1 -1
- package/ios/SharedConfiguration.m +1 -1
- package/ios/Utils/BarcodeMapping.h +40 -33
- package/ios/Utils/HashUtils.h +1 -1
- package/ios/Utils/JSONMappings.h +1 -1
- package/ios/Utils/LoggingUtils.h +1 -1
- package/ios/Utils/ObjectMapper.h +1 -1
- package/ios/Utils/ObjectMapper.m +1 -1
- package/ios/Utils/ReactBarcodeExtensionsFilter.h +1 -1
- package/ios/Utils/ScanbotStorageUtils.h +1 -1
- package/ios/Utils/ScanbotStorageUtils.m +1 -1
- package/js/RTNScanbotBarcodeCameraViewNativeComponent.tsx +209 -0
- package/package.json +22 -2
- package/src/components/barcode-camera-view/scanbot-barcode-camera-view-types.tsx +8 -1
- package/src/components/barcode-camera-view/scanbot-barcode-camera-view.tsx +46 -12
- package/src/components/barcode-camera-view/scanbot-native-barcode-camera-view.tsx +7 -5
- package/src/configuration.ts +4 -1
- package/src/enum.ts +1 -1
- package/android/.gradle/6.1.1/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.1.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/6.1.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/6.1.1/gc.properties +0 -0
- package/android/.gradle/6.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/6.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/6.2/gc.properties +0 -0
- package/android/.gradle/6.8/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.8/fileChanges/last-build.bin +0 -0
- package/android/.gradle/6.8/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/6.8/gc.properties +0 -0
- package/android/.gradle/7.0-rc-1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.0-rc-1/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.0-rc-1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.0-rc-1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.0-rc-1/gc.properties +0 -0
- package/android/.gradle/7.1.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.1.1/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.1.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.1.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.1.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.1.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/configuration-cache/gc.properties +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build/.transforms/8cdb68f56773f65afa4976aa86d988f7/classes/classes.dex +0 -0
- package/android/build/.transforms/8cdb68f56773f65afa4976aa86d988f7.bin +0 -1
- package/android/build/.transforms/991094845a707011dcf91007d9838bb7/classes/classes.dex +0 -0
- package/android/build/.transforms/991094845a707011dcf91007d9838bb7.bin +0 -1
- package/android/build/generated/source/buildConfig/debug/io/scanbot/barcodesdk/plugin/reactnative/BuildConfig.java +0 -18
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -11
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output.json +0 -1
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
- package/android/build/intermediates/compile_library_classes/debug/classes.jar +0 -0
- package/android/build/intermediates/compile_only_not_namespaced_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/incremental/debug-mergeNativeLibs/merge-state +0 -0
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +0 -2
- package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +0 -4
- package/android/build/intermediates/incremental/packageDebugResources/merger.xml +0 -2
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/ScanbotBarcodeSdkModule.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/reactlibrary/ScanbotBarcodeSdkPackage.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/BitmapHelper.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/JSONUtils$WritableMapBuilder.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/JSONUtils.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/LogUtils.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ObjectMapper.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ReactBarcodeExtensionsFilter$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ReactBarcodeExtensionsFilter$Type.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ReactBarcodeExtensionsFilter.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ResponseUtils.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkConfiguration.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule$3.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkPackage.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/StorageUtils.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/barcode/ScanbotBarcodeDetectorAdditionalConfigBuilder.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/barcode/ScanbotBarcodeDetectorConfigBuilder.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/EventEmitter$NativeEvent.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/EventEmitter.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewConfiguration.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewFragment$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewFragment$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewFragment.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager$1$1$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager$1$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentFrameLayout$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentFrameLayout$ILayoutChangeListener.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentFrameLayout.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentRootView$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentRootView$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentRootView$ILayoutChangeListener.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentRootView$IOnChildRemovedListener.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentRootView.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/filters/ReactBarcodeExtensionsFilter$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/filters/ReactBarcodeExtensionsFilter$Type.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/filters/ReactBarcodeExtensionsFilter.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/utils/BitmapHelper.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/utils/JSONUtils$WritableMapBuilder.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/utils/JSONUtils.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/utils/LogUtils.class +0 -0
- package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/utils/ResponseUtils.class +0 -0
- package/android/build/intermediates/library_java_res/debug/res.jar +0 -0
- package/android/build/intermediates/library_manifest/debug/AndroidManifest.xml +0 -11
- package/android/build/intermediates/local_only_symbol_list/debug/parseDebugLibraryResources/R-def.txt +0 -9
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -13
- package/android/build/intermediates/merged_manifests/debug/output.json +0 -1
- package/android/build/intermediates/packaged_res/debug/drawable/ic_baseline_arrow_back_24.xml +0 -10
- package/android/build/intermediates/packaged_res/debug/layout/component_barcode_camera_view.xml +0 -11
- package/android/build/intermediates/packaged_res/debug/layout/fragment_barcode_scanner.xml +0 -23
- package/android/build/intermediates/res/symbol-table-with-package/debug/package-aware-r.txt +0 -3560
- package/android/build/intermediates/runtime_library_classes/debug/classes.jar +0 -0
- package/android/build/intermediates/symbols/debug/R.txt +0 -5107
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -37
- package/android/local.properties +0 -8
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ReactBarcodeExtensionsFilter.java +0 -61
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/BitmapHelper.java +0 -30
- package/ios/ScanbotBarcodeSdk.xcodeproj/xcuserdata/mayankpatil.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/ios/ScanbotBarcodeSdk.xcworkspace/xcuserdata/mayankpatil.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
package io.scanbot.barcodesdk.plugin.reactnative.components.barcodecameraview;
|
|
2
|
+
|
|
3
|
+
import android.util.Log;
|
|
4
|
+
|
|
5
|
+
import androidx.annotation.NonNull;
|
|
6
|
+
import androidx.annotation.Nullable;
|
|
7
|
+
|
|
8
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
9
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
10
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
11
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
12
|
+
import com.facebook.react.uimanager.ViewGroupManager;
|
|
13
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
14
|
+
import com.facebook.react.viewmanagers.RTNScanbotBarcodeCameraViewManagerInterface;
|
|
15
|
+
|
|
16
|
+
import java.util.Map;
|
|
17
|
+
|
|
18
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.base.communication.ScanbotEventEmitter;
|
|
19
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.base.communication.ScanbotEventEmitter.NativeEvent;
|
|
20
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.base.communication.ScanbotEventReceiver;
|
|
21
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.base.communication.ScanbotEventReceiver.CommonEvents;
|
|
22
|
+
|
|
23
|
+
@ReactModule(name = ScanbotBarcodeCameraViewManager.NAME)
|
|
24
|
+
public class ScanbotBarcodeCameraViewManager
|
|
25
|
+
extends ViewGroupManager<ScanbotBarcodeCameraView>
|
|
26
|
+
implements RTNScanbotBarcodeCameraViewManagerInterface<ScanbotBarcodeCameraView>, ScanbotEventReceiver.IEventHandler
|
|
27
|
+
{
|
|
28
|
+
static final String NAME = "RTNScanbotBarcodeCameraView";
|
|
29
|
+
@NonNull @Override public String getName() { return NAME; }
|
|
30
|
+
|
|
31
|
+
private ScanbotBarcodeCameraView barcodeCameraView;
|
|
32
|
+
private final ScanbotEventReceiver eventReceiver;
|
|
33
|
+
private boolean shouldRefreshConfig = false;
|
|
34
|
+
|
|
35
|
+
public ScanbotBarcodeCameraViewManager() {
|
|
36
|
+
super();
|
|
37
|
+
this.eventReceiver = new ScanbotEventReceiver(this, new ScanbotEventReceiver.JavaScriptEvent[] {});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@NonNull
|
|
41
|
+
@Override
|
|
42
|
+
protected ScanbotBarcodeCameraView createViewInstance(@NonNull ThemedReactContext context) {
|
|
43
|
+
this.barcodeCameraView = new ScanbotBarcodeCameraView(context);
|
|
44
|
+
return this.barcodeCameraView;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/*-----------------------*
|
|
48
|
+
* Component Lifecycle
|
|
49
|
+
*------------------------*/
|
|
50
|
+
@Override
|
|
51
|
+
public void componentDidUpdate(ScanbotBarcodeCameraView view) {
|
|
52
|
+
if (shouldRefreshConfig) {
|
|
53
|
+
this.barcodeCameraView.refreshConfiguration();
|
|
54
|
+
shouldRefreshConfig = false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
@Override
|
|
58
|
+
public void orientationChanged(ScanbotBarcodeCameraView view) {
|
|
59
|
+
shouldRefreshConfig = true;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@Override
|
|
63
|
+
public void componentDidMount(ScanbotBarcodeCameraView view) {
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@Override
|
|
67
|
+
public void componentWillUnmount(ScanbotBarcodeCameraView view) {
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/*-----------------------*
|
|
71
|
+
* Events Handling
|
|
72
|
+
*------------------------*/
|
|
73
|
+
@Override
|
|
74
|
+
public void receiveCommand(@NonNull ScanbotBarcodeCameraView root, String commandId, @Nullable ReadableArray args) {
|
|
75
|
+
super.receiveCommand(root, commandId, args);
|
|
76
|
+
eventReceiver.receiveCommand(commandId, args);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@Nullable
|
|
80
|
+
@Override
|
|
81
|
+
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
82
|
+
final NativeEvent[] commonEvents = ScanbotEventEmitter.CommonEvents.values();
|
|
83
|
+
final NativeEvent[] customEvents = ScanbotBarcodeCameraView.getNativeEvents();
|
|
84
|
+
final NativeEvent[] allEvents = ScanbotEventEmitter.concatEvents(commonEvents, customEvents);
|
|
85
|
+
return ScanbotEventEmitter.getMapForNativeEvents(allEvents);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@Override
|
|
89
|
+
public void eventHandler_eventReceived(ScanbotEventReceiver.JavaScriptEvent event, @Nullable ReadableArray args) {
|
|
90
|
+
CommonEvents commonEvent = eventReceiver.getCommonEventFromName(event.getName());
|
|
91
|
+
if (commonEvent == null) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
this.handleCommonEvent(commonEvent, args);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private void handleCommonEvent(CommonEvents commonEvent, @Nullable ReadableArray ignoredArgs) {
|
|
98
|
+
switch (commonEvent) {
|
|
99
|
+
case COMPONENT_DID_UPDATE:
|
|
100
|
+
componentDidUpdate(null);
|
|
101
|
+
break;
|
|
102
|
+
case COMPONENT_DID_MOUNT:
|
|
103
|
+
componentDidMount(null);
|
|
104
|
+
break;
|
|
105
|
+
case COMPONENT_WILL_UNMOUNT:
|
|
106
|
+
componentWillUnmount(null);
|
|
107
|
+
break;
|
|
108
|
+
case ORIENTATION_CHANGED:
|
|
109
|
+
orientationChanged(null);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@Nullable
|
|
115
|
+
@Override
|
|
116
|
+
public Map<String, Integer> getCommandsMap() {
|
|
117
|
+
return eventReceiver.getCommandsMap();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@Override
|
|
121
|
+
@ReactProp(name = "configuration")
|
|
122
|
+
public void setConfiguration(ScanbotBarcodeCameraView view, @Nullable ReadableMap value) {
|
|
123
|
+
if (barcodeCameraView == null) { return; }
|
|
124
|
+
if (value == null) { return; }
|
|
125
|
+
barcodeCameraView.applyConfiguration(value);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -19,7 +19,7 @@ import io.scanbot.barcodesdk.plugin.reactnative.components.base.communication.Sc
|
|
|
19
19
|
import io.scanbot.barcodesdk.plugin.reactnative.components.base.communication.ScanbotEventReceiver.CommonEvents;
|
|
20
20
|
|
|
21
21
|
public class ScanbotBarcodeCameraViewManager extends ViewGroupManager<ScanbotBarcodeCameraView> implements ScanbotEventReceiver.IEventHandler {
|
|
22
|
-
private static final String TAG = "
|
|
22
|
+
private static final String TAG = "RTNScanbotBarcodeCameraView";
|
|
23
23
|
@NonNull @Override public String getName() { return TAG; }
|
|
24
24
|
|
|
25
25
|
private ScanbotBarcodeCameraView barcodeCameraView;
|
package/index.js
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RTNScanbotBarcodeCameraView.h
|
|
3
|
+
// RTNScanbotSDK
|
|
4
|
+
//
|
|
5
|
+
// Created by Marco Saia on 18.05.21.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
// We use this compilation pragma to expose this implementation for the NEW ARCHITECTURE only
|
|
9
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
#ifndef RTNScanbotCameraView_h
|
|
12
|
+
#define RTNScanbotCameraView_h
|
|
13
|
+
|
|
14
|
+
#import <React/RCTViewComponentView.h>
|
|
15
|
+
#import <React/RCTView.h>
|
|
16
|
+
#import <UIKit/UIKit.h>
|
|
17
|
+
#import <ScanbotBarcodeScannerSDK/ScanbotBarcodeScannerSDK.h>
|
|
18
|
+
#import <react/renderer/components/RTNScanbotBarcodeCameraViewSpecs/Props.h>
|
|
19
|
+
|
|
20
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
21
|
+
|
|
22
|
+
@interface RTNScanbotBarcodeCameraView: RCTViewComponentView<SBSDKBarcodeScannerViewControllerDelegate>
|
|
23
|
+
|
|
24
|
+
@property SBSDKBarcodeScannerViewController* _Nullable cameraViewController;
|
|
25
|
+
@property NSMutableArray* _Nonnull barcodes;
|
|
26
|
+
|
|
27
|
+
// TODO: Check if required
|
|
28
|
+
@property (nonatomic, copy) RCTBubblingEventBlock _Nullable requestComponentReload;
|
|
29
|
+
|
|
30
|
+
@property (nonatomic) facebook::react::RTNScanbotBarcodeCameraViewConfigurationStruct configuration;
|
|
31
|
+
|
|
32
|
+
- (void) createCameraViewController;
|
|
33
|
+
- (UIViewController* _Nullable) getParentViewController;
|
|
34
|
+
|
|
35
|
+
- (void) componentDidMount;
|
|
36
|
+
- (void) componentDidUpdate;
|
|
37
|
+
- (void) componentWillUnmount;
|
|
38
|
+
- (void) orientationChanged;
|
|
39
|
+
|
|
40
|
+
@end
|
|
41
|
+
|
|
42
|
+
NS_ASSUME_NONNULL_END
|
|
43
|
+
|
|
44
|
+
#endif /* RTNScanbotCameraView_h */
|
|
45
|
+
#endif // ifdef RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RTNScanbotBarcodeCameraView.mm
|
|
3
|
+
// RNScanbotSDK
|
|
4
|
+
//
|
|
5
|
+
// Created by Marco Saia on 18.05.21.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
// We use this compilation pragma to expose this implementation for the NEW ARCHITECTURE only
|
|
9
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
#import <react/renderer/components/RTNScanbotBarcodeCameraViewSpecs/ComponentDescriptors.h>
|
|
12
|
+
#import <react/renderer/components/RTNScanbotBarcodeCameraViewSpecs/EventEmitters.h>
|
|
13
|
+
#import <react/renderer/components/RTNScanbotBarcodeCameraViewSpecs/Props.h>
|
|
14
|
+
#import <react/renderer/components/RTNScanbotBarcodeCameraViewSpecs/RCTComponentViewHelpers.h>
|
|
15
|
+
|
|
16
|
+
#import "RTNScanbotBarcodeCameraView.h"
|
|
17
|
+
#import "ObjectMapper.h"
|
|
18
|
+
#import "BarcodeMapping.h"
|
|
19
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
20
|
+
|
|
21
|
+
#import <ScanbotBarcodeScannerSDK/ScanbotBarcodeScannerSDK.h>
|
|
22
|
+
#import <Foundation/Foundation.h>
|
|
23
|
+
|
|
24
|
+
using namespace facebook::react;
|
|
25
|
+
|
|
26
|
+
static inline NSString* toNSString(std::string value) {
|
|
27
|
+
return [[NSString alloc] initWithCString:value.c_str() encoding:NSUTF8StringEncoding];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static inline bool isUndefined(facebook::react::Float value) {
|
|
31
|
+
return isnan(value) || value == -1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@interface RTNScanbotBarcodeCameraView () <RCTRTNScanbotBarcodeCameraViewViewProtocol>
|
|
35
|
+
@end
|
|
36
|
+
|
|
37
|
+
@implementation RTNScanbotBarcodeCameraView {
|
|
38
|
+
RTNScanbotBarcodeCameraViewConfigurationStruct _configuration;
|
|
39
|
+
SBSDKBarcodeScannerViewController* viewController;
|
|
40
|
+
SBSDKUIBarcodeFilter* _barcodeFilter;
|
|
41
|
+
CGFloat _userDefinedCameraZoomFactor;
|
|
42
|
+
BOOL _isFirstLaunch;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
46
|
+
{
|
|
47
|
+
return concreteComponentDescriptorProvider<RTNScanbotBarcodeCameraViewComponentDescriptor>();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
- (instancetype)initWithFrame:(CGRect)frame {
|
|
51
|
+
self = [super initWithFrame:frame];
|
|
52
|
+
if (self) {
|
|
53
|
+
_isFirstLaunch = true;
|
|
54
|
+
static const auto defaultProps = std::make_shared<const RTNScanbotBarcodeCameraViewProps>();
|
|
55
|
+
_props = defaultProps;
|
|
56
|
+
|
|
57
|
+
self.barcodes = [[NSMutableArray alloc] init];
|
|
58
|
+
_userDefinedCameraZoomFactor = -1;
|
|
59
|
+
}
|
|
60
|
+
return self;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (void)layoutSubviews {
|
|
64
|
+
if (_cameraViewController) {
|
|
65
|
+
_cameraViewController.view.frame = [self bounds];
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
__weak RTNScanbotBarcodeCameraView* weakSelf = self;
|
|
70
|
+
|
|
71
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
72
|
+
[weakSelf createCameraViewController];
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
- (void)createCameraViewController {
|
|
77
|
+
UIViewController* parentViewController = [self getParentViewController];
|
|
78
|
+
if (!parentViewController) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!_cameraViewController) {
|
|
83
|
+
viewController = [[SBSDKBarcodeScannerViewController alloc] initWithParentViewController:parentViewController
|
|
84
|
+
parentView:self
|
|
85
|
+
delegate:self];
|
|
86
|
+
|
|
87
|
+
_cameraViewController = viewController;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args {
|
|
92
|
+
if ([commandName isEqualToString:@"componentDidMount"]) {
|
|
93
|
+
[self componentDidMount];
|
|
94
|
+
} else if ([commandName isEqualToString:@"componentDidUpdate"]) {
|
|
95
|
+
[self componentDidUpdate];
|
|
96
|
+
} else if ([commandName isEqualToString:@"componentWillUnmount"]) {
|
|
97
|
+
[self componentWillUnmount];
|
|
98
|
+
} else if ([commandName isEqualToString:@"orientationChanged"]) {
|
|
99
|
+
[self orientationChanged];
|
|
100
|
+
} else {
|
|
101
|
+
NSLog(@"Unhandled React Native Command: %@", commandName);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
- (UIViewController* _Nullable)getParentViewController {
|
|
106
|
+
UIResponder* parentResponder = self;
|
|
107
|
+
while (parentResponder) {
|
|
108
|
+
parentResponder = parentResponder.nextResponder;
|
|
109
|
+
if (parentResponder && [parentResponder isKindOfClass:[UIViewController class]]) {
|
|
110
|
+
return (UIViewController*) parentResponder;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return NULL;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
- (void)sendScanResults:(NSArray<SBSDKBarcodeScannerResult*>*) results onImage:(UIImage*)image {
|
|
117
|
+
if (_eventEmitter == nullptr) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if(!results || results.count == 0) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (_barcodeFilter != nil) {
|
|
126
|
+
results = filterBarcodeResults(results, _barcodeFilter);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
NSDictionary* outResult = @{
|
|
130
|
+
@"result": @{
|
|
131
|
+
@"status": @"OK",
|
|
132
|
+
@"barcodes": jsonFromBarcodeResults(results)
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
NSData *data = [NSJSONSerialization dataWithJSONObject:outResult options:NSJSONWritingFragmentsAllowed error:nil];
|
|
137
|
+
NSString *jsonResult = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
138
|
+
|
|
139
|
+
const auto &eventEmitter = std::dynamic_pointer_cast<const facebook::react::RTNScanbotBarcodeCameraViewEventEmitter>(_eventEmitter);
|
|
140
|
+
eventEmitter->onNativeBarcodeScannerResult(facebook::react::RTNScanbotBarcodeCameraViewEventEmitter::OnNativeBarcodeScannerResult{.jsonResult = std::string([jsonResult UTF8String])});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// MARK: - Utility View Configuration Methods
|
|
144
|
+
|
|
145
|
+
/* TODO: A single property change requires us to create a new ViewFinder configuration */
|
|
146
|
+
- (SBSDKBaseScannerViewFinderConfiguration*)createViewFinderConfigurationCopy
|
|
147
|
+
{
|
|
148
|
+
SBSDKBaseScannerViewFinderConfiguration* oldConfig = viewController.viewFinderConfiguration;
|
|
149
|
+
SBSDKBaseScannerViewFinderConfiguration* newConfig = [SBSDKBaseScannerViewFinderConfiguration defaultConfiguration];
|
|
150
|
+
|
|
151
|
+
newConfig.viewFinderEnabled = oldConfig.viewFinderEnabled;
|
|
152
|
+
newConfig.aspectRatio = oldConfig.aspectRatio;
|
|
153
|
+
newConfig.minimumInset = oldConfig.minimumInset;
|
|
154
|
+
newConfig.preferredHeight = oldConfig.preferredHeight;
|
|
155
|
+
newConfig.ignoresSafeAreaInsets = oldConfig.ignoresSafeAreaInsets;
|
|
156
|
+
newConfig.secondaryAspectRatio = oldConfig.secondaryAspectRatio;
|
|
157
|
+
newConfig.secondaryMinimumInset = oldConfig.secondaryMinimumInset;
|
|
158
|
+
newConfig.lineColor = oldConfig.lineColor;
|
|
159
|
+
newConfig.backgroundColor = oldConfig.backgroundColor;
|
|
160
|
+
newConfig.lineCornerRadius = oldConfig.lineCornerRadius;
|
|
161
|
+
newConfig.lineWidth = oldConfig.lineWidth;
|
|
162
|
+
newConfig.animateChanges = oldConfig.animateChanges;
|
|
163
|
+
newConfig.backgroundEffect = oldConfig.backgroundEffect;
|
|
164
|
+
|
|
165
|
+
return newConfig;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// MARK: - React Native Lifecycle
|
|
169
|
+
- (void)applyProps:(const facebook::react::Props::Shared &)props oldProps:(const facebook::react::Props::Shared &)oldProps forceUpdate:(bool)forceUpdate {
|
|
170
|
+
const auto &oldViewProps = *std::static_pointer_cast<RTNScanbotBarcodeCameraViewProps const>(_props);
|
|
171
|
+
const auto &newViewProps = *std::static_pointer_cast<RTNScanbotBarcodeCameraViewProps const>(props);
|
|
172
|
+
|
|
173
|
+
// -----------------------------------------
|
|
174
|
+
// START OF ViewFinderConfiguration MAPPING
|
|
175
|
+
// -----------------------------------------
|
|
176
|
+
|
|
177
|
+
// In order for the mapping to work we need to alloc, init and set a new SBSDKBaseScannerViewFinderConfiguration object
|
|
178
|
+
// in the Scanbot SDK ViewController configuration. Applying hot changes on the existing object does not update
|
|
179
|
+
// the component.
|
|
180
|
+
|
|
181
|
+
SBSDKBaseScannerViewFinderConfiguration* viewFinderConfiguration = [SBSDKBaseScannerViewFinderConfiguration defaultConfiguration];
|
|
182
|
+
|
|
183
|
+
viewFinderConfiguration.viewFinderEnabled = newViewProps.configuration.shouldUseFinderView;
|
|
184
|
+
|
|
185
|
+
if (!isUndefined(newViewProps.configuration.finderLineWidth)) {
|
|
186
|
+
viewFinderConfiguration.lineWidth = newViewProps.configuration.finderLineWidth;
|
|
187
|
+
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (!newViewProps.configuration.finderLineColor.empty()) {
|
|
191
|
+
viewFinderConfiguration.lineColor = [UIColor colorFromHexString:toNSString(newViewProps.configuration.finderLineColor)];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (!newViewProps.configuration.finderBackgroundColor.empty()) {
|
|
195
|
+
viewFinderConfiguration.backgroundColor = [UIColor colorFromHexString:toNSString(newViewProps.configuration.finderBackgroundColor)];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (!isUndefined(newViewProps.configuration.finderBackgroundOpacity)) {
|
|
199
|
+
UIColor* bgColor = viewController.viewFinderConfiguration.backgroundColor;
|
|
200
|
+
viewFinderConfiguration.backgroundColor = [bgColor colorWithAlphaComponent:newViewProps.configuration.finderBackgroundOpacity];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (
|
|
204
|
+
!isUndefined(newViewProps.configuration.finderAspectRatio.width) &&
|
|
205
|
+
!isUndefined(newViewProps.configuration.finderAspectRatio.height)
|
|
206
|
+
) {
|
|
207
|
+
viewFinderConfiguration.aspectRatio = [[SBSDKAspectRatio alloc] initWithWidth:newViewProps.configuration.finderAspectRatio.width
|
|
208
|
+
andHeight:newViewProps.configuration.finderAspectRatio.height];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
if (!isUndefined(newViewProps.configuration.finderInset.left) &&
|
|
213
|
+
!isUndefined(newViewProps.configuration.finderInset.top) &&
|
|
214
|
+
!isUndefined(newViewProps.configuration.finderInset.right) &&
|
|
215
|
+
!isUndefined(newViewProps.configuration.finderInset.bottom)
|
|
216
|
+
) {
|
|
217
|
+
viewFinderConfiguration.minimumInset = UIEdgeInsetsMake(newViewProps.configuration.finderInset.top,
|
|
218
|
+
newViewProps.configuration.finderInset.left,
|
|
219
|
+
newViewProps.configuration.finderInset.bottom,
|
|
220
|
+
newViewProps.configuration.finderInset.right);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
viewController.viewFinderConfiguration = viewFinderConfiguration;
|
|
224
|
+
// ---------------------------------------
|
|
225
|
+
// END OF ViewFinderConfiguration MAPPING
|
|
226
|
+
// ---------------------------------------
|
|
227
|
+
|
|
228
|
+
if (forceUpdate || oldViewProps.configuration.lowPowerMode != newViewProps.configuration.lowPowerMode) {
|
|
229
|
+
// TODO: verify behavior
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (forceUpdate || oldViewProps.configuration.minimumTextLength != newViewProps.configuration.minimumTextLength) {
|
|
233
|
+
if (!isUndefined(newViewProps.configuration.minimumTextLength)) {
|
|
234
|
+
viewController.additionalDetectionParameters.minimumTextLength = newViewProps.configuration.minimumTextLength;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (forceUpdate || oldViewProps.configuration.maximumTextLength != newViewProps.configuration.maximumTextLength) {
|
|
239
|
+
if (!isUndefined(newViewProps.configuration.maximumTextLength)) {
|
|
240
|
+
viewController.additionalDetectionParameters.maximumTextLength = newViewProps.configuration.maximumTextLength;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (forceUpdate || oldViewProps.configuration.minimum1DBarcodesQuietZone != newViewProps.configuration.minimum1DBarcodesQuietZone) {
|
|
245
|
+
if (!isUndefined(newViewProps.configuration.minimum1DBarcodesQuietZone)) {
|
|
246
|
+
viewController.additionalDetectionParameters.minimum1DBarcodesQuietZone = newViewProps.configuration.minimum1DBarcodesQuietZone;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (forceUpdate || oldViewProps.configuration.stripCheckDigits != newViewProps.configuration.stripCheckDigits) {
|
|
251
|
+
viewController.additionalDetectionParameters.stripCheckDigits = newViewProps.configuration.stripCheckDigits;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (forceUpdate || oldViewProps.configuration.gs1DecodingEnabled != newViewProps.configuration.gs1DecodingEnabled) {
|
|
255
|
+
viewController.additionalDetectionParameters.enableGS1Decoding = newViewProps.configuration.gs1DecodingEnabled;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (forceUpdate || oldViewProps.configuration.msiPlesseyChecksumAlgorithm != newViewProps.configuration.msiPlesseyChecksumAlgorithm) {
|
|
259
|
+
viewController.additionalDetectionParameters.msiPlesseyChecksumAlgorithm = extractMsiPlesseyChecksumAlgorithm(toNSString(newViewProps.configuration.msiPlesseyChecksumAlgorithm));
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (forceUpdate || oldViewProps.configuration.codeDensity != newViewProps.configuration.codeDensity) {
|
|
263
|
+
viewController.additionalDetectionParameters.codeDensity = extractBarcodeDensity(toNSString(newViewProps.configuration.codeDensity));
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (forceUpdate || oldViewProps.configuration.flashEnabled != newViewProps.configuration.flashEnabled) {
|
|
267
|
+
viewController.flashLightEnabled = newViewProps.configuration.flashEnabled;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (forceUpdate || oldViewProps.configuration.barcodeFormats != newViewProps.configuration.barcodeFormats) {
|
|
271
|
+
if (!newViewProps.configuration.barcodeFormats.empty()) {
|
|
272
|
+
NSMutableArray* barcodeFormats = [NSMutableArray array];
|
|
273
|
+
for (auto const& format : newViewProps.configuration.barcodeFormats) {
|
|
274
|
+
SBSDKBarcodeType* type = barcodeTypeFromString(toNSString(format));
|
|
275
|
+
if (type != nil) {
|
|
276
|
+
[barcodeFormats addObject:type];
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
viewController.acceptedBarcodeTypes = [barcodeFormats copy];
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (forceUpdate || oldViewProps.configuration.engineMode != newViewProps.configuration.engineMode) {
|
|
284
|
+
viewController.engineMode = extractEngineMode(toNSString(newViewProps.configuration.engineMode));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (forceUpdate || oldViewProps.configuration.cameraZoomFactor != newViewProps.configuration.cameraZoomFactor) {
|
|
288
|
+
if (!isUndefined(newViewProps.configuration.cameraZoomFactor)) {
|
|
289
|
+
if (newViewProps.configuration.cameraZoomFactor != _userDefinedCameraZoomFactor || _userDefinedCameraZoomFactor == -1) {
|
|
290
|
+
viewController.cameraZoomFactor = newViewProps.configuration.cameraZoomFactor;
|
|
291
|
+
_userDefinedCameraZoomFactor = newViewProps.configuration.cameraZoomFactor;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (forceUpdate || oldViewProps.configuration.barcodeFilter != newViewProps.configuration.barcodeFilter) {
|
|
297
|
+
_barcodeFilter = extractBarcodeFilter(toNSString(newViewProps.configuration.barcodeFilter));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
- (void)updateProps:(const facebook::react::Props::Shared &)props oldProps:(const facebook::react::Props::Shared &)oldProps {
|
|
302
|
+
const auto &newViewProps = *std::static_pointer_cast<RTNScanbotBarcodeCameraViewProps const>(props);
|
|
303
|
+
|
|
304
|
+
_configuration = newViewProps.configuration;
|
|
305
|
+
|
|
306
|
+
[self applyProps:props oldProps:oldProps forceUpdate:_isFirstLaunch];
|
|
307
|
+
_isFirstLaunch = false;
|
|
308
|
+
|
|
309
|
+
[super updateProps:props oldProps:oldProps];
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
- (void)componentDidMount {
|
|
313
|
+
_isFirstLaunch = true;
|
|
314
|
+
[self applyProps:_props oldProps:_props forceUpdate:_isFirstLaunch];
|
|
315
|
+
}
|
|
316
|
+
- (void)componentDidUpdate {}
|
|
317
|
+
- (void)componentWillUnmount {
|
|
318
|
+
[_cameraViewController removeFromParentViewController];
|
|
319
|
+
_cameraViewController = NULL;
|
|
320
|
+
}
|
|
321
|
+
- (void)orientationChanged {}
|
|
322
|
+
|
|
323
|
+
// MARK: - SBSDKBarcodeScannerViewControllerDelegate
|
|
324
|
+
|
|
325
|
+
- (void)barcodeScannerController:(SBSDKBarcodeScannerViewController *)controller
|
|
326
|
+
didDetectBarcodes:(NSArray<SBSDKBarcodeScannerResult *> *)codes
|
|
327
|
+
onImage:(nonnull UIImage *)image {
|
|
328
|
+
|
|
329
|
+
[self sendScanResults:codes onImage:image];
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
- (BOOL)barcodeScannerControllerShouldDetectBarcodes:(SBSDKBarcodeScannerViewController *)controller {
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
- (void)barcodeScannerController:(nonnull SBSDKBarcodeScannerViewController *)controller didDetectBarcodes:(nonnull NSArray<SBSDKBarcodeScannerResult *> *)codes {
|
|
337
|
+
[self sendScanResults:codes onImage:nil];
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
- (NSArray*)hashedBarcodes {
|
|
342
|
+
NSMutableArray* outArray = [[NSMutableArray alloc] init];
|
|
343
|
+
for (NSDictionary* barcode in self.barcodes) {
|
|
344
|
+
NSString* hash = [RTNScanbotBarcodeCameraView hashFromBarcode:barcode];
|
|
345
|
+
[outArray addObject:hash];
|
|
346
|
+
}
|
|
347
|
+
return outArray;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
+ (NSString*)hashFromBarcode: (NSDictionary* _Nonnull)barcode {
|
|
351
|
+
NSString* text = [barcode objectForKey:@"barcode"];
|
|
352
|
+
NSString* type = [barcode objectForKey:@"type"];
|
|
353
|
+
return [[NSString stringWithFormat:@"%@_%@", text, type] lowercaseString];
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
@end
|
|
357
|
+
|
|
358
|
+
Class<RCTComponentViewProtocol> RTNScanbotBarcodeCameraViewCls(void)
|
|
359
|
+
{
|
|
360
|
+
return RTNScanbotBarcodeCameraView.class;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
#endif // ifdef RCT_NEW_ARCH_ENABLED
|
|
364
|
+
|
package/ios/Components/BarcodeCameraView/NewArchitecture/RTNScanbotBarcodeCameraViewManager.mm
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNScanbotBarcodeCameraViewManager.mm
|
|
3
|
+
// RNScanbotBarcodeSDK
|
|
4
|
+
//
|
|
5
|
+
// Created by Marco Saia on 28.08.23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
// We use this compilation pragma to expose this implementation for the NEW ARCHITECTURE only
|
|
9
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
#import <React/RCTLog.h>
|
|
12
|
+
#import <React/RCTUIManager.h>
|
|
13
|
+
#import <React/RCTViewManager.h>
|
|
14
|
+
#import <Foundation/Foundation.h>
|
|
15
|
+
#import "RTNScanbotBarcodeCameraView.h"
|
|
16
|
+
|
|
17
|
+
typedef void (^NativeViewBlock)(RTNScanbotBarcodeCameraView* _Nonnull);
|
|
18
|
+
|
|
19
|
+
@interface RTNScanbotBarcodeCameraViewManager : RCTViewManager
|
|
20
|
+
@end
|
|
21
|
+
|
|
22
|
+
@implementation RTNScanbotBarcodeCameraViewManager
|
|
23
|
+
|
|
24
|
+
RCT_EXPORT_MODULE(RTNScanbotBarcodeCameraView)
|
|
25
|
+
RCT_EXPORT_VIEW_PROPERTY(configuration, NSDictionary*)
|
|
26
|
+
RCT_EXPORT_VIEW_PROPERTY(onNativeBarcodeScannerResult, RCTDirectEventBlock);
|
|
27
|
+
|
|
28
|
+
// componentDidMount
|
|
29
|
+
RCT_EXPORT_METHOD(componentDidMount:(nonnull NSNumber*) reactTag) {
|
|
30
|
+
[self callNativeMethodWithReactTag: reactTag andBlock: ^void (RTNScanbotBarcodeCameraView* nativeView) {
|
|
31
|
+
[nativeView componentDidMount];
|
|
32
|
+
}];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// componentDidUpdate
|
|
36
|
+
RCT_EXPORT_METHOD(componentDidUpdate:(nonnull NSNumber*) reactTag) {
|
|
37
|
+
[self callNativeMethodWithReactTag: reactTag andBlock: ^void (RTNScanbotBarcodeCameraView* nativeView) {
|
|
38
|
+
[nativeView componentDidUpdate];
|
|
39
|
+
}];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// componentWillUnmount
|
|
43
|
+
RCT_EXPORT_METHOD(componentWillUnmount:(nonnull NSNumber*) reactTag) {
|
|
44
|
+
[self callNativeMethodWithReactTag: reactTag andBlock: ^void (RTNScanbotBarcodeCameraView* nativeView) {
|
|
45
|
+
[nativeView componentWillUnmount];
|
|
46
|
+
}];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// orientationChanged
|
|
50
|
+
RCT_EXPORT_METHOD(orientationChanged:(nonnull NSNumber*) reactTag) {
|
|
51
|
+
[self callNativeMethodWithReactTag: reactTag andBlock: ^void (RTNScanbotBarcodeCameraView* nativeView) {
|
|
52
|
+
[nativeView orientationChanged];
|
|
53
|
+
}];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
- (void) callNativeMethodWithReactTag:(nonnull NSNumber*) reactTag andBlock:(NativeViewBlock)block {
|
|
57
|
+
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
58
|
+
RTNScanbotBarcodeCameraView* view = (RTNScanbotBarcodeCameraView*) viewRegistry[reactTag];
|
|
59
|
+
if (!view || ![view isKindOfClass:[RTNScanbotBarcodeCameraView class]]) {
|
|
60
|
+
RCTLogError(@"Cannot find native view with tag #%@", reactTag);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
block(view);
|
|
64
|
+
}];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@end
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
#endif
|