Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open vs public issues #205 #206

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions Sources/UIViewControllerExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,107 +11,107 @@ import UIKit
extension UIViewController {
// MARK: - Notifications
//TODO: Document this part
public func addNotificationObserver(_ name: String, selector: Selector) {
open func addNotificationObserver(_ name: String, selector: Selector) {
NotificationCenter.default.addObserver(self, selector: selector, name: NSNotification.Name(rawValue: name), object: nil)
}

public func removeNotificationObserver(_ name: String) {
open func removeNotificationObserver(_ name: String) {
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: name), object: nil)
}

public func removeNotificationObserver() {
open func removeNotificationObserver() {
NotificationCenter.default.removeObserver(self)
}

#if os(iOS)
public func addKeyboardWillShowNotification() {
open func addKeyboardWillShowNotification() {
self.addNotificationObserver(NSNotification.Name.UIKeyboardWillShow.rawValue, selector: #selector(UIViewController.keyboardWillShowNotification(_:)))
}

public func addKeyboardDidShowNotification() {
open func addKeyboardDidShowNotification() {
self.addNotificationObserver(NSNotification.Name.UIKeyboardDidShow.rawValue, selector: #selector(UIViewController.keyboardDidShowNotification(_:)))
}

public func addKeyboardWillHideNotification() {
open func addKeyboardWillHideNotification() {
self.addNotificationObserver(NSNotification.Name.UIKeyboardWillHide.rawValue, selector: #selector(UIViewController.keyboardWillHideNotification(_:)))
}

public func addKeyboardDidHideNotification() {
open func addKeyboardDidHideNotification() {
self.addNotificationObserver(NSNotification.Name.UIKeyboardDidHide.rawValue, selector: #selector(UIViewController.keyboardDidHideNotification(_:)))
}

public func removeKeyboardWillShowNotification() {
open func removeKeyboardWillShowNotification() {
self.removeNotificationObserver(NSNotification.Name.UIKeyboardWillShow.rawValue)
}

public func removeKeyboardDidShowNotification() {
open func removeKeyboardDidShowNotification() {
self.removeNotificationObserver(NSNotification.Name.UIKeyboardDidShow.rawValue)
}

public func removeKeyboardWillHideNotification() {
open func removeKeyboardWillHideNotification() {
self.removeNotificationObserver(NSNotification.Name.UIKeyboardWillHide.rawValue)
}

public func removeKeyboardDidHideNotification() {
open func removeKeyboardDidHideNotification() {
self.removeNotificationObserver(NSNotification.Name.UIKeyboardDidHide.rawValue)
}

public func keyboardDidShowNotification(_ notification: Notification) {
open func keyboardDidShowNotification(_ notification: Notification) {
if let nInfo = (notification as NSNotification).userInfo, let value = nInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue {

let frame = value.cgRectValue
keyboardDidShowWithFrame(frame)
}
}

public func keyboardWillShowNotification(_ notification: Notification) {
open func keyboardWillShowNotification(_ notification: Notification) {
if let nInfo = (notification as NSNotification).userInfo, let value = nInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue {

let frame = value.cgRectValue
keyboardWillShowWithFrame(frame)
}
}

public func keyboardWillHideNotification(_ notification: Notification) {
open func keyboardWillHideNotification(_ notification: Notification) {
if let nInfo = (notification as NSNotification).userInfo, let value = nInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue {

let frame = value.cgRectValue
keyboardWillHideWithFrame(frame)
}
}

public func keyboardDidHideNotification(_ notification: Notification) {
open func keyboardDidHideNotification(_ notification: Notification) {
if let nInfo = (notification as NSNotification).userInfo, let value = nInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue {

let frame = value.cgRectValue
keyboardDidHideWithFrame(frame)
}
}

public func keyboardWillShowWithFrame(_ frame: CGRect) {
open func keyboardWillShowWithFrame(_ frame: CGRect) {

}

public func keyboardDidShowWithFrame(_ frame: CGRect) {
open func keyboardDidShowWithFrame(_ frame: CGRect) {

}

public func keyboardWillHideWithFrame(_ frame: CGRect) {
open func keyboardWillHideWithFrame(_ frame: CGRect) {

}

public func keyboardDidHideWithFrame(_ frame: CGRect) {
open func keyboardDidHideWithFrame(_ frame: CGRect) {

}

//EZSE: Makes the UIViewController register tap events and hides keyboard when clicked somewhere in the ViewController.
public func hideKeyboardWhenTappedAround() {
open func hideKeyboardWhenTappedAround() {
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(UIViewController.dismissKeyboard))
view.addGestureRecognizer(tap)
}
#endif

public func dismissKeyboard() {
open func dismissKeyboard() {
view.endEditing(true)
}

Expand Down