Animate Select Feed context menu result. Issue #1220

This commit is contained in:
Maurice Parker 2019-10-31 20:55:08 -05:00
parent ebed17ed2f
commit b78b996e88
3 changed files with 21 additions and 11 deletions

View File

@ -129,7 +129,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
guard let feed = notification.userInfo?[UserInfoKey.feed] as? Feed else { guard let feed = notification.userInfo?[UserInfoKey.feed] as? Feed else {
return return
} }
discloseFeed(feed) discloseFeed(feed, animated: true)
} }
@objc func contentSizeCategoryDidChange(_ note: Notification) { @objc func contentSizeCategoryDidChange(_ note: Notification) {
@ -481,7 +481,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
} }
} }
func discloseFeed(_ feed: Feed, completion: (() -> Void)? = nil) { func discloseFeed(_ feed: Feed, animated: Bool, completion: (() -> Void)? = nil) {
guard let node = coordinator.rootNode.descendantNodeRepresentingObject(feed as AnyObject) else { guard let node = coordinator.rootNode.descendantNodeRepresentingObject(feed as AnyObject) else {
completion?() completion?()
@ -490,7 +490,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
if let indexPath = dataSource.indexPath(for: node) { if let indexPath = dataSource.indexPath(for: node) {
tableView.selectRowAndScrollIfNotVisible(at: indexPath, animated: true) tableView.selectRowAndScrollIfNotVisible(at: indexPath, animated: true)
coordinator.selectFeed(indexPath) coordinator.selectFeed(indexPath, animated: animated)
completion?() completion?()
return return
} }
@ -505,7 +505,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
self.applyChanges(animate: true, adjustScroll: true) { [weak self] in self.applyChanges(animate: true, adjustScroll: true) { [weak self] in
if let indexPath = self?.dataSource.indexPath(for: node) { if let indexPath = self?.dataSource.indexPath(for: node) {
self?.coordinator.selectFeed(indexPath) self?.coordinator.selectFeed(indexPath, animated: animated)
completion?() completion?()
} }
} }

View File

@ -586,7 +586,8 @@ private extension MasterTimelineViewController {
let title = NSLocalizedString("Select Feed", comment: "Select Feed") let title = NSLocalizedString("Select Feed", comment: "Select Feed")
let action = UIAction(title: title, image: AppAssets.openInSidebarImage) { [weak self] action in let action = UIAction(title: title, image: AppAssets.openInSidebarImage) { [weak self] action in
self?.coordinator.discloseFeed(feed) self?.coordinator.selectFeed(nil, animated: true)
self?.coordinator.discloseFeed(feed, animated: true)
} }
return action return action
} }
@ -596,7 +597,8 @@ private extension MasterTimelineViewController {
let title = NSLocalizedString("Select Feed", comment: "Select Feed") let title = NSLocalizedString("Select Feed", comment: "Select Feed")
let action = UIAlertAction(title: title, style: .default) { [weak self] action in let action = UIAlertAction(title: title, style: .default) { [weak self] action in
self?.coordinator.discloseFeed(feed) self?.coordinator.selectFeed(nil, animated: true)
self?.coordinator.discloseFeed(feed, animated: true)
completionHandler(true) completionHandler(true)
} }
return action return action

View File

@ -65,6 +65,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
private var lastSearchScope: SearchScope? = nil private var lastSearchScope: SearchScope? = nil
private var isSearching: Bool = false private var isSearching: Bool = false
private var searchArticleIds: Set<String>? = nil private var searchArticleIds: Set<String>? = nil
private var isTimelineViewControllerPending = false
private var isArticleViewControllerPending = false private var isArticleViewControllerPending = false
private(set) var sortDirection = AppDefaults.timelineSortDirection { private(set) var sortDirection = AppDefaults.timelineSortDirection {
@ -782,8 +783,8 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
markArticlesWithUndo([article], statusKey: .starred, flag: !article.status.starred) markArticlesWithUndo([article], statusKey: .starred, flag: !article.status.starred)
} }
func discloseFeed(_ feed: Feed, completion: (() -> Void)? = nil) { func discloseFeed(_ feed: Feed, animated: Bool, completion: (() -> Void)? = nil) {
masterFeedViewController.discloseFeed(feed) { masterFeedViewController.discloseFeed(feed, animated: animated) {
completion?() completion?()
} }
} }
@ -952,11 +953,15 @@ extension SceneCoordinator: UINavigationControllerDelegate {
} }
// If we are showing the Feeds and only the feeds start clearing stuff // If we are showing the Feeds and only the feeds start clearing stuff
if viewController === masterFeedViewController && !isThreePanelMode { if viewController === masterFeedViewController && !isThreePanelMode && !isTimelineViewControllerPending {
activityManager.invalidateCurrentActivities() activityManager.invalidateCurrentActivities()
selectFeed(nil) selectFeed(nil)
return return
} }
if viewController is MasterTimelineViewController {
isTimelineViewControllerPending = false
}
// If we are using a phone and navigate away from the detail, clear up the article resources (including activity). // If we are using a phone and navigate away from the detail, clear up the article resources (including activity).
// Don't clear it if we have pushed an ArticleViewController, but don't yet see it on the navigation stack. // Don't clear it if we have pushed an ArticleViewController, but don't yet see it on the navigation stack.
@ -1473,6 +1478,9 @@ private extension SceneCoordinator {
// MARK: Double Split // MARK: Double Split
func installTimelineControllerIfNecessary(animated: Bool) { func installTimelineControllerIfNecessary(animated: Bool) {
isTimelineViewControllerPending = true
if navControllerForTimeline().viewControllers.filter({ $0 is MasterTimelineViewController }).count < 1 { if navControllerForTimeline().viewControllers.filter({ $0 is MasterTimelineViewController }).count < 1 {
masterTimelineViewController = UIStoryboard.main.instantiateController(ofType: MasterTimelineViewController.self) masterTimelineViewController = UIStoryboard.main.instantiateController(ofType: MasterTimelineViewController.self)
masterTimelineViewController!.coordinator = self masterTimelineViewController!.coordinator = self
@ -1654,7 +1662,7 @@ private extension SceneCoordinator {
return return
} }
if let feed = feedNode.representedObject as? Feed { if let feed = feedNode.representedObject as? Feed {
discloseFeed(feed) discloseFeed(feed, animated: false)
} }
} }
@ -1663,7 +1671,7 @@ private extension SceneCoordinator {
return return
} }
discloseFeed(feedNode.representedObject as! Feed) { discloseFeed(feedNode.representedObject as! Feed, animated: false) {
guard let articleID = userInfo?[DeepLinkKey.articleID.rawValue] as? String else { return } guard let articleID = userInfo?[DeepLinkKey.articleID.rawValue] as? String else { return }
if let article = self.articles.first(where: { $0.articleID == articleID }) { if let article = self.articles.first(where: { $0.articleID == articleID }) {