Skip to content

Commit

Permalink
- Replaced IQKeyboardReturnKeyHandler with IQKeyboardReturnManager
Browse files Browse the repository at this point in the history
- Added unavailability to some of the classes
- Deleted KeyboardListener and TextFieldListener
  • Loading branch information
hackiftekhar committed Nov 4, 2024
1 parent c6f6304 commit 42e0d94
Show file tree
Hide file tree
Showing 28 changed files with 181 additions and 1,479 deletions.
1 change: 1 addition & 0 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
github "hackiftekhar/IQKeyboardNotification"
github "hackiftekhar/IQTextInputViewNotification"
github "hackiftekhar/IQKeyboardToolbarManager"
github "hackiftekhar/IQKeyboardReturnManager"
github "hackiftekhar/IQTextView"
1 change: 1 addition & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
github "hackiftekhar/IQKeyboardCore" "1.0.7"
github "hackiftekhar/IQKeyboardNotification" "1.0.5"
github "hackiftekhar/IQKeyboardReturnManager" "1.0.5"
github "hackiftekhar/IQKeyboardToolbar" "1.1.1"
github "hackiftekhar/IQKeyboardToolbarManager" "1.1.1"
github "hackiftekhar/IQTextInputViewNotification" "1.0.8"
Expand Down
62 changes: 10 additions & 52 deletions Demo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Demo/Swift_Demo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Override point for customization after application launch.

window?.backgroundColor = UIColor.white
IQKeyboardManager.shared.enable = true
IQKeyboardManager.shared.isEnabled = true
IQKeyboardManager.shared.enableAutoToolbar = true
return true
}
Expand Down
3 changes: 2 additions & 1 deletion Demo/Swift_Demo/ViewController/CustomViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@

import UIKit
import IQKeyboardManagerSwift
import IQKeyboardReturnManager
import IQKeyboardToolbarManager

