mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Implement search home page quick action
This commit is contained in:
@@ -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? {
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user