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

Commit 9d90fe0

Browse files
committed
Added back the private init. Updated comment style
1 parent 819b797 commit 9d90fe0

File tree

2 files changed

+45
-59
lines changed

2 files changed

+45
-59
lines changed

KeyboardHelper/Classes/KeyboardAppearanceInfo.swift

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
import Foundation
1010
import UIKit
1111

12-
/**
13-
A struct holding all keyboard view information when it's being shown or hidden.
14-
*/
12+
/// A struct holding all keyboard view information when it's being shown or hidden.
1513
public struct KeyboardAppearanceInfo {
1614

1715
public let notification: Notification
@@ -22,66 +20,54 @@ public struct KeyboardAppearanceInfo {
2220
self.userInfo = notification.userInfo ?? [:]
2321
}
2422

25-
/**
26-
Getter for the UIKeyboard frame begin infokey.
27-
Return a `CGRect` or `CGRectZero`.
28-
*/
23+
/// Getter for the UIKeyboard frame begin infokey. Returns a `CGRect` or `CGRectZero`.
2924
public var beginFrame: CGRect {
3025
return (userInfo[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue ?? .zero
3126
}
3227

33-
/**
34-
Getter for the UIKeyboard frame end infokey.
35-
Return a `CGRect` or `CGRectZero`.
36-
*/
28+
29+
/// Getter for the UIKeyboard frame end infokey. Return a `CGRect` or `CGRectZero`.
3730
public var endFrame: CGRect {
3831
return (userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue ?? .zero
3932
}
4033

41-
/**
42-
Getter for the UIKeyboard info if the keyboard is in the current app.
43-
That variable will help to keep track of which app uses the keyboard at the moment.
44-
If it is the current app it is true, if not it is false.
45-
*/
34+
4635
@available(iOS 9.0, *)
36+
/// Getter for the UIKeyboard info if the keyboard is in the current app.
37+
/// That variable will help to keep track of which app uses the keyboard at the moment.
38+
/// If it is the current app it is true, if not it is false.
4739
public var belongsToCurrentApp: Bool {
4840
return (userInfo[UIKeyboardIsLocalUserInfoKey] as? Bool) ?? true
4941

5042
}
5143

52-
/**
53-
Getter for the duration of the keyboard appear/disappear animation.
54-
By default: `0.25`.
55-
*/
44+
45+
/// Getter for the duration of the keyboard appear/disappear animation.
46+
/// By default: `0.25`.
5647
public var animationDuration: Double {
5748
return (userInfo[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0.25
5849
}
59-
60-
/**
61-
Getter for the animation curve.
62-
By default: `EaseInOut`.
63-
*/
50+
51+
/// Getter for the animation curve.
52+
/// By default: `EaseInOut`.
6453
public var animationCurve: UIViewAnimationCurve {
6554
guard let value = userInfo[UIKeyboardAnimationCurveUserInfoKey] as? Int else { return .easeInOut }
6655
return UIViewAnimationCurve(rawValue: value) ?? .easeInOut
6756
}
6857

69-
/**
70-
Getter for the animation option.
71-
That variable will help to keep track of the keyboard appearence.
72-
*/
58+
59+
/// Getter for the animation option.
60+
/// That variable will help to keep track of the keyboard appearence.
7361
public var animationOptions: UIViewAnimationOptions {
7462
return UIViewAnimationOptions(rawValue: UInt(animationCurve.rawValue << 16))
7563
}
7664

77-
/**
78-
Animate a `UView` while the keyboard appears and check if animation is finished.
79-
If finished do completion.
80-
81-
Parameters:
82-
- animationBlock: Animation that should happen.
83-
- completion: Function that happens after the animation is finished.
84-
*/
65+
/// Animate a `UView` while the keyboard appears and check if animation is finished.
66+
/// If finished do completion.
67+
///
68+
/// Parameters:
69+
/// - animationBlock: Animation that should happen.
70+
/// - completion: Function that happens after the animation is finished.
8571
public func animateAlong(_ animationBlock: @escaping (() -> Void), completion: @escaping ((_ finished: Bool) -> Void) = { _ in }) {
8672
UIView.animate(
8773
withDuration: animationDuration,

KeyboardHelper/Classes/KeyboardHelper.swift

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,47 @@
99
import Foundation
1010
import UIKit
1111

12-
/**
13-
Protocol `KeyboardHelperDelegate` requires two functions.
14-
Function `keyboardWillAppear` and `keyboardWillDisappear` with parameter `info` struct `KeyboardAppearanceInfo`.
15-
*/
1612

13+
/// Protocol `KeyboardHelperDelegate` requires two functions, `keyboardWillAppear` and `keyboardWillDisappear` with parameter `info` struct `KeyboardAppearanceInfo`.
1714
public protocol KeyboardHelperDelegate: class {
1815

19-
/**
20-
This function will recongnize a change of `KeyboardAppearanceInfo` and will be fired when the keyboard will appaear.
21-
- Parameter info: Struct `KeyboardAppearanceInfo`.
22-
*/
16+
17+
/// This function will recongnize a change of `KeyboardAppearanceInfo` and will be fired when the keyboard will appaear.
18+
///
19+
/// - Parameter info: Struct `KeyboardAppearanceInfo`.
2320
func keyboardWillAppear(_ info: KeyboardAppearanceInfo)
21+
2422

25-
/**
26-
This function will recongnize a change of `KeyboardAppearanceInfo` and will be fired when the keyboard will disappaear.
27-
- Parameter info: Struct `KeyboardAppearanceInfo`.
28-
*/
23+
/// This function will recongnize a change of `KeyboardAppearanceInfo` and will be fired when the keyboard will disappaear.
24+
///
25+
/// - Parameter info: Struct `KeyboardAppearanceInfo`.
2926
func keyboardWillDisappear(_ info: KeyboardAppearanceInfo)
3027
}
3128

32-
/**
33-
Useful helper to keep track of keyboard changes.
34-
*/
29+
30+
/// Useful helper to keep track of keyboard changes.
3531
public class KeyboardHelper {
3632

37-
/**
38-
Delegate that conforms with the `KeyboardHelperDelegate`.
39-
*/
33+
/// Delegate that conforms with the `KeyboardHelperDelegate`.
4034
public weak var delegate: KeyboardHelperDelegate?
4135

42-
/**
43-
Initialize the `delegate` and add the two observer for `keyboardWillAppear` and `keyboardWillDisappear`.
44-
Observers are nessecary for tracking the `UIKeyboardWillShowNotification` and `UIKeyboardWillHideNotification`, so the function that are connectet are getting fired.
45-
*/
36+
/// Initialize the `delegate` and add the two observer for `keyboardWillAppear` and `keyboardWillDisappear`.
37+
/// Observers are nessecary for tracking the `UIKeyboardWillShowNotification` and `UIKeyboardWillHideNotification`, so the function that are connectet are getting fired.
38+
///
39+
/// - Parameter delegate: KeyboardHelperDelegate
4640
required public init(delegate: KeyboardHelperDelegate) {
4741
self.delegate = delegate
4842

4943
NotificationCenter.default.addObserver(self, selector: #selector(KeyboardHelper.keyboardWillAppear(_:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
5044
NotificationCenter.default.addObserver(self, selector: #selector(KeyboardHelper.keyboardWillDisappear(_:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
5145
}
5246

47+
48+
/// Making sure that you can't intantiate it without a delegate
49+
private init() {
50+
delegate = nil
51+
}
52+
5353
dynamic private func keyboardWillAppear(_ note: Notification) {
5454
let info = KeyboardAppearanceInfo(notification: note)
5555
self.delegate?.keyboardWillAppear(info)

0 commit comments

Comments
 (0)