Skip to content

Commit aee8b83

Browse files
committed
Switched the demo project to use dedicated IQKeyboardToolbarManager functions
1 parent 95c7f44 commit aee8b83

8 files changed

Lines changed: 76 additions & 62 deletions

Example/IQKeyboardManagerSwiftExample/AppDelegate.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import UIKit
2525
import IQKeyboardManagerSwift
26+
import IQKeyboardToolbarManager
2627

2728
@main
2829
class AppDelegate: UIResponder, UIApplicationDelegate {
@@ -35,7 +36,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3536

3637
window?.backgroundColor = UIColor.white
3738
IQKeyboardManager.shared.isEnabled = true
38-
IQKeyboardManager.shared.enableAutoToolbar = true
39+
IQKeyboardManager.shared.isDebuggingEnabled = true
40+
IQKeyboardToolbarManager.shared.isEnabled = true
41+
IQKeyboardToolbarManager.shared.isDebuggingEnabled = true
3942
return true
4043
}
4144

Example/IQKeyboardManagerSwiftExample/ViewController/CustomViewController.swift

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ class CustomViewController: BaseViewController {
7474
}
7575

7676
do {
77-
let classes = IQKeyboardManager.shared.disabledToolbarClasses
77+
let classes = IQKeyboardToolbarManager.shared.disabledToolbarClasses
7878
switchDisableToolbar.isOn = classes.contains(where: { element in
7979
return element == CustomViewController.self
8080
})
8181
}
8282

