From ec4a6f3e0a03ef26eff8410ba5b2fc921c898365 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 7 Sep 2019 09:01:29 -0500 Subject: [PATCH] Add search articles keyboard shortcut and make search work in three panel mode --- iOS/KeyboardManager.swift | 3 +++ iOS/RootSplitViewController.swift | 4 ++++ iOS/SceneCoordinator.swift | 21 ++++++++++----------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/iOS/KeyboardManager.swift b/iOS/KeyboardManager.swift index 0af53e80e..ece86d0b9 100644 --- a/iOS/KeyboardManager.swift +++ b/iOS/KeyboardManager.swift @@ -146,6 +146,9 @@ private extension KeyboardManager { let openInBrowserTitle = NSLocalizedString("Open In Browser", comment: "Open In Browser") keys.append(createKeyCommand(title: openInBrowserTitle, action: "openInBrowser:", input: UIKeyCommand.inputRightArrow, modifiers: [.command])) + let articleSearchTitle = NSLocalizedString("Article Search", comment: "Article Search") + keys.append(createKeyCommand(title: articleSearchTitle, action: "articleSearch:", input: "f", modifiers: [.command, .shift])) + return keys } diff --git a/iOS/RootSplitViewController.swift b/iOS/RootSplitViewController.swift index c02d23594..2f548b17f 100644 --- a/iOS/RootSplitViewController.swift +++ b/iOS/RootSplitViewController.swift @@ -61,6 +61,10 @@ class RootSplitViewController: UISplitViewController { coordinator.showBrowserForCurrentArticle() } + @objc func articleSearch(_ sender: Any?) { + coordinator.showSearch() + } + @objc func addNewFeed(_ sender: Any?) { coordinator.showAdd(.feed) } diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 46856d69f..cc0cc47f8 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -327,11 +327,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { func showSearch() { selectFeed(nil) - - masterTimelineViewController = UIStoryboard.main.instantiateController(ofType: MasterTimelineViewController.self) - masterTimelineViewController!.coordinator = self - navControllerForTimeline().pushViewController(masterTimelineViewController!, animated: false) - + installTimelineControllerIfNecessary(animated: false) DispatchQueue.main.asyncAfter(deadline: .now()) { self.masterTimelineViewController!.showSearchAll() } @@ -584,12 +580,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { if let ip = indexPath, let node = nodeFor(ip), let fetcher = node.representedObject as? ArticleFetcher { timelineFetcher = fetcher updateSelectingActivity(with: node) - - if navControllerForTimeline().viewControllers.filter({ $0 is MasterTimelineViewController }).count < 1 { - masterTimelineViewController = UIStoryboard.main.instantiateController(ofType: MasterTimelineViewController.self) - masterTimelineViewController!.coordinator = self - navControllerForTimeline().pushViewController(masterTimelineViewController!, animated: !automated) - } + installTimelineControllerIfNecessary(animated: !automated) } else { timelineFetcher = nil @@ -1473,6 +1464,14 @@ private extension SceneCoordinator { // MARK: Double Split + func installTimelineControllerIfNecessary(animated: Bool) { + if navControllerForTimeline().viewControllers.filter({ $0 is MasterTimelineViewController }).count < 1 { + masterTimelineViewController = UIStoryboard.main.instantiateController(ofType: MasterTimelineViewController.self) + masterTimelineViewController!.coordinator = self + navControllerForTimeline().pushViewController(masterTimelineViewController!, animated: animated) + } + } + // Note about the Shim Controller // In the root split view controller's secondary (or detail) position we use a view controller that // only acts as a shim (or wrapper) for the actually desired contents of the second position. This