aix 0.7.0 → 0.7.1-alpha.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/Aix.podspec CHANGED
@@ -22,6 +22,9 @@ Pod::Spec.new do |s|
22
22
  "cpp/**/*.{hpp,cpp}",
23
23
  ]
24
24
 
25
+ # Force -ObjC linker flag in consuming apps to prevent +load method stripping in release builds
26
+ s.user_target_xcconfig = { 'OTHER_LDFLAGS' => '-ObjC' }
27
+
25
28
  load 'nitrogen/generated/ios/Aix+autolinking.rb'
26
29
  add_nitrogen_files(s)
27
30
 
@@ -0,0 +1,118 @@
1
+ //
2
+ // AixKeyboardManager.swift
3
+ // Aix
4
+ //
5
+ // Keyboard notification manager for tracking keyboard state.
6
+ //
7
+
8
+ import Foundation
9
+ import UIKit
10
+
11
+ // Source - https://stackoverflow.com/a
12
+ // Posted by Vasily Bodnarchuk, modified by community. See post 'Timeline' for change history
13
+ // Retrieved 2026-01-07, License - CC BY-SA 4.0
14
+
15
+ protocol KeyboardNotificationsDelegate: AnyObject {
16
+ func keyboardWillShow(notification: NSNotification)
17
+ func keyboardWillHide(notification: NSNotification)
18
+ func keyboardDidShow(notification: NSNotification)
19
+ func keyboardDidHide(notification: NSNotification)
20
+ func keyboardWillChangeFrame(notification: NSNotification)
21
+ }
22
+
23
+ extension KeyboardNotificationsDelegate {
24
+ func keyboardWillShow(notification: NSNotification) {}
25
+ func keyboardWillHide(notification: NSNotification) {}
26
+ func keyboardDidShow(notification: NSNotification) {}
27
+ func keyboardDidHide(notification: NSNotification) {}
28
+ func keyboardWillChangeFrame(notification: NSNotification) {}
29
+ }
30
+
31
+ class KeyboardNotifications: NSObject {
32
+ fileprivate var _isEnabled: Bool
33
+ fileprivate var notifications: [KeyboardNotificationsType]
34
+ fileprivate weak var delegate: KeyboardNotificationsDelegate?
35
+
36
+ init(notifications: [KeyboardNotificationsType], delegate: KeyboardNotificationsDelegate) {
37
+ _isEnabled = false
38
+ self.notifications = notifications
39
+ self.delegate = delegate
40
+ super.init()
41
+ }
42
+
43
+ deinit { isEnabled = false }
44
+ }
45
+
46
+ // MARK: - enums
47
+ extension KeyboardNotifications {
48
+
49
+ enum KeyboardNotificationsType {
50
+ case willShow, willHide, didShow, didHide, willChangeFrame
51
+
52
+ var selector: Selector {
53
+ switch self {
54
+ case .willShow: return #selector(keyboardWillShow(notification:))
55
+ case .willHide: return #selector(keyboardWillHide(notification:))
56
+ case .didShow: return #selector(keyboardDidShow(notification:))
57
+ case .didHide: return #selector(keyboardDidHide(notification:))
58
+ case .willChangeFrame: return #selector(keyboardWillChangeFrame(notification:))
59
+ }
60
+ }
61
+
62
+ var notificationName: NSNotification.Name {
63
+ switch self {
64
+ case .willShow: return UIResponder.keyboardWillShowNotification
65
+ case .willHide: return UIResponder.keyboardWillHideNotification
66
+ case .didShow: return UIResponder.keyboardDidShowNotification
67
+ case .didHide: return UIResponder.keyboardDidHideNotification
68
+ case .willChangeFrame: return UIResponder.keyboardWillChangeFrameNotification
69
+ }
70
+ }
71
+ }
72
+ }
73
+
74
+ // MARK: - isEnabled
75
+ extension KeyboardNotifications {
76
+
77
+ private func addObserver(type: KeyboardNotificationsType) {
78
+ NotificationCenter.default.addObserver(self, selector: type.selector, name: type.notificationName, object: nil)
79
+ }
80
+
81
+ var isEnabled: Bool {
82
+ set {
83
+ if newValue {
84
+ for notificaton in notifications { addObserver(type: notificaton) }
85
+ } else {
86
+ NotificationCenter.default.removeObserver(self)
87
+ }
88
+ _isEnabled = newValue
89
+ }
90
+
91
+ get { return _isEnabled }
92
+ }
93
+
94
+ }
95
+
96
+ // MARK: - Notification functions
97
+ extension KeyboardNotifications {
98
+
99
+ @objc func keyboardWillShow(notification: NSNotification) {
100
+ delegate?.keyboardWillShow(notification: notification)
101
+ }
102
+
103
+ @objc func keyboardWillHide(notification: NSNotification) {
104
+ delegate?.keyboardWillHide(notification: notification)
105
+ }
106
+
107
+ @objc func keyboardDidShow(notification: NSNotification) {
108
+ delegate?.keyboardDidShow(notification: notification)
109
+ }
110
+
111
+ @objc func keyboardDidHide(notification: NSNotification) {
112
+ delegate?.keyboardDidHide(notification: notification)
113
+ }
114
+
115
+ @objc func keyboardWillChangeFrame(notification: NSNotification) {
116
+ delegate?.keyboardWillChangeFrame(notification: notification)
117
+ }
118
+ }