Skip to content

Commit c02a9bd

Browse files
committed
Fix ACL issues for Keyboard type
1 parent 2e601ad commit c02a9bd

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

Sources/LayoutAid/Keyboard.swift

+14-15
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,34 @@ public final class Keyboard {
3838
}
3939
}
4040

41-
enum Event {
41+
public enum Event {
4242
case willChangeFrame
4343
case willShow
4444
case willHide
4545
}
4646

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
5050

51-
func remove() {
51+
public func remove() {
5252
Keyboard.removeObserver(self)
5353
}
5454

55-
init(event: Event, block: @escaping (Animator?) -> Void) {
55+
fileprivate init(event: Event, block: @escaping (Animator?) -> Void) {
5656
self.event = event
5757
self.callback = block
5858
}
5959

60-
static func == (lhs: Observer, rhs: Observer) -> Bool {
60+
public static func == (lhs: Observer, rhs: Observer) -> Bool {
6161
return lhs === rhs
6262
}
6363
}
6464

6565
private static var observers: [Observer] = [] {
6666
didSet {
6767
if observers.isEmpty {
68-
unregisterForKeyboardNotifications()
68+
deregisterForKeyboardNotifications()
6969
} else {
7070
registerForKeyboardNotificationsIfNeeded()
7171
}
@@ -122,7 +122,7 @@ public final class Keyboard {
122122
isObservingKeyboardNotifications = true
123123
}
124124

125-
static func unregisterForKeyboardNotifications() {
125+
static func deregisterForKeyboardNotifications() {
126126
for notificationName in keyboardNotificationNames {
127127
NotificationCenter.default.removeObserver(
128128
self,
@@ -152,13 +152,13 @@ public final class Keyboard {
152152
}
153153

154154
@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 {
156156
let observer = Observer(event: event, block: body)
157157
observers.append(observer)
158158
return observer
159159
}
160160

161-
static func removeObserver(_ observer: Observer) {
161+
public static func removeObserver(_ observer: Observer) {
162162
observers = observers.filter { existing in
163163
existing != observer
164164
}
@@ -172,7 +172,7 @@ public final class Keyboard {
172172

173173
// MARK: - Notification handling
174174
@objc
175-
static func handleKeyboardNotification(notification: Notification) {
175+
private static func handleKeyboardNotification(notification: Notification) {
176176

177177
guard let userInfo = notification.userInfo else {
178178
return
@@ -185,7 +185,6 @@ public final class Keyboard {
185185
switch notification.name {
186186

187187
case UIResponder.keyboardWillChangeFrameNotification:
188-
189188
withObservers(for: .willChangeFrame) { observer in
190189
observer.callback(animator)
191190
}
@@ -208,12 +207,12 @@ public final class Keyboard {
208207
}
209208

210209
@objc
211-
static func handleApplicationNotification(notification: Notification) {
210+
private static func handleApplicationNotification(notification: Notification) {
212211

213212
switch notification.name {
214213

215214
case UIApplication.willResignActiveNotification:
216-
unregisterForKeyboardNotifications()
215+
deregisterForKeyboardNotifications()
217216

218217
case UIApplication.didBecomeActiveNotification:
219218
registerForKeyboardNotificationsIfNeeded()

0 commit comments

Comments
 (0)