react-native-scanbot-barcode-scanner-sdk 6.1.0-rc.3 → 6.2.0-beta.1
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/Libraries.txt +2 -2
- package/RNScanbotBarcodeSDK.podspec +1 -1
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcode_scanner_view/ScanbotBarcodeScannerView.kt +107 -32
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcode_scanner_view/ScanbotBarcodeScannerViewManager.kt +45 -27
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/{models → components/barcode_scanner_view/models}/ScanbotBarcodeScannerModels.kt +44 -1
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/extensions/BarcodeItemExtensions.kt +8 -0
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/extensions/IntExtensions.kt +7 -0
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/extensions/Utils.kt +10 -3
- package/android/src/paper/com/facebook/react/viewmanagers/ScanbotBarcodeScannerViewManagerDelegate.java +9 -0
- package/android/src/paper/com/facebook/react/viewmanagers/ScanbotBarcodeScannerViewManagerInterface.java +3 -0
- package/ios/Components/BarcodeScannerView/BarcodeItem.h +2 -1
- package/ios/Components/BarcodeScannerView/BarcodeItem.m +4 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerLegacyView.h +1 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerLegacyView.m +59 -2
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerView.h +0 -1
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerView.mm +56 -3
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerViewControllerWrapper.h +15 -1
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerViewControllerWrapper.m +113 -5
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerViewManager.mm +9 -0
- package/lib/commonjs/component/barcode-camera-view/ScanbotBarcodeCameraView.js +20 -3
- package/lib/commonjs/component/barcode-camera-view/ScanbotBarcodeCameraView.js.map +1 -1
- package/lib/commonjs/component/spec/ScanbotBarcodeScannerViewNativeComponent.js +1 -1
- package/lib/commonjs/component/spec/ScanbotBarcodeScannerViewNativeComponent.js.map +1 -1
- package/lib/module/component/barcode-camera-view/ScanbotBarcodeCameraView.js +20 -3
- package/lib/module/component/barcode-camera-view/ScanbotBarcodeCameraView.js.map +1 -1
- package/lib/module/component/spec/ScanbotBarcodeScannerViewNativeComponent.js +1 -1
- package/lib/module/component/spec/ScanbotBarcodeScannerViewNativeComponent.js.map +1 -1
- package/lib/typescript/src/component/barcode-camera-view/ScanbotBarcodeCameraView.d.ts.map +1 -1
- package/lib/typescript/src/component/barcode-camera-view/ScanbotBarcodeCameraViewProperties.d.ts +24 -0
- package/lib/typescript/src/component/barcode-camera-view/ScanbotBarcodeCameraViewProperties.d.ts.map +1 -1
- package/lib/typescript/src/component/spec/ScanbotBarcodeScannerViewNativeComponent.d.ts +3 -0
- package/lib/typescript/src/component/spec/ScanbotBarcodeScannerViewNativeComponent.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/component/barcode-camera-view/ScanbotBarcodeCameraView.tsx +29 -2
- package/src/component/barcode-camera-view/ScanbotBarcodeCameraViewProperties.ts +27 -0
- package/src/component/spec/ScanbotBarcodeScannerViewNativeComponent.ts +13 -1
package/Libraries.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Open Source libraries used in the Scanbot Barcode SDK for React Native version 6.
|
|
1
|
+
Open Source libraries used in the Scanbot Barcode SDK for React Native version 6.2.0
|
|
2
2
|
|
|
3
|
-
Open Source libraries used in ScanbotBarcodeScannerSDK for iOS version 6.
|
|
3
|
+
Open Source libraries used in ScanbotBarcodeScannerSDK for iOS version 6.2.0:
|
|
4
4
|
|
|
5
5
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
6
6
|
|
|
@@ -4,21 +4,26 @@ import android.Manifest
|
|
|
4
4
|
import android.app.Activity
|
|
5
5
|
import android.content.Context
|
|
6
6
|
import android.content.pm.PackageManager
|
|
7
|
+
import android.content.res.ColorStateList
|
|
7
8
|
import android.util.AttributeSet
|
|
8
9
|
import android.view.View
|
|
9
10
|
import android.view.ViewGroup
|
|
11
|
+
import android.widget.Button
|
|
10
12
|
import android.widget.FrameLayout
|
|
11
13
|
import androidx.core.app.ActivityCompat
|
|
12
14
|
import com.facebook.react.bridge.LifecycleEventListener
|
|
13
15
|
import com.facebook.react.bridge.ReactContext
|
|
14
16
|
import com.facebook.react.uimanager.UIManagerHelper
|
|
17
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.models.BarcodeItemOverlayViewConfig
|
|
18
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.models.CameraConfiguration
|
|
19
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.models.FinderViewConfiguration
|
|
20
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.models.PolygonStyleConfig
|
|
21
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.models.SelectedBarcodes
|
|
22
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.models.TextStyleConfig
|
|
15
23
|
import io.scanbot.barcodesdk.plugin.reactnative.extensions.toPx
|
|
16
|
-
import io.scanbot.barcodesdk.plugin.reactnative.
|
|
17
|
-
import io.scanbot.barcodesdk.plugin.reactnative.models.FinderViewConfiguration
|
|
18
|
-
import io.scanbot.barcodesdk.plugin.reactnative.models.PolygonStyleConfig
|
|
19
|
-
import io.scanbot.barcodesdk.plugin.reactnative.models.SelectedBarcodes
|
|
20
|
-
import io.scanbot.barcodesdk.plugin.reactnative.models.TextStyleConfig
|
|
24
|
+
import io.scanbot.barcodesdk.plugin.reactnative.extensions.uuid
|
|
21
25
|
import io.scanbot.sdk.barcode.entity.BarcodeItem
|
|
26
|
+
import io.scanbot.sdk.barcode.entity.BarcodeScanningResult
|
|
22
27
|
import io.scanbot.sdk.barcode.ui.BarcodePolygonsView
|
|
23
28
|
import io.scanbot.sdk.barcode.ui.BarcodeScannerView
|
|
24
29
|
import io.scanbot.sdk.barcode.ui.IBarcodeScannerFinderViewController
|
|
@@ -30,19 +35,13 @@ import io.scanbot.sdk.camera.FrameHandlerResult
|
|
|
30
35
|
import io.scanbot.sdk.ui.camera.CameraUiSettings
|
|
31
36
|
|
|
32
37
|
class ScanbotBarcodeScannerView(
|
|
33
|
-
context: Context,
|
|
34
|
-
attrs: AttributeSet?,
|
|
35
|
-
defStyleAttr: Int,
|
|
36
|
-
defStyleRes: Int
|
|
38
|
+
context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int
|
|
37
39
|
) : FrameLayout(context, attrs, defStyleAttr, defStyleRes) {
|
|
38
40
|
|
|
39
41
|
constructor(context: Context) : this(context, null)
|
|
40
42
|
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
|
|
41
43
|
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : this(
|
|
42
|
-
context,
|
|
43
|
-
attrs,
|
|
44
|
-
defStyleAttr,
|
|
45
|
-
0
|
|
44
|
+
context, attrs, defStyleAttr, 0
|
|
46
45
|
)
|
|
47
46
|
|
|
48
47
|
companion object {
|
|
@@ -63,6 +62,41 @@ class ScanbotBarcodeScannerView(
|
|
|
63
62
|
|
|
64
63
|
private var cameraPermissionRequested = false
|
|
65
64
|
|
|
65
|
+
private var barcodeItemOverlayViewBinders: MutableMap<String, BarcodeItemOverlayViewConfig>? =
|
|
66
|
+
null
|
|
67
|
+
|
|
68
|
+
private val barcodeItemOverlayViewBinder: BarcodePolygonsView.BarcodeItemViewBinder =
|
|
69
|
+
object : BarcodePolygonsView.BarcodeItemViewBinder {
|
|
70
|
+
override fun bindView(view: View, barcodeItem: BarcodeItem, shouldHighlight: Boolean) {
|
|
71
|
+
(view as? Button)?.let { buttonView ->
|
|
72
|
+
barcodeItemOverlayViewBinders?.get(barcodeItem.uuid())
|
|
73
|
+
?.let { overlayViewConfig ->
|
|
74
|
+
buttonView.text = overlayViewConfig.text
|
|
75
|
+
|
|
76
|
+
// TODO native bug: buttonView doesn't use global overlay configuration by default
|
|
77
|
+
if (shouldHighlight) {
|
|
78
|
+
buttonView.setTextColor(
|
|
79
|
+
overlayViewConfig.highlightedTextColorParsed
|
|
80
|
+
?: textStyle.textHighlightedColor!!
|
|
81
|
+
)
|
|
82
|
+
buttonView.backgroundTintList = ColorStateList.valueOf(
|
|
83
|
+
overlayViewConfig.highlightedTextContainerColorParsed
|
|
84
|
+
?: textStyle.textContainerHighlightedColor!!
|
|
85
|
+
)
|
|
86
|
+
} else {
|
|
87
|
+
buttonView.setTextColor(
|
|
88
|
+
overlayViewConfig.textColorParsed ?: textStyle.textColor!!
|
|
89
|
+
)
|
|
90
|
+
buttonView.backgroundTintList = ColorStateList.valueOf(
|
|
91
|
+
overlayViewConfig.textContainerColorParsed
|
|
92
|
+
?: textStyle.textContainerColor!!
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
66
100
|
private var lifecycleEventListener: LifecycleEventListener = object : LifecycleEventListener {
|
|
67
101
|
override fun onHostResume() {
|
|
68
102
|
requestCameraPermissionIfNotGranted()
|
|
@@ -88,8 +122,6 @@ class ScanbotBarcodeScannerView(
|
|
|
88
122
|
addView(barcodeScanner)
|
|
89
123
|
}
|
|
90
124
|
|
|
91
|
-
|
|
92
|
-
|
|
93
125
|
private fun initBarcodeScannerView() {
|
|
94
126
|
barcodeScanner = BarcodeScannerView(context).apply {
|
|
95
127
|
initCamera(CameraUiSettings(true))
|
|
@@ -97,6 +129,8 @@ class ScanbotBarcodeScannerView(
|
|
|
97
129
|
initDetectionBehavior(barcodeDetector, {
|
|
98
130
|
(it as? FrameHandlerResult.Success)?.value?.let { result ->
|
|
99
131
|
sendEvent(BarcodeScannerResultEvent(result))
|
|
132
|
+
|
|
133
|
+
addBarcodeItemOverlayViewInitialBinder(result)
|
|
100
134
|
}
|
|
101
135
|
|
|
102
136
|
false
|
|
@@ -224,10 +258,8 @@ class ScanbotBarcodeScannerView(
|
|
|
224
258
|
private fun requestCameraPermissionIfNotGranted() {
|
|
225
259
|
val activity: Activity = (context as ReactContext).currentActivity ?: return
|
|
226
260
|
|
|
227
|
-
if (!cameraPermissionRequested &&
|
|
228
|
-
|
|
229
|
-
activity,
|
|
230
|
-
Manifest.permission.CAMERA
|
|
261
|
+
if (!cameraPermissionRequested && ActivityCompat.checkSelfPermission(
|
|
262
|
+
activity, Manifest.permission.CAMERA
|
|
231
263
|
) != PackageManager.PERMISSION_GRANTED
|
|
232
264
|
) {
|
|
233
265
|
// shouldShowRequestPermissionRationale can be changed from another place in the app,
|
|
@@ -235,9 +267,7 @@ class ScanbotBarcodeScannerView(
|
|
|
235
267
|
cameraPermissionRequested = true
|
|
236
268
|
|
|
237
269
|
ActivityCompat.requestPermissions(
|
|
238
|
-
activity,
|
|
239
|
-
arrayOf(Manifest.permission.CAMERA),
|
|
240
|
-
CAMERA_PERMISSION_REQUEST_CODE
|
|
270
|
+
activity, arrayOf(Manifest.permission.CAMERA), CAMERA_PERMISSION_REQUEST_CODE
|
|
241
271
|
)
|
|
242
272
|
}
|
|
243
273
|
}
|
|
@@ -246,20 +276,32 @@ class ScanbotBarcodeScannerView(
|
|
|
246
276
|
barcodeScanner.selectionOverlayController.setBarcodeAppearanceDelegate(object :
|
|
247
277
|
BarcodePolygonsView.BarcodeAppearanceDelegate {
|
|
248
278
|
override fun getPolygonStyle(
|
|
249
|
-
defaultStyle: BarcodePolygonsView.BarcodePolygonStyle,
|
|
250
|
-
barcodeItem: BarcodeItem
|
|
279
|
+
defaultStyle: BarcodePolygonsView.BarcodePolygonStyle, barcodeItem: BarcodeItem
|
|
251
280
|
): BarcodePolygonsView.BarcodePolygonStyle {
|
|
252
|
-
return
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
281
|
+
return barcodeItemOverlayViewBinders?.get(barcodeItem.uuid())
|
|
282
|
+
?.let { overlayViewConfig ->
|
|
283
|
+
defaultStyle.copy(
|
|
284
|
+
fillColor = overlayViewConfig.polygonColorParsed
|
|
285
|
+
?: polygonStyle.fillColor!!,
|
|
286
|
+
fillHighlightedColor = overlayViewConfig.highlightedPolygonColorParsed
|
|
287
|
+
?: polygonStyle.fillHighlightedColor!!,
|
|
288
|
+
strokeColor = overlayViewConfig.strokeColorParsed
|
|
289
|
+
?: polygonStyle.strokeColor!!,
|
|
290
|
+
strokeHighlightedColor = overlayViewConfig.highlightedStrokeColorParsed
|
|
291
|
+
?: polygonStyle.strokeHighlightedColor!!,
|
|
292
|
+
)
|
|
293
|
+
} ?: run {
|
|
294
|
+
defaultStyle.copy(
|
|
295
|
+
fillColor = polygonStyle.fillColor!!,
|
|
296
|
+
fillHighlightedColor = polygonStyle.fillHighlightedColor!!,
|
|
297
|
+
strokeColor = polygonStyle.strokeColor!!,
|
|
298
|
+
strokeHighlightedColor = polygonStyle.strokeHighlightedColor!!,
|
|
299
|
+
)
|
|
300
|
+
}
|
|
258
301
|
}
|
|
259
302
|
|
|
260
303
|
override fun getTextViewStyle(
|
|
261
|
-
defaultStyle: BarcodePolygonsView.BarcodeTextViewStyle,
|
|
262
|
-
barcodeItem: BarcodeItem
|
|
304
|
+
defaultStyle: BarcodePolygonsView.BarcodeTextViewStyle, barcodeItem: BarcodeItem
|
|
263
305
|
): BarcodePolygonsView.BarcodeTextViewStyle {
|
|
264
306
|
return defaultStyle.copy(
|
|
265
307
|
textColor = textStyle.textColor!!,
|
|
@@ -271,4 +313,37 @@ class ScanbotBarcodeScannerView(
|
|
|
271
313
|
}
|
|
272
314
|
})
|
|
273
315
|
}
|
|
316
|
+
|
|
317
|
+
private fun addBarcodeItemOverlayViewInitialBinder(barcodeResult: BarcodeScanningResult) {
|
|
318
|
+
barcodeItemOverlayViewBinders?.let { bindersList ->
|
|
319
|
+
barcodeResult.barcodeItems.forEach { barcodeItem ->
|
|
320
|
+
val barcodeItemUuid = barcodeItem.uuid()
|
|
321
|
+
|
|
322
|
+
if (!bindersList.contains(barcodeItemUuid)) {
|
|
323
|
+
bindersList[barcodeItemUuid] =
|
|
324
|
+
BarcodeItemOverlayViewConfig(text = BarcodeItemOverlayViewConfig.LOADING_TEXT)
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
fun updateBarcodeItemOverlayViewBinder(
|
|
331
|
+
barcodeItemUuid: String, barcodeItemOverlayViewConfig: BarcodeItemOverlayViewConfig
|
|
332
|
+
) {
|
|
333
|
+
barcodeItemOverlayViewBinders?.let { bindersList ->
|
|
334
|
+
if (bindersList.contains(barcodeItemUuid)) {
|
|
335
|
+
bindersList[barcodeItemUuid] = barcodeItemOverlayViewConfig
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
fun setBarcodeItemOverlayViewBinderCallback() {
|
|
341
|
+
if (barcodeItemOverlayViewBinders == null) {
|
|
342
|
+
barcodeItemOverlayViewBinders = mutableMapOf()
|
|
343
|
+
|
|
344
|
+
barcodeScanner.selectionOverlayController.setBarcodeItemViewBinder(
|
|
345
|
+
barcodeItemOverlayViewBinder
|
|
346
|
+
)
|
|
347
|
+
}
|
|
348
|
+
}
|
|
274
349
|
}
|
|
@@ -11,14 +11,15 @@ import com.facebook.react.uimanager.annotations.ReactProp
|
|
|
11
11
|
import com.facebook.react.viewmanagers.ScanbotBarcodeScannerViewManagerDelegate
|
|
12
12
|
import com.facebook.react.viewmanagers.ScanbotBarcodeScannerViewManagerInterface
|
|
13
13
|
import com.google.gson.reflect.TypeToken
|
|
14
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.models.BarcodeItemOverlayViewConfig
|
|
15
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.models.CameraConfiguration
|
|
16
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.models.DetectorConfig
|
|
17
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.models.FinderInsets
|
|
18
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.models.FinderViewConfiguration
|
|
19
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.models.SelectedBarcodes
|
|
20
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.models.ZoomRangeConfig
|
|
14
21
|
import io.scanbot.barcodesdk.plugin.reactnative.extensions.toJSON
|
|
15
22
|
import io.scanbot.barcodesdk.plugin.reactnative.extensions.toPx
|
|
16
|
-
import io.scanbot.barcodesdk.plugin.reactnative.models.CameraConfiguration
|
|
17
|
-
import io.scanbot.barcodesdk.plugin.reactnative.models.DetectorConfig
|
|
18
|
-
import io.scanbot.barcodesdk.plugin.reactnative.models.FinderInsets
|
|
19
|
-
import io.scanbot.barcodesdk.plugin.reactnative.models.FinderViewConfiguration
|
|
20
|
-
import io.scanbot.barcodesdk.plugin.reactnative.models.SelectedBarcodes
|
|
21
|
-
import io.scanbot.barcodesdk.plugin.reactnative.models.ZoomRangeConfig
|
|
22
23
|
import io.scanbot.sdk.AspectRatio
|
|
23
24
|
import io.scanbot.sdk.barcode.BarcodeEanUpcNoExtensionsFilter
|
|
24
25
|
import io.scanbot.sdk.barcode.BarcodeExtensionsFilter
|
|
@@ -33,13 +34,10 @@ import java.util.EnumSet
|
|
|
33
34
|
class ScanbotBarcodeScannerViewManager : SimpleViewManager<ScanbotBarcodeScannerView>(),
|
|
34
35
|
ScanbotBarcodeScannerViewManagerInterface<ScanbotBarcodeScannerView> {
|
|
35
36
|
|
|
36
|
-
private val mDelegate: ViewManagerDelegate<ScanbotBarcodeScannerView>
|
|
37
|
+
private val mDelegate: ViewManagerDelegate<ScanbotBarcodeScannerView> =
|
|
38
|
+
ScanbotBarcodeScannerViewManagerDelegate(this)
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
mDelegate = ScanbotBarcodeScannerViewManagerDelegate(this)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
override fun getDelegate(): ViewManagerDelegate<ScanbotBarcodeScannerView>? {
|
|
40
|
+
override fun getDelegate(): ViewManagerDelegate<ScanbotBarcodeScannerView> {
|
|
43
41
|
return mDelegate
|
|
44
42
|
}
|
|
45
43
|
|
|
@@ -87,15 +85,27 @@ class ScanbotBarcodeScannerViewManager : SimpleViewManager<ScanbotBarcodeScanner
|
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
87
|
|
|
88
|
+
override fun bindBarcodeItemOverlayView(
|
|
89
|
+
view: ScanbotBarcodeScannerView, barcodeItemUuid: String, bindingConfig: String
|
|
90
|
+
) {
|
|
91
|
+
val barcodeItemOverlayViewConfig =
|
|
92
|
+
SBWrapper.gson.fromJson(bindingConfig, BarcodeItemOverlayViewConfig::class.java)
|
|
93
|
+
|
|
94
|
+
view.updateBarcodeItemOverlayViewBinder(barcodeItemUuid, barcodeItemOverlayViewConfig)
|
|
95
|
+
view.setOverlayAppearance()
|
|
96
|
+
}
|
|
97
|
+
|
|
90
98
|
override fun receiveCommand(
|
|
91
|
-
root: ScanbotBarcodeScannerView,
|
|
92
|
-
commandId: String?,
|
|
93
|
-
args: ReadableArray?
|
|
99
|
+
root: ScanbotBarcodeScannerView, commandId: String?, args: ReadableArray?
|
|
94
100
|
) {
|
|
95
101
|
when (commandId) {
|
|
96
102
|
"freezeCamera" -> freezeCamera(root)
|
|
97
103
|
"unfreezeCamera" -> unfreezeCamera(root)
|
|
98
104
|
"addHighLightedBarcode" -> addHighLightedBarcode(root, args?.getString(0))
|
|
105
|
+
"bindBarcodeItemOverlayView" -> bindBarcodeItemOverlayView(
|
|
106
|
+
root, args!!.getString(0), args.getString(1)
|
|
107
|
+
)
|
|
108
|
+
|
|
99
109
|
else -> throw Error("Unrecognized command $commandId")
|
|
100
110
|
}
|
|
101
111
|
}
|
|
@@ -127,8 +137,7 @@ class ScanbotBarcodeScannerViewManager : SimpleViewManager<ScanbotBarcodeScanner
|
|
|
127
137
|
override fun setCameraZoomRange(view: ScanbotBarcodeScannerView, value: ReadableMap?) {
|
|
128
138
|
val zoomRange = if (value != null) {
|
|
129
139
|
val zoomRangeConfig = SBWrapper.gson.fromJson(
|
|
130
|
-
value.toJSON().toString(),
|
|
131
|
-
ZoomRangeConfig::class.java
|
|
140
|
+
value.toJSON().toString(), ZoomRangeConfig::class.java
|
|
132
141
|
)
|
|
133
142
|
ZoomRange(zoomRangeConfig.maxZoom, zoomRangeConfig.minZoom)
|
|
134
143
|
} else {
|
|
@@ -155,8 +164,7 @@ class ScanbotBarcodeScannerViewManager : SimpleViewManager<ScanbotBarcodeScanner
|
|
|
155
164
|
override fun setDetectorConfig(view: ScanbotBarcodeScannerView, value: ReadableMap?) {
|
|
156
165
|
val config = if (value != null) {
|
|
157
166
|
SBWrapper.gson.fromJson(
|
|
158
|
-
value.toJSON().toString(),
|
|
159
|
-
DetectorConfig::class.java
|
|
167
|
+
value.toJSON().toString(), DetectorConfig::class.java
|
|
160
168
|
)
|
|
161
169
|
} else {
|
|
162
170
|
DetectorConfig()
|
|
@@ -192,14 +200,12 @@ class ScanbotBarcodeScannerViewManager : SimpleViewManager<ScanbotBarcodeScanner
|
|
|
192
200
|
|
|
193
201
|
@ReactProp(name = "finderRequiredAspectRatios")
|
|
194
202
|
override fun setFinderRequiredAspectRatios(
|
|
195
|
-
view: ScanbotBarcodeScannerView,
|
|
196
|
-
value: ReadableMap?
|
|
203
|
+
view: ScanbotBarcodeScannerView, value: ReadableMap?
|
|
197
204
|
) {
|
|
198
205
|
val aspectRatios = if (value != null) {
|
|
199
206
|
listOf(
|
|
200
207
|
SBWrapper.gson.fromJson(
|
|
201
|
-
value.toJSON().toString(),
|
|
202
|
-
AspectRatio::class.java
|
|
208
|
+
value.toJSON().toString(), AspectRatio::class.java
|
|
203
209
|
)
|
|
204
210
|
)
|
|
205
211
|
} else {
|
|
@@ -213,8 +219,7 @@ class ScanbotBarcodeScannerViewManager : SimpleViewManager<ScanbotBarcodeScanner
|
|
|
213
219
|
override fun setFinderInset(view: ScanbotBarcodeScannerView, value: ReadableMap?) {
|
|
214
220
|
val insets = if (value != null) {
|
|
215
221
|
SBWrapper.gson.fromJson(
|
|
216
|
-
value.toJSON().toString(),
|
|
217
|
-
FinderInsets::class.java
|
|
222
|
+
value.toJSON().toString(), FinderInsets::class.java
|
|
218
223
|
)
|
|
219
224
|
} else {
|
|
220
225
|
FinderViewConfiguration.DEFAULT_FINDER_INSETS
|
|
@@ -305,8 +310,7 @@ class ScanbotBarcodeScannerViewManager : SimpleViewManager<ScanbotBarcodeScanner
|
|
|
305
310
|
|
|
306
311
|
@ReactProp(name = "overlayHighlightedTextContainerColor", customType = "Color")
|
|
307
312
|
override fun setOverlayHighlightedTextContainerColor(
|
|
308
|
-
view: ScanbotBarcodeScannerView,
|
|
309
|
-
value: Int?
|
|
313
|
+
view: ScanbotBarcodeScannerView, value: Int?
|
|
310
314
|
) {
|
|
311
315
|
view.textStyle.textContainerHighlightedColor = value
|
|
312
316
|
view.setOverlayAppearance()
|
|
@@ -324,6 +328,20 @@ class ScanbotBarcodeScannerViewManager : SimpleViewManager<ScanbotBarcodeScanner
|
|
|
324
328
|
view.barcodeScanner.selectionOverlayController.setEnabled(value)
|
|
325
329
|
}
|
|
326
330
|
|
|
331
|
+
@ReactProp(name = "overlayLoadingTextValue")
|
|
332
|
+
override fun setOverlayLoadingTextValue(view: ScanbotBarcodeScannerView?, value: String?) {
|
|
333
|
+
BarcodeItemOverlayViewConfig.LOADING_TEXT = value
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
@ReactProp(name = "overlayBarcodeItemOverlayViewBinder")
|
|
337
|
+
override fun setOverlayBarcodeItemOverlayViewBinder(
|
|
338
|
+
view: ScanbotBarcodeScannerView, value: Boolean
|
|
339
|
+
) {
|
|
340
|
+
if (value) {
|
|
341
|
+
view.setBarcodeItemOverlayViewBinderCallback()
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
327
345
|
// endregion
|
|
328
346
|
}
|
|
329
347
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
package io.scanbot.barcodesdk.plugin.reactnative.models
|
|
1
|
+
package io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.models
|
|
2
2
|
|
|
3
3
|
import android.graphics.Color
|
|
4
4
|
import androidx.annotation.Keep
|
|
5
|
+
import io.scanbot.barcodesdk.plugin.reactnative.extensions.Utils
|
|
5
6
|
import io.scanbot.sdk.AspectRatio
|
|
6
7
|
import io.scanbot.sdk.barcode.entity.BarcodeDocumentFormat
|
|
7
8
|
import io.scanbot.sdk.barcode.entity.BarcodeFormat
|
|
9
|
+
import io.scanbot.sdk.barcode.entity.BarcodeItem
|
|
8
10
|
import io.scanbot.sdk.barcode.entity.EngineMode
|
|
9
11
|
import io.scanbot.sdk.barcode.entity.Gs1Handling
|
|
10
12
|
import io.scanbot.sdk.barcode.entity.MSIPlesseyChecksumAlgorithm
|
|
@@ -162,3 +164,44 @@ data class FinderInsets(
|
|
|
162
164
|
var left: Int, var right: Int, var top: Int, var bottom: Int
|
|
163
165
|
)
|
|
164
166
|
|
|
167
|
+
@Keep
|
|
168
|
+
data class BarcodeItemOverlayViewConfig(
|
|
169
|
+
var text: String? = null,
|
|
170
|
+
var textColor: String? = null,
|
|
171
|
+
var textContainerColor: String? = null,
|
|
172
|
+
var highlightedTextColor: String? = null,
|
|
173
|
+
var highlightedTextContainerColor: String? = null,
|
|
174
|
+
var polygonColor: String? = null,
|
|
175
|
+
var strokeColor: String? = null,
|
|
176
|
+
var highlightedPolygonColor: String? = null,
|
|
177
|
+
var highlightedStrokeColor: String? = null
|
|
178
|
+
) {
|
|
179
|
+
|
|
180
|
+
val textColorParsed: Int?
|
|
181
|
+
get() = textColor?.let { Utils.tryToParseRGBAHexColor(it) }
|
|
182
|
+
|
|
183
|
+
val textContainerColorParsed: Int?
|
|
184
|
+
get() = textContainerColor?.let { Utils.tryToParseRGBAHexColor(it) }
|
|
185
|
+
|
|
186
|
+
val highlightedTextColorParsed: Int?
|
|
187
|
+
get() = highlightedTextColor?.let { Utils.tryToParseRGBAHexColor(it) }
|
|
188
|
+
|
|
189
|
+
val highlightedTextContainerColorParsed: Int?
|
|
190
|
+
get() = highlightedTextContainerColor?.let { Utils.tryToParseRGBAHexColor(it) }
|
|
191
|
+
|
|
192
|
+
val polygonColorParsed: Int?
|
|
193
|
+
get() = polygonColor?.let { Utils.tryToParseRGBAHexColor(it) }
|
|
194
|
+
|
|
195
|
+
val strokeColorParsed: Int?
|
|
196
|
+
get() = strokeColor?.let { Utils.tryToParseRGBAHexColor(it) }
|
|
197
|
+
|
|
198
|
+
val highlightedPolygonColorParsed: Int?
|
|
199
|
+
get() = highlightedPolygonColor?.let { Utils.tryToParseRGBAHexColor(it) }
|
|
200
|
+
|
|
201
|
+
val highlightedStrokeColorParsed: Int?
|
|
202
|
+
get() = highlightedStrokeColor?.let { Utils.tryToParseRGBAHexColor(it) }
|
|
203
|
+
|
|
204
|
+
companion object {
|
|
205
|
+
var LOADING_TEXT: String? = null
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
package io.scanbot.barcodesdk.plugin.reactnative.extensions
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import io.scanbot.sdk.ui_v2.common.ScanbotColor
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
object Utils {
|
|
6
|
+
|
|
7
|
+
fun tryToParseRGBAHexColor(colorString: String): Int? {
|
|
8
|
+
return try {
|
|
9
|
+
ScanbotColor(colorString, false).toAndroid()
|
|
10
|
+
} catch (ex: Exception) {
|
|
11
|
+
null
|
|
12
|
+
}
|
|
13
|
+
}
|
|
7
14
|
}
|
|
@@ -96,6 +96,12 @@ public class ScanbotBarcodeScannerViewManagerDelegate<T extends View, U extends
|
|
|
96
96
|
case "overlayTextFormat":
|
|
97
97
|
mViewManager.setOverlayTextFormat(view, value == null ? "CODE_AND_TYPE" : (String) value);
|
|
98
98
|
break;
|
|
99
|
+
case "overlayLoadingTextValue":
|
|
100
|
+
mViewManager.setOverlayLoadingTextValue(view, value == null ? null : (String) value);
|
|
101
|
+
break;
|
|
102
|
+
case "overlayBarcodeItemOverlayViewBinder":
|
|
103
|
+
mViewManager.setOverlayBarcodeItemOverlayViewBinder(view, value == null ? false : (boolean) value);
|
|
104
|
+
break;
|
|
99
105
|
default:
|
|
100
106
|
super.setProperty(view, propName, value);
|
|
101
107
|
}
|
|
@@ -113,6 +119,9 @@ public class ScanbotBarcodeScannerViewManagerDelegate<T extends View, U extends
|
|
|
113
119
|
case "addHighLightedBarcode":
|
|
114
120
|
mViewManager.addHighLightedBarcode(view, args.getString(0));
|
|
115
121
|
break;
|
|
122
|
+
case "bindBarcodeItemOverlayView":
|
|
123
|
+
mViewManager.bindBarcodeItemOverlayView(view, args.getString(0), args.getString(1));
|
|
124
|
+
break;
|
|
116
125
|
}
|
|
117
126
|
}
|
|
118
127
|
}
|
|
@@ -38,7 +38,10 @@ public interface ScanbotBarcodeScannerViewManagerInterface<T extends View> {
|
|
|
38
38
|
void setOverlayHighlightedTextColor(T view, @Nullable Integer value);
|
|
39
39
|
void setOverlayHighlightedTextContainerColor(T view, @Nullable Integer value);
|
|
40
40
|
void setOverlayTextFormat(T view, @Nullable String value);
|
|
41
|
+
void setOverlayLoadingTextValue(T view, @Nullable String value);
|
|
42
|
+
void setOverlayBarcodeItemOverlayViewBinder(T view, boolean value);
|
|
41
43
|
void freezeCamera(T view);
|
|
42
44
|
void unfreezeCamera(T view);
|
|
43
45
|
void addHighLightedBarcode(T view, String barcodeItem);
|
|
46
|
+
void bindBarcodeItemOverlayView(T view, String barcodeItemUuid, String bindingConfig);
|
|
44
47
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
#define BarcodeItem_h
|
|
3
3
|
|
|
4
4
|
#import <Foundation/Foundation.h>
|
|
5
|
-
#import <AVFoundation/AVFoundation.h>
|
|
6
5
|
|
|
7
6
|
#import <ScanbotBarcodeScannerSDK/ScanbotBarcodeScannerSDK-Swift.h>
|
|
7
|
+
#import <ScanbotBarcodeSDKWrapper/ScanbotBarcodeSDKWrapper-Swift.h>
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
@interface BarcodeItem : NSObject
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
- (instancetype)initWithText:(NSString *)text andType:(SBSDKBarcodeType *)type;
|
|
16
16
|
- (BOOL)isEqual:(id)object;
|
|
17
17
|
|
|
18
|
+
+ (NSString *) uuidFor:(SBSDKBarcodeScannerResult *)barcodeItem;
|
|
18
19
|
@end
|
|
19
20
|
|
|
20
21
|
#endif /* BarcodeItem_h */
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
- (void) freezeCamera;
|
|
21
21
|
- (void) unfreezeCamera;
|
|
22
22
|
- (void) addHighlightedBarcode:(NSString *)barcodesJSON;
|
|
23
|
+
- (void) bindBarcodeItemOverlayView:(nonnull NSString *)barcodeItemUuid bindingConfig:(nonnull NSString *)bindingConfigJson;
|
|
23
24
|
@end
|
|
24
25
|
|
|
25
26
|
#endif /* RNScanbotBarcodeScannerPaperView_h */
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
@property (strong, nonatomic) SBSDKBarcodeScannerViewController *scannerViewController;
|
|
7
7
|
@property (strong, nonatomic) UIViewController *vc;
|
|
8
8
|
@property (nonatomic) BOOL scanningEnabled;
|
|
9
|
+
@property (nonatomic) NSString* _Nullable barcodeItemOverlayViewLoadigText;
|
|
10
|
+
@property (atomic) NSMutableDictionary* _Nullable barcodeItemOverlayViewBinders;
|
|
9
11
|
@end
|
|
10
12
|
|
|
11
13
|
@implementation RNScanbotBarcodeScannerLegacyView
|
|
@@ -18,6 +20,8 @@
|
|
|
18
20
|
if (self = [super initWithFrame:frame]) {
|
|
19
21
|
_scanningEnabled = true;
|
|
20
22
|
_selectedBarcodes = [NSMutableSet set];
|
|
23
|
+
_barcodeItemOverlayViewLoadigText = nil;
|
|
24
|
+
_barcodeItemOverlayViewBinders = nil;
|
|
21
25
|
|
|
22
26
|
self.vc = [[UIViewController alloc] init];
|
|
23
27
|
self.vc.view = self;
|
|
@@ -42,6 +46,9 @@
|
|
|
42
46
|
self.scannerViewController = nil;
|
|
43
47
|
self.vc = nil;
|
|
44
48
|
self.selectedBarcodes = [NSMutableSet set];
|
|
49
|
+
self.barcodeItemOverlayViewLoadigText = nil;
|
|
50
|
+
self.barcodeItemOverlayViewBinders = nil;
|
|
51
|
+
|
|
45
52
|
[super removeFromSuperview];
|
|
46
53
|
}
|
|
47
54
|
|
|
@@ -210,6 +217,17 @@
|
|
|
210
217
|
[RNScanbotBarcodeScannerViewControllerWrapper setOverlayTextFormat:self.scannerViewController value: decodedConfig.textFormat];
|
|
211
218
|
}
|
|
212
219
|
|
|
220
|
+
- (void) setOverlayLoadingTextValue:(NSString * _Nullable) value {
|
|
221
|
+
self.barcodeItemOverlayViewLoadigText = value;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
- (void) setOverlayBarcodeItemOverlayViewBinder:(BOOL) value {
|
|
225
|
+
|
|
226
|
+
if(value){
|
|
227
|
+
self.barcodeItemOverlayViewBinders = [[NSMutableDictionary alloc] init];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
213
231
|
- (void) freezeCamera {
|
|
214
232
|
[RNScanbotBarcodeScannerViewControllerWrapper freezeCamera:self.scannerViewController];
|
|
215
233
|
}
|
|
@@ -218,6 +236,12 @@
|
|
|
218
236
|
[RNScanbotBarcodeScannerViewControllerWrapper unfreezeCamera:self.scannerViewController];
|
|
219
237
|
}
|
|
220
238
|
|
|
239
|
+
- (void)bindBarcodeItemOverlayView:(nonnull NSString *)barcodeItemUuid bindingConfig:(nonnull NSString *)bindingConfigJson {
|
|
240
|
+
[RNScanbotBarcodeScannerViewControllerWrapper updateBarcodeItemOverlayViewBinderInDictionary:self.barcodeItemOverlayViewBinders
|
|
241
|
+
barcodeItemUuid:barcodeItemUuid
|
|
242
|
+
barcodeItemOverlayViewConfigJson:bindingConfigJson];
|
|
243
|
+
}
|
|
244
|
+
|
|
221
245
|
- (void)barcodeScannerController:(nonnull SBSDKBarcodeScannerViewController *)controller
|
|
222
246
|
didDetectBarcodes:(nonnull NSArray<SBSDKBarcodeScannerResult *> *)codes {
|
|
223
247
|
|
|
@@ -228,6 +252,10 @@
|
|
|
228
252
|
NSString *result = [RNScanbotBarcodeScannerViewControllerWrapper jsonFromResultOrNil:codes];
|
|
229
253
|
if(result != nil){
|
|
230
254
|
self.onBarcodeScannerResult(@{@"result":result});
|
|
255
|
+
|
|
256
|
+
[RNScanbotBarcodeScannerViewControllerWrapper addBarcodeItemOverlayViewInitialBinderInDictionary:self.barcodeItemOverlayViewBinders
|
|
257
|
+
loadingText:self.barcodeItemOverlayViewLoadigText
|
|
258
|
+
barcodes:codes];
|
|
231
259
|
}
|
|
232
260
|
}
|
|
233
261
|
|
|
@@ -254,19 +282,48 @@
|
|
|
254
282
|
|
|
255
283
|
- (SBSDKBarcodeTrackedViewPolygonStyle *)barcodeTrackingOverlay:(SBSDKBarcodeTrackingOverlayController * _Nonnull)controller polygonStyleFor:(SBSDKBarcodeScannerResult * _Nonnull)barcode {
|
|
256
284
|
|
|
285
|
+
NSString * _Nonnull barcodeItemUuid = [BarcodeItem uuidFor:barcode];
|
|
286
|
+
NSString * _Nullable barcodeItemOverlayViewBindingJson = nil;
|
|
287
|
+
|
|
288
|
+
if (self.barcodeItemOverlayViewBinders != nil) {
|
|
289
|
+
barcodeItemOverlayViewBindingJson = [self.barcodeItemOverlayViewBinders objectForKey:barcodeItemUuid];
|
|
290
|
+
}
|
|
291
|
+
|
|
257
292
|
return [RNScanbotBarcodeScannerViewControllerWrapper polygonForSelectedBarcode:barcode
|
|
258
293
|
selectedBarcodes:self.selectedBarcodes
|
|
294
|
+
barcodeItemOverlayViewBindingJson:barcodeItemOverlayViewBindingJson
|
|
259
295
|
controller:self.scannerViewController];
|
|
260
296
|
|
|
261
297
|
}
|
|
262
298
|
|
|
263
299
|
- (SBSDKBarcodeTrackedViewTextStyle *)barcodeTrackingOverlay:(SBSDKBarcodeTrackingOverlayController * _Nonnull)controller textStyleFor:(SBSDKBarcodeScannerResult * _Nonnull)barcode {
|
|
264
300
|
|
|
265
|
-
|
|
266
|
-
|
|
301
|
+
NSString * _Nonnull barcodeItemUuid = [BarcodeItem uuidFor:barcode];
|
|
302
|
+
NSString * _Nullable barcodeItemOverlayViewBindingJson = nil;
|
|
303
|
+
|
|
304
|
+
if (self.barcodeItemOverlayViewBinders != nil) {
|
|
305
|
+
barcodeItemOverlayViewBindingJson = [self.barcodeItemOverlayViewBinders objectForKey:barcodeItemUuid];
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return [RNScanbotBarcodeScannerViewControllerWrapper scannedBarcodeOverlayViewTextStyle:barcode
|
|
309
|
+
selectedBarcodes:self.selectedBarcodes
|
|
310
|
+
barcodeItemOverlayViewBindingJson:barcodeItemOverlayViewBindingJson
|
|
267
311
|
controller:self.scannerViewController];
|
|
268
312
|
}
|
|
269
313
|
|
|
314
|
+
- (NSString * _Nonnull)barcodeTrackingOverlay:(SBSDKBarcodeTrackingOverlayController * _Nonnull)controller overrideTextFor:(SBSDKBarcodeScannerResult * _Nonnull)barcode proposedString:(NSString * _Nonnull)proposedString {
|
|
315
|
+
|
|
316
|
+
NSString * _Nonnull barcodeItemUuid = [BarcodeItem uuidFor:barcode];
|
|
317
|
+
NSString * _Nullable barcodeItemOverlayViewBindingJson = nil;
|
|
318
|
+
|
|
319
|
+
if (self.barcodeItemOverlayViewBinders != nil) {
|
|
320
|
+
barcodeItemOverlayViewBindingJson = [self.barcodeItemOverlayViewBinders objectForKey:barcodeItemUuid];
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return [RNScanbotBarcodeScannerViewControllerWrapper scannedBarcodeOverlayViewText:barcodeItemUuid
|
|
324
|
+
proposedString:proposedString
|
|
325
|
+
barcodeItemOverlayViewBindingJson:barcodeItemOverlayViewBindingJson];
|
|
326
|
+
}
|
|
270
327
|
|
|
271
328
|
@end
|
|
272
329
|
|