scandit-capacitor-datacapture-barcode 8.1.1 → 8.2.0
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/ScanditCapacitorDatacaptureBarcode.podspec +1 -1
- package/android/build.gradle +71 -23
- package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/ScanditBarcodeNative.java +593 -0
- package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/ar/BarcodeArViewHandler.java +146 -0
- package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/count/BarcodeCountViewHandler.java +143 -0
- package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/find/BarcodeFindViewHandler.java +181 -0
- package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/pick/BarcodePickViewHandler.java +152 -0
- package/dist/barcode.js +5271 -1377
- package/dist/barcode.js.map +1 -1
- package/dist/dts/definitions.d.ts +35 -8
- package/dist/dts/ts/BarcodeArView.d.ts +57 -0
- package/dist/dts/ts/BarcodeBatchAdvancedOverlay.d.ts +1 -0
- package/dist/dts/ts/BarcodeFindView.d.ts +1 -0
- package/dist/dts/web.d.ts +1 -3
- package/dist/index.js +562 -316
- package/dist/index.js.map +1 -1
- package/ios/Sources/ScanditCapacitorBarcode/BarcodeArViewHandler.swift +146 -0
- package/ios/Sources/ScanditCapacitorBarcode/BarcodeCountViewHandler.swift +11 -0
- package/ios/Sources/ScanditCapacitorBarcode/BarcodeFindViewHandler.swift +43 -25
- package/ios/Sources/ScanditCapacitorBarcode/BarcodePickViewHandler.swift +11 -8
- package/ios/Sources/ScanditCapacitorBarcode/ScanditBarcodeCapture.swift +293 -1910
- package/package.json +7 -7
- package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/ScanditBarcodeNative.kt +0 -1569
- package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/count/BarcodeCountViewHandler.kt +0 -137
- package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/factories/BarcodeCaptureActionFactory.kt +0 -13
- package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/find/BarcodeFindViewHandler.kt +0 -166
- package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/pick/BarcodePickViewHandler.kt +0 -136
- package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/utils/AdvancedOverlayViewSerialization.kt +0 -89
- package/ios/Sources/ScanditCapacitorBarcode/BlockingCallbackResults.swift +0 -73
- package/ios/Sources/ScanditCapacitorBarcode/CommandJSONArgument+ScanditBarcodeCapture.swift +0 -70
- package/ios/Sources/ScanditCapacitorBarcode/TappableBase64ImageView.swift +0 -63
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the Scandit Data Capture SDK
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023- Scandit AG. All rights reserved.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import ScanditCapacitorDatacaptureCore
|
|
8
|
+
import ScanditFrameworksCore
|
|
9
|
+
import UIKit
|
|
10
|
+
import WebKit
|
|
11
|
+
|
|
12
|
+
class BarcodeArViewHandler {
|
|
13
|
+
private weak var webView: WKWebView?
|
|
14
|
+
private weak var containerView: UIView?
|
|
15
|
+
|
|
16
|
+
private var top: NSLayoutConstraint?
|
|
17
|
+
private var left: NSLayoutConstraint?
|
|
18
|
+
private var width: NSLayoutConstraint?
|
|
19
|
+
private var height: NSLayoutConstraint?
|
|
20
|
+
|
|
21
|
+
private var position = CGPoint.zero
|
|
22
|
+
private var size = CGSize.zero
|
|
23
|
+
private var shouldBeUnderWebView = false
|
|
24
|
+
|
|
25
|
+
private var constraints: [NSLayoutConstraint] {
|
|
26
|
+
[top, left, width, height].compactMap { $0 }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
init(relativeTo webView: WKWebView) {
|
|
30
|
+
self.webView = webView
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// Add the BarcodeAr view container to the view hierarchy.
|
|
34
|
+
///
|
|
35
|
+
/// - Parameter container: The container view to add
|
|
36
|
+
func addBarcodeArViewContainer(_ container: UIView) {
|
|
37
|
+
guard let webView = webView else { return }
|
|
38
|
+
|
|
39
|
+
self.containerView = container
|
|
40
|
+
container.translatesAutoresizingMaskIntoConstraints = false
|
|
41
|
+
|
|
42
|
+
// Add container as a subview of the webView's superview
|
|
43
|
+
if let parent = webView.superview {
|
|
44
|
+
parent.addSubview(container)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Bring webView to front and make it transparent
|
|
48
|
+
webView.superview?.bringSubviewToFront(webView)
|
|
49
|
+
webView.isOpaque = false
|
|
50
|
+
webView.backgroundColor = .clear
|
|
51
|
+
webView.scrollView.backgroundColor = .clear
|
|
52
|
+
|
|
53
|
+
resetConstraints()
|
|
54
|
+
update()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/// Update the position and size of the BarcodeAr view container.
|
|
58
|
+
///
|
|
59
|
+
/// - Parameter positionAndSizeJSON: The position and size information
|
|
60
|
+
func updatePositionAndSize(fromJSON positionAndSizeJSON: ViewPositionAndSizeJSON) {
|
|
61
|
+
position = positionAndSizeJSON.position
|
|
62
|
+
size = positionAndSizeJSON.size
|
|
63
|
+
shouldBeUnderWebView = positionAndSizeJSON.shouldBeUnderWebView
|
|
64
|
+
update()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/// Clean up and remove the container view.
|
|
68
|
+
func disposeCurrentView() {
|
|
69
|
+
containerView?.removeFromSuperview()
|
|
70
|
+
containerView = nil
|
|
71
|
+
|
|
72
|
+
// Restore webView opacity
|
|
73
|
+
webView?.isOpaque = true
|
|
74
|
+
webView?.backgroundColor = nil
|
|
75
|
+
webView?.scrollView.backgroundColor = nil
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// MARK: - Private Methods
|
|
79
|
+
|
|
80
|
+
private func update() {
|
|
81
|
+
updateConstraints()
|
|
82
|
+
updateLayering()
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private func resetConstraints() {
|
|
86
|
+
top = nil
|
|
87
|
+
left = nil
|
|
88
|
+
width = nil
|
|
89
|
+
height = nil
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private func updateConstraints() {
|
|
93
|
+
guard let containerView = containerView, let webView = self.webView
|
|
94
|
+
else {
|
|
95
|
+
assert(true, "barcodeArView or containerView is not set")
|
|
96
|
+
return
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if size.width == 0 || size.height == 0 {
|
|
100
|
+
containerView.isHidden = true
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
containerView.isHidden = false
|
|
105
|
+
|
|
106
|
+
let topConstant = position.y + webView.adjustedContentInset.top
|
|
107
|
+
let leftConstant = position.x + webView.adjustedContentInset.left
|
|
108
|
+
|
|
109
|
+
if let top = top {
|
|
110
|
+
top.constant = topConstant
|
|
111
|
+
} else {
|
|
112
|
+
top = containerView.topAnchor.constraint(equalTo: webView.topAnchor, constant: topConstant)
|
|
113
|
+
top?.isActive = true
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if let left = left {
|
|
117
|
+
left.constant = leftConstant
|
|
118
|
+
} else {
|
|
119
|
+
left = containerView.leadingAnchor.constraint(equalTo: webView.leadingAnchor, constant: leftConstant)
|
|
120
|
+
left?.isActive = true
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
width?.isActive = false
|
|
124
|
+
self.width = containerView.widthAnchor.constraint(equalToConstant: size.width)
|
|
125
|
+
self.width?.isActive = true
|
|
126
|
+
|
|
127
|
+
height?.isActive = false
|
|
128
|
+
self.height = containerView.heightAnchor.constraint(equalToConstant: size.height)
|
|
129
|
+
self.height?.isActive = true
|
|
130
|
+
|
|
131
|
+
containerView.superview?.layoutIfNeeded()
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private func updateLayering() {
|
|
135
|
+
guard let containerView = containerView else { return }
|
|
136
|
+
guard let webView = webView else { return }
|
|
137
|
+
guard let parent = webView.superview else { return }
|
|
138
|
+
|
|
139
|
+
if shouldBeUnderWebView {
|
|
140
|
+
parent.sendSubviewToBack(containerView)
|
|
141
|
+
parent.bringSubviewToFront(webView)
|
|
142
|
+
} else {
|
|
143
|
+
parent.bringSubviewToFront(containerView)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -119,4 +119,15 @@ class BarcodeCountViewHandler {
|
|
|
119
119
|
barcodeCountView.superview?.bringSubviewToFront(barcodeCountView)
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
+
|
|
123
|
+
/// Clean up and remove the current BarcodeCount view.
|
|
124
|
+
func disposeCurrentView() {
|
|
125
|
+
// Deactivate constraints before removing the view
|
|
126
|
+
NSLayoutConstraint.deactivate(constraints)
|
|
127
|
+
resetConstraints()
|
|
128
|
+
|
|
129
|
+
// Remove the view from the hierarchy synchronously
|
|
130
|
+
currentBarcodeCountView?.removeFromSuperview()
|
|
131
|
+
currentBarcodeCountView = nil
|
|
132
|
+
}
|
|
122
133
|
}
|
|
@@ -6,15 +6,32 @@
|
|
|
6
6
|
|
|
7
7
|
import ScanditBarcodeCapture
|
|
8
8
|
import ScanditCapacitorDatacaptureCore
|
|
9
|
+
import UIKit
|
|
9
10
|
import WebKit
|
|
10
11
|
|
|
11
12
|
class BarcodeFindViewHandler {
|
|
12
13
|
let webView: WKWebView
|
|
13
14
|
|
|
15
|
+
/// Container view that holds the BarcodeFindView.
|
|
16
|
+
/// The handler positions this container, and the BarcodeFindView fills it.
|
|
17
|
+
/// This allows the native view's internal layout to remain intact.
|
|
18
|
+
private var containerView: UIView?
|
|
19
|
+
|
|
20
|
+
var container: UIView {
|
|
21
|
+
if let existing = containerView, existing.superview != nil {
|
|
22
|
+
return existing
|
|
23
|
+
}
|
|
24
|
+
let view = UIView()
|
|
25
|
+
view.translatesAutoresizingMaskIntoConstraints = false
|
|
26
|
+
view.backgroundColor = .clear
|
|
27
|
+
webView.addSubview(view)
|
|
28
|
+
containerView = view
|
|
29
|
+
return view
|
|
30
|
+
}
|
|
31
|
+
|
|
14
32
|
var barcodeFindView: BarcodeFindView? {
|
|
15
33
|
didSet {
|
|
16
|
-
guard
|
|
17
|
-
barcodeFindView.translatesAutoresizingMaskIntoConstraints = false
|
|
34
|
+
guard barcodeFindView != nil else { return }
|
|
18
35
|
resetConstraints()
|
|
19
36
|
update()
|
|
20
37
|
}
|
|
@@ -68,61 +85,62 @@ class BarcodeFindViewHandler {
|
|
|
68
85
|
}
|
|
69
86
|
|
|
70
87
|
private func updateConstraints() {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
88
|
+
// Position the container, not the BarcodeFindView directly.
|
|
89
|
+
// The BarcodeFindView fills the container via constraints set by the deserializer.
|
|
75
90
|
let topConstant = position.y + webView.adjustedContentInset.top
|
|
76
91
|
let leftConstant = position.x + webView.adjustedContentInset.left
|
|
77
92
|
|
|
78
93
|
if let top = top {
|
|
79
94
|
top.constant = topConstant
|
|
80
95
|
} else {
|
|
81
|
-
top =
|
|
96
|
+
top = container.topAnchor.constraint(equalTo: webView.topAnchor, constant: topConstant)
|
|
82
97
|
top?.isActive = true
|
|
83
98
|
}
|
|
84
99
|
|
|
85
100
|
if let left = left {
|
|
86
101
|
left.constant = leftConstant
|
|
87
102
|
} else {
|
|
88
|
-
left =
|
|
103
|
+
left = container.leadingAnchor.constraint(equalTo: webView.leadingAnchor, constant: leftConstant)
|
|
89
104
|
left?.isActive = true
|
|
90
105
|
}
|
|
91
106
|
|
|
92
107
|
if let width = width {
|
|
93
108
|
width.constant = size.width
|
|
94
109
|
} else {
|
|
95
|
-
width =
|
|
110
|
+
width = container.widthAnchor.constraint(equalToConstant: size.width)
|
|
96
111
|
width?.isActive = true
|
|
97
112
|
}
|
|
98
113
|
|
|
99
114
|
if let height = height {
|
|
100
115
|
height.constant = size.height
|
|
101
116
|
} else {
|
|
102
|
-
height =
|
|
117
|
+
height = container.heightAnchor.constraint(equalToConstant: size.height)
|
|
103
118
|
height?.isActive = true
|
|
104
119
|
}
|
|
105
120
|
|
|
106
|
-
|
|
121
|
+
container.layoutIfNeeded()
|
|
107
122
|
}
|
|
108
123
|
|
|
109
124
|
private func updatePosition() {
|
|
110
|
-
guard let barcodeFindView = barcodeFindView else {
|
|
111
|
-
return
|
|
112
|
-
}
|
|
113
|
-
|
|
114
125
|
if shouldBeUnderWebView {
|
|
115
|
-
|
|
116
|
-
barcodeFindView.superview?.sendSubviewToBack(barcodeFindView)
|
|
117
|
-
#else
|
|
118
|
-
barcodeFindView.superview?.sendSubview(toBack: barcodeFindView)
|
|
119
|
-
#endif
|
|
126
|
+
webView.sendSubviewToBack(container)
|
|
120
127
|
} else {
|
|
121
|
-
|
|
122
|
-
barcodeFindView.superview?.bringSubviewToFront(barcodeFindView)
|
|
123
|
-
#else
|
|
124
|
-
barcodeFindView.superview?.bringSubview(toFront: barcodeFindView)
|
|
125
|
-
#endif
|
|
128
|
+
webView.bringSubviewToFront(container)
|
|
126
129
|
}
|
|
127
130
|
}
|
|
131
|
+
|
|
132
|
+
/// Clean up and remove the current BarcodeFind view.
|
|
133
|
+
func disposeCurrentView() {
|
|
134
|
+
// Deactivate constraints before removing the container
|
|
135
|
+
NSLayoutConstraint.deactivate(constraints)
|
|
136
|
+
resetConstraints()
|
|
137
|
+
|
|
138
|
+
// Remove the BarcodeFindView from the container (it was added by the deserializer)
|
|
139
|
+
barcodeFindView?.removeFromSuperview()
|
|
140
|
+
barcodeFindView = nil
|
|
141
|
+
|
|
142
|
+
// Remove the container from the webView and clear the reference
|
|
143
|
+
containerView?.removeFromSuperview()
|
|
144
|
+
containerView = nil
|
|
145
|
+
}
|
|
128
146
|
}
|
|
@@ -111,17 +111,20 @@ class BarcodePickViewHandler {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
if shouldBeUnderWebView {
|
|
114
|
-
#if swift(>=5.0)
|
|
115
114
|
barcodePickView.superview?.sendSubviewToBack(barcodePickView)
|
|
116
|
-
#else
|
|
117
|
-
barcodePickView.superview?.sendSubview(toBack: barcodePickView)
|
|
118
|
-
#endif
|
|
119
115
|
} else {
|
|
120
|
-
#if swift(>=5.0)
|
|
121
116
|
barcodePickView.superview?.bringSubviewToFront(barcodePickView)
|
|
122
|
-
#else
|
|
123
|
-
barcodePickView.superview?.bringSubview(toFront: barcodePickView)
|
|
124
|
-
#endif
|
|
125
117
|
}
|
|
126
118
|
}
|
|
119
|
+
|
|
120
|
+
/// Clean up and remove the current BarcodePick view.
|
|
121
|
+
func disposeCurrentView() {
|
|
122
|
+
// Deactivate constraints before removing the view
|
|
123
|
+
NSLayoutConstraint.deactivate(constraints)
|
|
124
|
+
resetConstraints()
|
|
125
|
+
|
|
126
|
+
// Remove the view from the hierarchy synchronously
|
|
127
|
+
currentBarcodePickView?.removeFromSuperview()
|
|
128
|
+
currentBarcodePickView = nil
|
|
129
|
+
}
|
|
127
130
|
}
|