raxon-barcode-scanner 0.1.1 → 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
- guard !isListening else {
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
- guard let viewController = appContext?.currentViewController else {
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
- if let chars = key.characters, !chars.isEmpty {
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 (Shift/Ctrl/Alt olmadan)
172
- if char == nil, let chars = key.charactersIgnoringModifiers, !chars.isEmpty {
173
- char = chars.first
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
@@ -289,11 +310,13 @@ private final class ExternalKeyboardHandler {
289
310
  }
290
311
  }
291
312
 
292
- // MARK: - UIViewController Extension
313
+ // MARK: - AssociatedKeys
293
314
 
294
- private var AssociatedKeys = (
295
- keyboardHandler: "raxon_keyboardHandler"
296
- )
315
+ private enum AssociatedKeys {
316
+ static var keyboardHandler: UInt8 = 0
317
+ }
318
+
319
+ // MARK: - UIViewController Extension
297
320
 
298
321
  @available(iOS 13.4, *)
299
322
  extension UIViewController {
@@ -314,13 +337,4 @@ extension UIViewController {
314
337
  // Orijinal implementasyonu çağır
315
338
  raxon_pressesEnded(presses, with: event)
316
339
  }
317
- }
318
-
319
- // MARK: - UIKey Extensions
320
-
321
- @available(iOS 13.4, *)
322
- extension UIKey {
323
- var keyCode: UIKeyboardHIDUsage {
324
- return self.keyCode
325
- }
326
340
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "raxon-barcode-scanner",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Zebra and enterprise barcode scanner hook for React Native Expo apps",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",