Skip to content
This repository was archived by the owner on Mar 10, 2022. It is now read-only.

Commit 819b797

Browse files
committed
Minor tweaks
1 parent acf26ee commit 819b797

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

KeyboardHelper/Classes/KeyboardAppearanceInfo.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@ public struct KeyboardAppearanceInfo {
4343
That variable will help to keep track of which app uses the keyboard at the moment.
4444
If it is the current app it is true, if not it is false.
4545
*/
46+
@available(iOS 9.0, *)
4647
public var belongsToCurrentApp: Bool {
47-
if #available(iOS 9.0, *) {
48-
return (userInfo[UIKeyboardIsLocalUserInfoKey] as? Bool) ?? true
49-
} else {
50-
return true
51-
}
48+
return (userInfo[UIKeyboardIsLocalUserInfoKey] as? Bool) ?? true
49+
5250
}
5351

5452
/**

KeyboardHelper/Classes/KeyboardHelper.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ public class KeyboardHelper {
5050
NotificationCenter.default.addObserver(self, selector: #selector(KeyboardHelper.keyboardWillDisappear(_:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
5151
}
5252

53-
private init() {
54-
delegate = nil
55-
}
56-
5753
dynamic private func keyboardWillAppear(_ note: Notification) {
5854
let info = KeyboardAppearanceInfo(notification: note)
5955
self.delegate?.keyboardWillAppear(info)

KeyboardHelperTests/Tests/KeyboardAppearanceInfoTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ class KeyboardAppearanceInfoTests: XCTestCase {
6969
}
7070

7171
func testAnimationCurve() {
72-
XCTAssertEqual(appearanceInfo.animationCurve, UIViewAnimationCurve(rawValue: 2),
72+
XCTAssertEqual(appearanceInfo.animationCurve, UIViewAnimationCurve.easeOut,
7373
"Parsing animationCurve from keyboard appearance info failed.")
74-
XCTAssertEqual(defaultsAppearanceInfo.animationCurve, UIViewAnimationCurve(rawValue: defaultsAppearanceInfo.animationCurve.rawValue),
74+
XCTAssertEqual(defaultsAppearanceInfo.animationCurve, UIViewAnimationCurve.easeInOut,
7575
"Parsing default animationCurve from keyboard appearance info failed.")
7676
}
7777

KeyboardHelperTests/Tests/KeyboardHelperTests.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ class KeyboardHelperTests: XCTestCase {
9595
XCTAssertEqual(result.animationDuration, 0.25)
9696
XCTAssertEqual(result.beginFrame, CGRect(x: 0, y: 667, width: 375, height: 0))
9797
XCTAssertEqual(result.endFrame, CGRect(x: 0, y: 409, width: 375, height: 258))
98-
XCTAssertEqual(result.belongsToCurrentApp, true)
98+
if #available(iOS 9.0, *) {
99+
XCTAssertEqual(result.belongsToCurrentApp, true)
100+
} else {
101+
// don't test this
102+
}
99103

100104
}
101105
}

0 commit comments

Comments
 (0)