8383
do {
84-
let classes = IQKeyboardManager.shared.enabledToolbarClasses
84+
let classes = IQKeyboardToolbarManager.shared.enabledToolbarClasses
8585
switchEnableToolbar.isOn = classes.contains(where: { element in
8686
return element == CustomViewController.self
8787
})
@@ -102,7 +102,7 @@ class CustomViewController: BaseViewController {
102102
}
103103

104104
do {
105-
let classes = IQKeyboardManager.shared.deepResponderAllowedContainerClasses
105+
let classes = IQKeyboardToolbarManager.shared.deepResponderAllowedContainerClasses
106106
switchAllowPreviousNext.isOn = classes.contains(where: { element in
107107
return element == IQDeepResponderContainerView.self
108108
})
@@ -161,26 +161,26 @@ class CustomViewController: BaseViewController {
161161
@IBAction func disableToolbarAction(_ sender: UISwitch) {
162162
self.view.endEditing(true)
163163
if sender.isOn {
164-
IQKeyboardManager.shared.disabledToolbarClasses.append(CustomViewController.self)
164+
IQKeyboardToolbarManager.shared.disabledToolbarClasses.append(CustomViewController.self)
165165
} else {
166166

167-
if let index = IQKeyboardManager.shared.disabledToolbarClasses.firstIndex(where: { element in
167+
if let index = IQKeyboardToolbarManager.shared.disabledToolbarClasses.firstIndex(where: { element in
168168
return element == CustomViewController.self
169169
}) {
170-
IQKeyboardManager.shared.disabledToolbarClasses.remove(at: index)
170+
IQKeyboardToolbarManager.shared.disabledToolbarClasses.remove(at: index)
171171
}
172172
}
173173
}
174174

175175
@IBAction func enableToolbarAction(_ sender: UISwitch) {
176176
self.view.endEditing(true)
177177
if sender.isOn {
178-
IQKeyboardManager.shared.enabledToolbarClasses.append(CustomViewController.self)
178+
IQKeyboardToolbarManager.shared.enabledToolbarClasses.append(CustomViewController.self)
179179
} else {
180-
if let index = IQKeyboardManager.shared.enabledToolbarClasses.firstIndex(where: { element in
180+
if let index = IQKeyboardToolbarManager.shared.enabledToolbarClasses.firstIndex(where: { element in
181181
return element == CustomViewController.self
182182
}) {
183-
IQKeyboardManager.shared.enabledToolbarClasses.remove(at: index)
183+
IQKeyboardToolbarManager.shared.enabledToolbarClasses.remove(at: index)
184184
}
185185
}
186186
}
@@ -215,13 +215,15 @@ class CustomViewController: BaseViewController {
215215
@IBAction func allowedPreviousNextAction(_ sender: UISwitch) {
216216
self.view.endEditing(true)
217217
if sender.isOn {
218-
IQKeyboardManager.shared.deepResponderAllowedContainerClasses.append(IQDeepResponderContainerView.self)
218+
IQKeyboardToolbarManager.shared
219+
.deepResponderAllowedContainerClasses.append(IQDeepResponderContainerView.self)
219220
} else {
220221

221-
if let index = IQKeyboardManager.shared.deepResponderAllowedContainerClasses.firstIndex(where: { element in
222+
if let index = IQKeyboardToolbarManager.shared
223+
.deepResponderAllowedContainerClasses.firstIndex(where: { element in
222224
return element == IQDeepResponderContainerView.self
223225
}) {
224-
IQKeyboardManager.shared.deepResponderAllowedContainerClasses.remove(at: index)
226+
IQKeyboardToolbarManager.shared.deepResponderAllowedContainerClasses.remove(at: index)
225227
}
226228
}
227229
}

Example/IQKeyboardManagerSwiftExample/ViewController/RefreshLayoutViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RefreshLayoutViewController: BaseViewController {
2828

2929
@IBOutlet var textViewHeightConstraint: NSLayoutConstraint!
3030

31-
@IBAction func stepperChanged (_ sender: UIStepper) {
31+
@IBAction func stepperChanged(_ sender: UIStepper) {
3232

3333
let finalCurve = UIView.AnimationOptions.beginFromCurrentState.union(.init(rawValue: 7))
3434

@@ -43,7 +43,7 @@ class RefreshLayoutViewController: BaseViewController {
4343
}, completion: nil)
4444
}
4545

46-
@IBAction func reloadLayoutAction (_ sender: UIButton) {
46+
@IBAction func reloadLayoutAction(_ sender: UIButton) {
4747
IQKeyboardManager.shared.reloadLayoutIfNeeded()
4848
}
4949
}

Example/IQKeyboardManagerSwiftExample/ViewController/SearchViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class SearchViewController: BaseTableViewController, UISearchResultsUpdating, UI
4444
super.viewDidLoad()
4545

4646
self.searchController = UISearchController(searchResultsController: nil)
47+
// self.searchController.hidesNavigationBarDuringPresentation = false
4748
self.searchController.searchResultsUpdater = self
4849
self.searchController.obscuresBackgroundDuringPresentation = false
4950
self.searchController.searchBar.scopeButtonTitles = ["All", "Name", "Email"]

Example/IQKeyboardManagerSwiftExample/ViewController/SettingsViewController+TableView.swift

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import UIKit
2525
import IQKeyboardManagerSwift
26+
import IQKeyboardToolbarManager
2627

2728
extension SettingsViewController {
2829

@@ -52,9 +53,10 @@ extension SettingsViewController {
5253
}
5354

5455
case 1:
55-
if IQKeyboardManager.shared.enableAutoToolbar == false {
56+
if IQKeyboardToolbarManager.shared.isEnabled == false {
5657
return 1
57-
} else if IQKeyboardManager.shared.toolbarConfiguration.placeholderConfiguration.showPlaceholder == false {
58+
} else if IQKeyboardToolbarManager.shared
59+
.toolbarConfiguration.placeholderConfiguration.showPlaceholder == false {
5860
return 4
5961
} else {
6062
let properties = keyboardManagerProperties[section]
@@ -151,7 +153,7 @@ extension SettingsViewController {
151153
cell.switchEnable.isEnabled = true
152154
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row]
153155
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row]
154-
cell.switchEnable.isOn = IQKeyboardManager.shared.enableAutoToolbar
156+
cell.switchEnable.isOn = IQKeyboardToolbarManager.shared.isEnabled
155157
cell.switchEnable.removeTarget(nil, action: nil, for: .allEvents)
156158
cell.switchEnable.addTarget(self, action: #selector(self.enableAutoToolbarAction(_:)),
157159
for: .valueChanged)
@@ -174,7 +176,7 @@ extension SettingsViewController {
174176
cell.switchEnable.isEnabled = true
175177
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row]
176178
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row]
177-
cell.switchEnable.isOn = IQKeyboardManager.shared.toolbarConfiguration.useTextInputViewTintColor
179+
cell.switchEnable.isOn = IQKeyboardToolbarManager.shared.toolbarConfiguration.useTextInputViewTintColor
178180
cell.switchEnable.removeTarget(nil, action: nil, for: .allEvents)
179181
cell.switchEnable.addTarget(self, action: #selector(self.shouldToolbarUsesTextFieldTintColorAction(_:)),
180182
for: .valueChanged)
@@ -189,7 +191,7 @@ extension SettingsViewController {
189191
let subtitle = keyboardManagerPropertyDetails[indexPath.section][indexPath.row]
190192
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row]
191193
cell.labelSubtitle.text = subtitle
192-
let toolbarConfig = IQKeyboardManager.shared.toolbarConfiguration
194+
let toolbarConfig = IQKeyboardToolbarManager.shared.toolbarConfiguration
193195
cell.switchEnable.isOn = toolbarConfig.placeholderConfiguration.showPlaceholder
194196
cell.switchEnable.removeTarget(nil, action: nil, for: .allEvents)
195197
cell.switchEnable.addTarget(self, action: #selector(self.shouldShowToolbarPlaceholder(_:)),
@@ -212,7 +214,7 @@ extension SettingsViewController {
212214

213215
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row]
214216
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row]
215-
cell.selectedColorView.backgroundColor = IQKeyboardManager.shared.toolbarConfiguration.tintColor
217+
cell.selectedColorView.backgroundColor = IQKeyboardToolbarManager.shared.toolbarConfiguration.tintColor
216218
cell.selectedColorView.layer.borderColor = UIColor.lightGray.cgColor
217219
cell.selectedColorView.layer.borderWidth = 1.0
218220
return cell
@@ -225,7 +227,8 @@ extension SettingsViewController {
225227
cell.switchEnable.isEnabled = true
226228
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row]
227229
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row]
228-
let doneButtonConfiguration = IQKeyboardManager.shared.toolbarConfiguration.doneBarButtonConfiguration
230+
let doneButtonConfiguration = IQKeyboardToolbarManager.shared
231+
.toolbarConfiguration.doneBarButtonConfiguration
229232
cell.arrowImageView.image = doneButtonConfiguration?.image
230233
cell.switchEnable.isOn = doneButtonConfiguration?.image != nil
231234
cell.switchEnable.removeTarget(nil, action: nil, for: .allEvents)
@@ -241,7 +244,8 @@ extension SettingsViewController {
241244

242245
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row]
243246
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row]
244-
cell.textField.text = IQKeyboardManager.shared.toolbarConfiguration.doneBarButtonConfiguration?.title
247+
cell.textField.text = IQKeyboardToolbarManager.shared
248+
.toolbarConfiguration.doneBarButtonConfiguration?.title
245249
cell.textField.tag = 17
246250
cell.textField.delegate = self
247251
return cell
@@ -306,7 +310,7 @@ extension SettingsViewController {
306310
cell.switchEnable.isEnabled = true
307311
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row]
308312
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row]
309-
cell.switchEnable.isOn = IQKeyboardManager.shared.playInputClicks
313+
cell.switchEnable.isOn = IQKeyboardToolbarManager.shared.playInputClicks
310314
cell.switchEnable.removeTarget(nil, action: nil, for: .allEvents)
311315
cell.switchEnable.addTarget(self, action: #selector(self.shouldPlayInputClicksAction(_:)),
312316
for: .valueChanged)

0 commit comments

Comments
 (0)