diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index 6bcec71db..6c1990462 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -150,6 +150,11 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner updateUI() } + func showSearchAll() { + navigationItem.searchController?.isActive = true + navigationItem.searchController?.searchBar.selectedScopeButtonIndex = 1 + } + // MARK: - Table view override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 06680c802..ea3e5587d 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -99,19 +99,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { return sections } - private(set) var currentMasterIndexPath: IndexPath? { - didSet { - guard let ip = currentMasterIndexPath, let node = nodeFor(ip) else { - assertionFailure() - return - } - if let fetcher = node.representedObject as? ArticleFetcher { - timelineFetcher = fetcher - } - masterFeedViewController.updateFeedSelection() - updateSelectingActivity(with: node) - } - } + private(set) var currentMasterIndexPath: IndexPath? var timelineName: String? { return (timelineFetcher as? DisplayNameProvider)?.nameForDisplay @@ -286,6 +274,16 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { } } + func selectFirstUnreadInAllUnread() { + selectFeed(IndexPath(row: 1, section: 0)) + selectFirstUnreadArticleInTimeline() + } + + func showSearch() { + selectFeed(nil) + masterTimelineViewController?.showSearchAll() + } + // MARK: Notifications @objc func statusesDidChange(_ note: Notification) { @@ -483,16 +481,23 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { return indexes } - func selectFeed(_ indexPath: IndexPath) { - if navControllerForTimeline().viewControllers.filter({ $0 is MasterTimelineViewController }).count > 0 { - currentMasterIndexPath = indexPath - } else { + func selectFeed(_ indexPath: IndexPath?) { + if navControllerForTimeline().viewControllers.filter({ $0 is MasterTimelineViewController }).count < 1 { masterTimelineViewController = UIStoryboard.main.instantiateController(ofType: MasterTimelineViewController.self) masterTimelineViewController!.coordinator = self - currentMasterIndexPath = indexPath navControllerForTimeline().pushViewController(masterTimelineViewController!, animated: true) } + + currentMasterIndexPath = indexPath + + if let ip = indexPath, let node = nodeFor(ip), let fetcher = node.representedObject as? ArticleFetcher { + timelineFetcher = fetcher + updateSelectingActivity(with: node) + } else { + timelineFetcher = nil + } + masterFeedViewController.updateFeedSelection() selectArticle(nil) } @@ -584,11 +589,6 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { } } - func selectFirstUnreadInAllUnread() { - selectFeed(IndexPath(row: 1, section: 0)) - selectFirstUnreadArticleInTimeline() - } - func selectFirstUnread() { selectFirstUnreadArticleInTimeline() } diff --git a/iOS/SceneDelegate.swift b/iOS/SceneDelegate.swift index 70e88bd65..3e476b931 100644 --- a/iOS/SceneDelegate.swift +++ b/iOS/SceneDelegate.swift @@ -62,6 +62,8 @@ private extension SceneDelegate { switch shortcutItem.type { case "com.ranchero.NetNewsWire.FirstUnread": coordinator.selectFirstUnreadInAllUnread() + case "com.ranchero.NetNewsWire.ShowSearch": + coordinator.showSearch() default: break }