@@ -38,34 +38,34 @@ public final class Keyboard {
38
38
}
39
39
}
40
40
41
- enum Event {
41
+ public enum Event {
42
42
case willChangeFrame
43
43
case willShow
44
44
case willHide
45
45
}
46
46
47
- class Observer : Equatable {
48
- var callback : ( Animator ? ) -> Void
49
- let event : Event
47
+ public class Observer : Equatable {
48
+ fileprivate var callback : ( Animator ? ) -> Void
49
+ public let event : Event
50
50
51
- func remove( ) {
51
+ public func remove( ) {
52
52
Keyboard . removeObserver ( self )
53
53
}
54
54
55
- init ( event: Event , block: @escaping ( Animator ? ) -> Void ) {
55
+ fileprivate init ( event: Event , block: @escaping ( Animator ? ) -> Void ) {
56
56
self . event = event
57
57
self . callback = block
58
58
}
59
59
60
- static func == ( lhs: Observer , rhs: Observer ) -> Bool {
60
+ public static func == ( lhs: Observer , rhs: Observer ) -> Bool {
61
61
return lhs === rhs
62
62
}
63
63
}
64
64
65
65
private static var observers : [ Observer ] = [ ] {
66
66
didSet {
67
67
if observers. isEmpty {
68
- unregisterForKeyboardNotifications ( )
68
+ deregisterForKeyboardNotifications ( )
69
69
} else {
70
70
registerForKeyboardNotificationsIfNeeded ( )
71
71
}
@@ -122,7 +122,7 @@ public final class Keyboard {
122
122
isObservingKeyboardNotifications = true
123
123
}
124
124
125
- static func unregisterForKeyboardNotifications ( ) {
125
+ static func deregisterForKeyboardNotifications ( ) {
126
126
for notificationName in keyboardNotificationNames {
127
127
NotificationCenter . default. removeObserver (
128
128
self ,
@@ -152,13 +152,13 @@ public final class Keyboard {
152
152
}
153
153
154
154
@discardableResult
155
- static func addObserver( for event: Event , _ body: @escaping ( Animator ? ) -> Void ) -> Observer {
155
+ public static func addObserver( for event: Event , _ body: @escaping ( Animator ? ) -> Void ) -> Observer {
156
156
let observer = Observer ( event: event, block: body)
157
157
observers. append ( observer)
158
158
return observer
159
159
}
160
160
161
- static func removeObserver( _ observer: Observer ) {
161
+ public static func removeObserver( _ observer: Observer ) {
162
162
observers = observers. filter { existing in
163
163
existing != observer
164
164
}
@@ -172,7 +172,7 @@ public final class Keyboard {
172
172
173
173
// MARK: - Notification handling
174
174
@objc
175
- static func handleKeyboardNotification( notification: Notification ) {
175
+ private static func handleKeyboardNotification( notification: Notification ) {
176
176
177
177
guard let userInfo = notification. userInfo else {
178
178
return
@@ -185,7 +185,6 @@ public final class Keyboard {
185
185
switch notification. name {
186
186
187
187
case UIResponder . keyboardWillChangeFrameNotification:
188
-
189
188
withObservers ( for: . willChangeFrame) { observer in
190
189
observer. callback ( animator)
191
190
}
@@ -208,12 +207,12 @@ public final class Keyboard {
208
207
}
209
208
210
209
@objc
211
- static func handleApplicationNotification( notification: Notification ) {
210
+ private static func handleApplicationNotification( notification: Notification ) {
212
211
213
212
switch notification. name {
214
213
215
214
case UIApplication . willResignActiveNotification:
216
- unregisterForKeyboardNotifications ( )
215
+ deregisterForKeyboardNotifications ( )
217
216
218
217
case UIApplication . didBecomeActiveNotification:
219
218
registerForKeyboardNotificationsIfNeeded ( )
0 commit comments