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

Commit

Permalink
Merge pull request #19 from nodes-ios/develop
Browse files Browse the repository at this point in the history
Renaming KeyboardNotificationDelegate to KeyboardHelperDelegate
  • Loading branch information
NickSkull committed Mar 30, 2017
2 parents 4c39d76 + acf26ee commit 9652b3a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Example/KeyboardHelperDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit
import KeyboardHelper

class ViewController: UIViewController, KeyboardNotificationDelegate {
class ViewController: UIViewController, KeyboardHelperDelegate {

fileprivate var tapGesture: UITapGestureRecognizer!
fileprivate var keyboardHelper : KeyboardHelper?
Expand Down
14 changes: 9 additions & 5 deletions KeyboardHelper/Classes/KeyboardHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import Foundation
import UIKit

/**
Protocol `KeyboardNotificationDelegate` requires two functions.
Protocol `KeyboardHelperDelegate` requires two functions.
Function `keyboardWillAppear` and `keyboardWillDisappear` with parameter `info` struct `KeyboardAppearanceInfo`.
*/
public protocol KeyboardNotificationDelegate: class {

public protocol KeyboardHelperDelegate: class {

/**
This function will recongnize a change of `KeyboardAppearanceInfo` and will be fired when the keyboard will appaear.
Expand All @@ -34,15 +35,15 @@ public protocol KeyboardNotificationDelegate: class {
public class KeyboardHelper {

/**
Delegate that conforms with the `KeyboardNotificationDelegate`.
Delegate that conforms with the `KeyboardHelperDelegate`.
*/
public weak var delegate: KeyboardNotificationDelegate?
public weak var delegate: KeyboardHelperDelegate?

/**
Initialize the `delegate` and add the two observer for `keyboardWillAppear` and `keyboardWillDisappear`.
Observers are nessecary for tracking the `UIKeyboardWillShowNotification` and `UIKeyboardWillHideNotification`, so the function that are connectet are getting fired.
*/
required public init(delegate: KeyboardNotificationDelegate) {
required public init(delegate: KeyboardHelperDelegate) {
self.delegate = delegate

NotificationCenter.default.addObserver(self, selector: #selector(KeyboardHelper.keyboardWillAppear(_:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
Expand All @@ -67,3 +68,6 @@ public class KeyboardHelper {
NotificationCenter.default.removeObserver(self)
}
}

@available(*, deprecated, message: "KeyboardNotificationDelegate has been renamed to KeyboardHelperDelegate")
public typealias KeyboardNotificationDelegate = KeyboardHelperDelegate
4 changes: 2 additions & 2 deletions KeyboardHelperTests/Tests/KeyboardHelperTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import XCTest
@testable import KeyboardHelper

class ShowSpyDelegate : KeyboardNotificationDelegate {
class ShowSpyDelegate : KeyboardHelperDelegate {
var kai : KeyboardAppearanceInfo?

var expectation : XCTestExpectation?
Expand All @@ -29,7 +29,7 @@ class ShowSpyDelegate : KeyboardNotificationDelegate {
}
}

class HideSpyDelegate : KeyboardNotificationDelegate {
class HideSpyDelegate : KeyboardHelperDelegate {
var kai : KeyboardAppearanceInfo?

var expectation : XCTestExpectation?
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pod 'KeyboardHelper', '~> 1.0'


## 🔧 Setup
Implement `KeyboardNotificationDelegate` in your UIViewController.
Implement `KeyboardHelperDelegate` in your UIViewController.

```swift
class ViewController: UIViewController, KeyboardNotificationDelegate
Expand All @@ -51,7 +51,7 @@ func viewDidLoad() {
...
}
```
Implement the two methods in the `KeyboardNotificationDelegate`:
Implement the two methods in the `KeyboardHelperDelegate`:

```swift
public func keyboardWillAppear(_ info: KeyboardHelper.KeyboardAppearanceInfo)
Expand Down

0 comments on commit 9652b3a

Please sign in to comment.