Implement search home page quick action

This commit is contained in:
Maurice Parker
2019-09-01 17:41:46 -05:00
parent 33882ab276
commit c405fdf583
3 changed files with 30 additions and 23 deletions

View File

@@ -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? {

View File

@@ -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()
}

View File

@@ -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
}