class CustomViewController: BaseViewController {

private let returnHandler: IQKeyboardReturnKeyHandler = .init()
private let returnHandler: IQKeyboardReturnManager = .init()
@IBOutlet var settingsView: UIView!

@IBOutlet var switchDisableViewController: UISwitch!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@

import UIKit
import IQKeyboardManagerSwift
import IQKeyboardReturnManager

class NavigationBarViewController: BaseViewController, UITextFieldDelegate {

private let returnHandler: IQKeyboardReturnKeyHandler = .init()
private let returnHandler: IQKeyboardReturnManager = .init()
@IBOutlet var textField2: UITextField!
@IBOutlet var textField3: UITextField!
@IBOutlet var scrollView: UIScrollView!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extension SettingsViewController {

switch section {
case 0:
if IQKeyboardManager.shared.enable == true {
if IQKeyboardManager.shared.isEnabled == true {

let properties = keyboardManagerProperties[section]

Expand Down Expand Up @@ -104,7 +104,7 @@ extension SettingsViewController {
cell.switchEnable.isEnabled = true
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row]
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row]
cell.switchEnable.isOn = IQKeyboardManager.shared.enable
cell.switchEnable.isOn = IQKeyboardManager.shared.isEnabled
cell.switchEnable.removeTarget(nil, action: nil, for: .allEvents)
cell.switchEnable.addTarget(self, action: #selector(self.enableAction(_:)), for: .valueChanged)
return cell
Expand Down Expand Up @@ -324,7 +324,7 @@ extension SettingsViewController {
cell.switchEnable.isEnabled = true
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row]
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row]
cell.switchEnable.isOn = IQKeyboardManager.shared.enableDebugging
cell.switchEnable.isOn = IQKeyboardManager.shared.isDebuggingEnabled
cell.switchEnable.removeTarget(nil, action: nil, for: .allEvents)
cell.switchEnable.addTarget(self, action: #selector(self.enableDebugging(_:)), for: .valueChanged)
return cell
Expand Down
4 changes: 2 additions & 2 deletions Demo/Swift_Demo/ViewController/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class SettingsViewController: UITableViewController {
/** UIKeyboard Handling */
@objc func enableAction (_ sender: UISwitch) {

IQKeyboardManager.shared.enable = sender.isOn
IQKeyboardManager.shared.isEnabled = sender.isOn

self.tableView.reloadSections(IndexSet(integer: 0), with: .fade)
}
Expand Down Expand Up @@ -156,7 +156,7 @@ class SettingsViewController: UITableViewController {
/** Debugging */
@objc func enableDebugging (_ sender: UISwitch) {

IQKeyboardManager.shared.enableDebugging = sender.isOn
IQKeyboardManager.shared.isDebuggingEnabled = sender.isOn
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
Expand Down
3 changes: 2 additions & 1 deletion Demo/Swift_Demo/ViewController/TextFieldViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import UIKit
import IQKeyboardManagerSwift
import IQDropDownTextFieldSwift
import IQKeyboardNotification
import IQTextView

class TextFieldViewController: BaseViewController, UITextViewDelegate {
Expand All @@ -33,7 +34,7 @@ class TextFieldViewController: BaseViewController, UITextViewDelegate {
@IBOutlet var textView2: UITextView!
@IBOutlet var textView3: UITextView!

let keyboardListener = IQKeyboardListener()
let keyboardListener = IQKeyboardNotification()

@IBOutlet var dropDownTextField: IQDropDownTextField!

Expand Down
13 changes: 5 additions & 8 deletions IQKeyboardManagerSwift.podspec.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "IQKeyboardManagerSwift",
"version": "7.3.0",
"version": "8.0.0",
"source": {
"git": "https://github.com/hackiftekhar/IQKeyboardManager.git",
"tag": "7.3.0"
"tag": "8.0.0"
},
"summary": "Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView.",
"homepage": "https://github.com/hackiftekhar/IQKeyboardManager",
Expand Down Expand Up @@ -43,12 +43,9 @@
}
},
{
"name": "IQKeyboardReturnKeyHandler",
"source_files": [
"IQKeyboardManagerSwift/IQKeyboardReturnKeyHandler/**/*.{swift}"
],
"name": "IQKeyboardReturnManager",
"dependencies": {
"IQKeyboardCore": []
"IQKeyboardReturnManager": []
}
},
{
Expand Down Expand Up @@ -80,7 +77,7 @@
"default_subspecs": [
"Appearance",
"Core",
"IQKeyboardReturnKeyHandler",
"IQKeyboardReturnManager",
"IQKeyboardToolbarManager",
"IQTextView",
"Resign"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// IQKeyboardConfiguration.swift
// IQKeyboardAppearanceConfiguration.swift
// https://github.com/hackiftekhar/IQKeyboardManager
// Copyright (c) 2013-24 Iftekhar Qurashi.
//
Expand All @@ -25,7 +25,7 @@ import UIKit

@available(iOSApplicationExtension, unavailable)
@MainActor
@objcMembers public final class IQKeyboardConfiguration: NSObject {
@objcMembers public final class IQKeyboardAppearanceConfiguration: NSObject {

/**
Override the keyboardAppearance for all textInputView. Default is NO.
Expand All @@ -37,3 +37,7 @@ import UIKit
*/
public var appearance: UIKeyboardAppearance = .default
}

@available(*, unavailable, renamed: "IQKeyboardAppearanceConfiguration")
@MainActor
@objcMembers public final class IQKeyboardConfiguration: NSObject {}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import IQTextInputViewNotification
/**
Configuration related to keyboard appearance
*/
var keyboardConfiguration: IQKeyboardConfiguration = .init()
var keyboardConfiguration: IQKeyboardAppearanceConfiguration = .init()

public override init() {
super.init()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import UIKit
/**
Configuration related to keyboard appearance
*/
var keyboardConfiguration: IQKeyboardConfiguration {
var keyboardConfiguration: IQKeyboardAppearanceConfiguration {
get { appearanceManager.keyboardConfiguration }
set { appearanceManager.keyboardConfiguration = newValue }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ extension IQActiveConfiguration {
return textInputViewObserver.textInputView
}

private var textInputViewInfo: IQTextInputViewInfo? {
var textInputViewInfo: IQTextInputViewInfo? {
guard let textInputView: UIView = textInputView,
textInputView.iq.isAlertViewTextField() == false else {
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ import UIKit

@MainActor
private struct AssociatedKeys {
static var enableDebugging: Int = 0
static var isDebuggingEnabled: Int = 0
static var logIndentation: Int = 0
}

var enableDebugging: Bool {
var isDebuggingEnabled: Bool {
get {
return objc_getAssociatedObject(self, &AssociatedKeys.enableDebugging) as? Bool ?? false
return objc_getAssociatedObject(self, &AssociatedKeys.isDebuggingEnabled) as? Bool ?? false
}
set(newValue) {
objc_setAssociatedObject(self, &AssociatedKeys.enableDebugging,
objc_setAssociatedObject(self, &AssociatedKeys.isDebuggingEnabled,
newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
Expand All @@ -56,7 +56,7 @@ import UIKit

internal func showLog(_ logString: String, indentation: Int = 0) {

guard enableDebugging else {
guard isDebuggingEnabled else {
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@

import UIKit

// swiftlint:disable unused_setter_value
// swiftlint:disable line_length
// swiftlint:disable type_name
@available(iOSApplicationExtension, unavailable)
@MainActor
@objc public extension IQKeyboardManager {

@available(*, deprecated, renamed: "keyboardDistance")
@available(*, unavailable, renamed: "keyboardDistance")
var keyboardDistanceFromTextField: CGFloat {
get { keyboardDistance }
set { keyboardDistance = newValue }
get { fatalError() }
set { }
}
}

Expand All @@ -51,23 +54,116 @@ import UIKit
}
}

// swiftlint:disable line_length
@available(iOSApplicationExtension, unavailable)
@MainActor
@objc public extension IQKeyboardManager {

typealias SizeBlock = (_ size: CGSize) -> Void

@available(*, unavailable, message: "This feature has been moved to IQKeyboardListener, use it directly by creating new instance")
@available(*, unavailable, message: "Please use `IQKeyboardNotification` independently from https://github.com/hackiftekhar/IQKeyboardNotification")
func registerKeyboardSizeChange(identifier: AnyHashable, sizeHandler: @escaping SizeBlock) {}

@available(*, unavailable, message: "This feature has been moved to IQKeyboardListener, use it directly by creating new instance")
@available(*, unavailable, message: "Please use `IQKeyboardNotification` independently from https://github.com/hackiftekhar/IQKeyboardNotification")
func unregisterKeyboardSizeChange(identifier: AnyHashable) {}

@available(*, unavailable, message: "This feature has been moved to IQKeyboardListener, use it directly by creating new instance")
@available(*, unavailable, message: "Please use `IQKeyboardNotification` independently from https://github.com/hackiftekhar/IQKeyboardNotification")
var keyboardShowing: Bool { false }

@available(*, unavailable, message: "This feature has been moved to IQKeyboardListener, use it directly by creating new instance")
@available(*, unavailable, message: "Please use `IQKeyboardNotification` independently from https://github.com/hackiftekhar/IQKeyboardNotification")
var keyboardFrame: CGRect { .zero }
}

@available(*, unavailable, renamed: "IQKeyboardReturnManager", message: "Please use `IQKeyboardReturnManager` independently from https://github.com/hackiftekhar/IQKeyboardReturnManager")
@MainActor
@objcMembers public final class IQKeyboardReturnKeyHandler: NSObject {}

@available(*, unavailable, renamed: "IQKeyboardNotification", message: "Please use `IQKeyboardNotification` independently from https://github.com/hackiftekhar/IQKeyboardNotification")
@MainActor
@objcMembers public final class IQKeyboardListener: NSObject {}

@available(*, unavailable, renamed: "IQTextInputViewNotification", message: "Please use `IQTextInputViewNotification` independently from https://github.com/hackiftekhar/IQTextInputViewNotification")
@MainActor
@objcMembers public final class IQTextFieldViewListener: NSObject {}

@available(*, unavailable, renamed: "IQDeepResponderContainerView", message: "Please use `IQDeepResponderContainerView` class which is now part of `IQKeyboardToolbarManager` from https://github.com/hackiftekhar/IQKeyboardToolbarManager.")
@MainActor
@objcMembers open class IQPreviousNextView: UIView {}

@available(*, unavailable, message: "Please use `IQKeyboardToolbar` independently https://github.com/hackiftekhar/IQKeyboardToolbar or through `IQKeyboardToolbarManager` from https://github.com/hackiftekhar/IQKeyboardToolbarManager")
@MainActor
@objcMembers public final class IQToolbarPlaceholderConfigurationDeprecated: NSObject {
public var showPlaceholder: Bool = true
public var font: UIFont?
public var color: UIColor?
public var buttonColor: UIColor?
public override var accessibilityLabel: String? { didSet { } }
}

@available(iOSApplicationExtension, unavailable)
@available(*, unavailable, message: "Please use `IQKeyboardToolbar` independently https://github.com/hackiftekhar/IQKeyboardToolbar or through `IQKeyboardToolbarManager` from https://github.com/hackiftekhar/IQKeyboardToolbarManager")
@MainActor
@objcMembers public final class IQBarButtonItemConfigurationDeprecated: NSObject {

public init(systemItem: UIBarButtonItem.SystemItem, action: Selector? = nil) {
self.systemItem = systemItem
self.image = nil
self.title = nil
self.action = action
super.init()
}

public init(image: UIImage, action: Selector? = nil) {
self.systemItem = nil
self.image = image
self.title = nil
self.action = action
super.init()
}

public init(title: String, action: Selector? = nil) {
self.systemItem = nil
self.image = nil
self.title = title
self.action = action
super.init()
}

public let systemItem: UIBarButtonItem.SystemItem?
public let image: UIImage?
public let title: String?
public var action: Selector?
public override var accessibilityLabel: String? { didSet { } }
}

@available(*, unavailable, message: "Please use `IQKeyboardToolbarManager` independently from https://github.com/hackiftekhar/IQKeyboardToolbarManager")
@objc public enum IQAutoToolbarManageBehaviorDeprecated: Int {
case bySubviews
case byTag
case byPosition
}

@available(*, unavailable, message: "Please use `IQKeyboardToolbarManager` independently from https://github.com/hackiftekhar/IQKeyboardToolbarManager")
@objc public enum IQPreviousNextDisplayModeDeprecated: Int {
case `default`
case alwaysHide
case alwaysShow
}

@available(*, unavailable, message: "Please use `IQKeyboardToolbarManager` independently from https://github.com/hackiftekhar/IQKeyboardToolbarManager")
@MainActor
@objcMembers public final class IQToolbarConfiguration: NSObject {

public var useTextInputViewTintColor: Bool = false
public var tintColor: UIColor?
public var barTintColor: UIColor?
public var previousNextDisplayMode: IQPreviousNextDisplayModeDeprecated = .default
public var manageBehavior: IQAutoToolbarManageBehaviorDeprecated = .bySubviews
public var previousBarButtonConfiguration: IQBarButtonItemConfigurationDeprecated?
public var nextBarButtonConfiguration: IQBarButtonItemConfigurationDeprecated?
public var doneBarButtonConfiguration: IQBarButtonItemConfigurationDeprecated?
public let placeholderConfiguration: IQToolbarPlaceholderConfigurationDeprecated = .init()
}

// swiftlint:enable line_length
// swiftlint:enable unused_setter_value
// swiftlint:enable type_name
Loading

0 comments on commit 42e0d94

Please sign in to comment.