Change Select Feed to Go to Feed. Issue #1240

This commit is contained in:
Maurice Parker 2019-11-13 15:22:22 -06:00
parent 2fd2b8b1b0
commit 38535910ef
3 changed files with 40 additions and 37 deletions

View File

@ -65,11 +65,10 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
configureToolbar()
becomeFirstResponder()
}
override func viewWillAppear(_ animated: Bool) {
navigationController?.title = NSLocalizedString("Feeds", comment: "Feeds")
applyChanges(animate: false)
updateUI()
super.viewWillAppear(animated)
}
@ -101,7 +100,10 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
}
if let node = node, dataSource.indexPath(for: node) != nil {
reloadNode(node)
// This can stop the scrolling of the disclose function if we don't delay it enough to complete
DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) {
self.reloadNode(node)
}
}
}
@ -462,14 +464,14 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
}
}
func updateFeedSelection() {
func updateFeedSelection(animated: Bool) {
if dataSource.snapshot().numberOfItems > 0 {
if let indexPath = coordinator.currentFeedIndexPath {
if tableView.indexPathForSelectedRow != indexPath {
tableView.selectRowAndScrollIfNotVisible(at: indexPath, animated: true)
tableView.selectRowAndScrollIfNotVisible(at: indexPath, animated: animated)
}
} else {
tableView.selectRow(at: nil, animated: true, scrollPosition: .none)
tableView.selectRow(at: nil, animated: animated, scrollPosition: .none)
}
}
}
@ -1022,7 +1024,7 @@ private extension MasterFeedViewController {
deleteCommand.perform()
if indexPath == coordinator.currentFeedIndexPath {
coordinator.selectFeed(nil)
coordinator.selectFeed(nil, animated: false)
}
}

View File

@ -592,10 +592,9 @@ private extension MasterTimelineViewController {
func discloseFeedAction(_ article: Article) -> UIAction? {
guard let feed = article.feed else { return nil }
let title = NSLocalizedString("Select Feed", comment: "Select Feed")
let title = NSLocalizedString("Go to Feed", comment: "Go to Feed")
let action = UIAction(title: title, image: AppAssets.openInSidebarImage) { [weak self] action in
self?.coordinator.selectFeed(nil, animated: true)
self?.coordinator.discloseFeed(feed, animated: true)
self?.coordinator.discloseFeed(feed, animated: false)
}
return action
}
@ -603,10 +602,9 @@ private extension MasterTimelineViewController {
func discloseFeedAlertAction(_ article: Article, completionHandler: @escaping (Bool) -> Void) -> UIAlertAction? {
guard let feed = article.feed else { return nil }
let title = NSLocalizedString("Select Feed", comment: "Select Feed")
let title = NSLocalizedString("Go to Feed", comment: "Go to Feed")
let action = UIAlertAction(title: title, style: .default) { [weak self] action in
self?.coordinator.selectFeed(nil, animated: true)
self?.coordinator.discloseFeed(feed, animated: true)
self?.coordinator.discloseFeed(feed, animated: false)
completionHandler(true)
}
return action

View File

@ -89,9 +89,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
}
private let treeControllerDelegate = FeedTreeControllerDelegate()
private lazy var treeController: TreeController = {
return TreeController(delegate: treeControllerDelegate)
}()
private let treeController: TreeController
var stateRestorationActivity: NSUserActivity? {
return activityManager.stateRestorationActivity
@ -280,6 +278,8 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
}
override init() {
treeController = TreeController(delegate: treeControllerDelegate)
super.init()
for section in treeController.rootNode.childNodes {
@ -315,6 +315,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
masterFeedViewController = UIStoryboard.main.instantiateController(ofType: MasterFeedViewController.self)
masterFeedViewController.coordinator = self
masterNavigationController.pushViewController(masterFeedViewController, animated: false)
masterFeedViewController.reloadFeeds()
let articleViewController = UIStoryboard.main.instantiateController(ofType: ArticleViewController.self)
articleViewController.coordinator = self
@ -327,7 +328,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
}
func handle(_ activity: NSUserActivity) {
selectFeed(nil)
selectFeed(nil, animated: false)
guard let activityType = ActivityType(rawValue: activity.activityType) else { return }
switch activityType {
@ -371,12 +372,12 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
}
func selectFirstUnreadInAllUnread() {
selectFeed(IndexPath(row: 1, section: 0))
selectFeed(IndexPath(row: 1, section: 0), animated: false)
selectFirstUnreadArticleInTimeline()
}
func showSearch() {
selectFeed(nil)
selectFeed(nil, animated: false)
installTimelineControllerIfNecessary(animated: false)
DispatchQueue.main.asyncAfter(deadline: .now()) {
self.masterTimelineViewController!.showSearchAll()
@ -532,13 +533,13 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
return indexPathFor(node)
}
func selectFeed(_ indexPath: IndexPath?, animated: Bool = false) {
func selectFeed(_ indexPath: IndexPath?, animated: Bool) {
guard indexPath != currentFeedIndexPath else { return }
selectArticle(nil)
currentFeedIndexPath = indexPath
masterFeedViewController.updateFeedSelection()
masterFeedViewController.updateFeedSelection(animated: animated)
if let ip = indexPath, let node = nodeFor(ip), let fetcher = node.representedObject as? ArticleFetcher {
timelineFetcher = fetcher
@ -556,31 +557,31 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
func selectPrevFeed() {
if let indexPath = prevFeedIndexPath {
selectFeed(indexPath)
selectFeed(indexPath, animated: true)
}
}
func selectNextFeed() {
if let indexPath = nextFeedIndexPath {
selectFeed(indexPath)
selectFeed(indexPath, animated: true)
}
}
func selectTodayFeed() {
masterFeedViewController?.ensureSectionIsExpanded(0) {
self.selectFeed(IndexPath(row: 0, section: 0))
self.selectFeed(IndexPath(row: 0, section: 0), animated: true)
}
}
func selectAllUnreadFeed() {
masterFeedViewController?.ensureSectionIsExpanded(0) {
self.selectFeed(IndexPath(row: 1, section: 0))
self.selectFeed(IndexPath(row: 1, section: 0), animated: true)
}
}
func selectStarredFeed() {
masterFeedViewController?.ensureSectionIsExpanded(0) {
self.selectFeed(IndexPath(row: 2, section: 0))
self.selectFeed(IndexPath(row: 2, section: 0), animated: true)
}
}
@ -830,7 +831,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
}
func showAdd(_ type: AddControllerType, initialFeed: String? = nil, initialFeedName: String? = nil) {
selectFeed(nil)
selectFeed(nil, animated: false)
let addViewController = UIStoryboard.add.instantiateInitialViewController() as! UINavigationController
@ -969,7 +970,7 @@ extension SceneCoordinator: UINavigationControllerDelegate {
// If we are showing the Feeds and only the feeds start clearing stuff
if viewController === masterFeedViewController && !isThreePanelMode && !isTimelineViewControllerPending {
activityManager.invalidateCurrentActivities()
selectFeed(nil)
selectFeed(nil, animated: true)
return
}
@ -1204,7 +1205,7 @@ private extension SceneCoordinator {
}
if unreadCountProvider.unreadCount > 0 {
selectFeed(prevIndexPath)
selectFeed(prevIndexPath, animated: true)
return true
}
@ -1310,7 +1311,7 @@ private extension SceneCoordinator {
}
if unreadCountProvider.unreadCount > 0 {
selectFeed(nextIndexPath)
selectFeed(nextIndexPath, animated: true)
return true
}
@ -1492,13 +1493,15 @@ private extension SceneCoordinator {
// MARK: Double Split
func installTimelineControllerIfNecessary(animated: Bool) {
isTimelineViewControllerPending = true
if navControllerForTimeline().viewControllers.filter({ $0 is MasterTimelineViewController }).count < 1 {
isTimelineViewControllerPending = true
masterTimelineViewController = UIStoryboard.main.instantiateController(ofType: MasterTimelineViewController.self)
masterTimelineViewController!.coordinator = self
navControllerForTimeline().pushViewController(masterTimelineViewController!, animated: animated)
masterTimelineViewController?.reloadArticles(animate: false)
}
}
@ -1646,19 +1649,19 @@ private extension SceneCoordinator {
func handleSelectToday() {
if let indexPath = indexPathFor(SmartFeedsController.shared.todayFeed) {
selectFeed(indexPath)
selectFeed(indexPath, animated: false)
}
}
func handleSelectAllUnread() {
if let indexPath = indexPathFor(SmartFeedsController.shared.unreadFeed) {
selectFeed(indexPath)
selectFeed(indexPath, animated: false)
}
}
func handleSelectStarred() {
if let indexPath = indexPathFor(SmartFeedsController.shared.starredFeed) {
selectFeed(indexPath)
selectFeed(indexPath, animated: false)
}
}
@ -1667,7 +1670,7 @@ private extension SceneCoordinator {
return
}
if let indexPath = indexPathFor(folderNode) {
selectFeed(indexPath)
selectFeed(indexPath, animated: false)
}
}