raxon-barcode-scanner 0.1.2 → 0.1.3
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.
|
@@ -33,7 +33,7 @@ public final class RaxonBarcodeScannerModule: Module {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
private func startListening(options: [String: Any]?) {
|
|
36
|
-
|
|
36
|
+
if isListening {
|
|
37
37
|
stopListening()
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -52,7 +52,8 @@ public final class RaxonBarcodeScannerModule: Module {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
private func setupKeyboardCapture() {
|
|
55
|
-
|
|
55
|
+
// UIApplication'dan aktif view controller'ı al
|
|
56
|
+
guard let viewController = findActiveViewController() else {
|
|
56
57
|
return
|
|
57
58
|
}
|
|
58
59
|
|
|
@@ -67,6 +68,22 @@ public final class RaxonBarcodeScannerModule: Module {
|
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
|
|
71
|
+
private func findActiveViewController() -> UIViewController? {
|
|
72
|
+
// UIApplication üzerinden root view controller'ı bul
|
|
73
|
+
guard let windowScene = UIApplication.shared.connectedScenes
|
|
74
|
+
.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene,
|
|
75
|
+
let keyWindow = windowScene.windows.first(where: { $0.isKeyWindow }) else {
|
|
76
|
+
return nil
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var topController = keyWindow.rootViewController
|
|
80
|
+
while let presentedController = topController?.presentedViewController {
|
|
81
|
+
topController = presentedController
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return topController
|
|
85
|
+
}
|
|
86
|
+
|
|
70
87
|
private func teardownKeyboardCapture() {
|
|
71
88
|
keyboardHandler?.stopListening()
|
|
72
89
|
keyboardHandler = nil
|
|
@@ -163,14 +180,18 @@ private final class ExternalKeyboardHandler {
|
|
|
163
180
|
|
|
164
181
|
var char: Character?
|
|
165
182
|
|
|
166
|
-
// UIKey.characters ile dene
|
|
167
|
-
|
|
183
|
+
// UIKey.characters ile dene (String, Optional değil)
|
|
184
|
+
let chars = key.characters
|
|
185
|
+
if !chars.isEmpty {
|
|
168
186
|
char = chars.first
|
|
169
187
|
}
|
|
170
188
|
|
|
171
|
-
// UIKey.charactersIgnoringModifiers ile dene (
|
|
172
|
-
if char == nil
|
|
173
|
-
|
|
189
|
+
// UIKey.charactersIgnoringModifiers ile dene (String, Optional değil)
|
|
190
|
+
if char == nil {
|
|
191
|
+
let charsIgnoringModifiers = key.charactersIgnoringModifiers
|
|
192
|
+
if !charsIgnoringModifiers.isEmpty {
|
|
193
|
+
char = charsIgnoringModifiers.first
|
|
194
|
+
}
|
|
174
195
|
}
|
|
175
196
|
|
|
176
197
|
// Eğer hala nil ise, keyCode'dan çevir
|
|
@@ -316,13 +337,4 @@ extension UIViewController {
|
|
|
316
337
|
// Orijinal implementasyonu çağır
|
|
317
338
|
raxon_pressesEnded(presses, with: event)
|
|
318
339
|
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// MARK: - UIKey Extensions
|
|
322
|
-
|
|
323
|
-
@available(iOS 13.4, *)
|
|
324
|
-
extension UIKey {
|
|
325
|
-
var keyCode: UIKeyboardHIDUsage {
|
|
326
|
-
return self.keyCode
|
|
327
|
-
}
|
|
328
340
|
}
|