Remove the coordinator dependency from KeyboadManager as it wasn't needed
This commit is contained in:
parent
988ec75d75
commit
73828e5115
|
@ -26,7 +26,7 @@ class DetailViewController: UIViewController {
|
|||
|
||||
weak var coordinator: SceneCoordinator!
|
||||
|
||||
lazy var keyboardManager = KeyboardManager(type: .detail, coordinator: coordinator)
|
||||
private let keyboardManager = KeyboardManager(type: .detail)
|
||||
override var keyCommands: [UIKeyCommand]? {
|
||||
return keyboardManager.keyCommands
|
||||
}
|
||||
|
|
|
@ -17,19 +17,9 @@ enum KeyboardType: String {
|
|||
|
||||
class KeyboardManager {
|
||||
|
||||
private let coordinator: SceneCoordinator
|
||||
private(set) var keyCommands: [UIKeyCommand]?
|
||||
|
||||
init(type: KeyboardType, coordinator: SceneCoordinator) {
|
||||
self.coordinator = coordinator
|
||||
load(type: type)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private extension KeyboardManager {
|
||||
|
||||
func load(type: KeyboardType) {
|
||||
init(type: KeyboardType) {
|
||||
let file = Bundle.main.path(forResource: type.rawValue, ofType: "plist")!
|
||||
let entries = NSArray(contentsOfFile: file)! as! [[String: Any]]
|
||||
keyCommands = entries.compactMap { createKeyCommand(keyEntry: $0) }
|
||||
|
@ -44,6 +34,10 @@ private extension KeyboardManager {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private extension KeyboardManager {
|
||||
|
||||
func createKeyCommand(keyEntry: [String: Any]) -> UIKeyCommand? {
|
||||
guard let input = createKeyCommandInput(keyEntry: keyEntry) else { return nil }
|
||||
let modifiers = createKeyModifierFlags(keyEntry: keyEntry)
|
||||
|
|
|
@ -22,7 +22,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
|||
var undoableCommands = [UndoableCommand]()
|
||||
weak var coordinator: SceneCoordinator!
|
||||
|
||||
lazy var keyboardManager = KeyboardManager(type: .sidebar, coordinator: coordinator)
|
||||
private let keyboardManager = KeyboardManager(type: .sidebar)
|
||||
override var keyCommands: [UIKeyCommand]? {
|
||||
return keyboardManager.keyCommands
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
|||
weak var coordinator: SceneCoordinator!
|
||||
var undoableCommands = [UndoableCommand]()
|
||||
|
||||
lazy var keyboardManager = KeyboardManager(type: .timeline, coordinator: coordinator)
|
||||
private let keyboardManager = KeyboardManager(type: .timeline)
|
||||
override var keyCommands: [UIKeyCommand]? {
|
||||
return keyboardManager.keyCommands
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class RootSplitViewController: UISplitViewController {
|
|||
|
||||
var coordinator: SceneCoordinator!
|
||||
|
||||
lazy var keyboardManager = KeyboardManager(type: .global, coordinator: coordinator)
|
||||
private let keyboardManager = KeyboardManager(type: .global)
|
||||
override var keyCommands: [UIKeyCommand]? {
|
||||
return keyboardManager.keyCommands
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue