Refactor how the No Selection message is displayed

This commit is contained in:
Maurice Parker 2019-08-01 06:53:34 -05:00
parent d2f43678a7
commit 88c6f2274b

View File

@ -210,7 +210,6 @@ class AppCoordinator: NSObject, UndoableCommandRunner {
rootSplitViewController.delegate = self rootSplitViewController.delegate = self
masterNavigationController = (rootSplitViewController.viewControllers.first as! UINavigationController) masterNavigationController = (rootSplitViewController.viewControllers.first as! UINavigationController)
masterNavigationController.delegate = self
masterFeedViewController = UIStoryboard.main.instantiateController(ofType: MasterFeedViewController.self) masterFeedViewController = UIStoryboard.main.instantiateController(ofType: MasterFeedViewController.self)
masterFeedViewController.coordinator = self masterFeedViewController.coordinator = self
masterNavigationController.pushViewController(masterFeedViewController, animated: false) masterNavigationController.pushViewController(masterFeedViewController, animated: false)
@ -453,18 +452,24 @@ class AppCoordinator: NSObject, UndoableCommandRunner {
navControllerForTimeline().pushViewController(masterTimelineViewController!, animated: true) navControllerForTimeline().pushViewController(masterTimelineViewController!, animated: true)
} }
if isThreePanelMode { selectArticle(nil)
let systemMessageViewController = UIStoryboard.main.instantiateController(ofType: SystemMessageViewController.self)
let targetSplitController = targetSplitForDetail()
let controller = addNavControllerIfNecessary(systemMessageViewController, split: targetSplitController, showBackButton: false)
targetSplitController.showDetailViewController(controller, sender: self)
}
} }
func selectArticle(_ indexPath: IndexPath) { func selectArticle(_ indexPath: IndexPath?) {
if detailViewController != nil { currentArticleIndexPath = indexPath
currentArticleIndexPath = indexPath
} else { if indexPath == nil {
if !rootSplitViewController.isCollapsed {
let systemMessageViewController = UIStoryboard.main.instantiateController(ofType: SystemMessageViewController.self)
let showBackButton = rootSplitViewController.displayMode != .allVisible
let targetSplit = targetSplitForDetail()
let controller = addNavControllerIfNecessary(systemMessageViewController, split: targetSplit, showBackButton: showBackButton)
targetSplit.showDetailViewController(controller, sender: self)
}
return
}
if detailViewController == nil {
let targetSplit = targetSplitForDetail() let targetSplit = targetSplitForDetail()
let detailViewController = UIStoryboard.main.instantiateController(ofType: DetailViewController.self) let detailViewController = UIStoryboard.main.instantiateController(ofType: DetailViewController.self)
@ -593,21 +598,6 @@ class AppCoordinator: NSObject, UndoableCommandRunner {
} }
// MARK: UINavigationControllerDelegate
extension AppCoordinator: UINavigationControllerDelegate {
func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
if rootSplitViewController.isCollapsed != true && navigationController.viewControllers.count == 1 {
let systemMessageViewController = UIStoryboard.main.instantiateController(ofType: SystemMessageViewController.self)
let showBackButton = rootSplitViewController.displayMode != .allVisible
let controller = addNavControllerIfNecessary(systemMessageViewController, split: rootSplitViewController, showBackButton: showBackButton)
rootSplitViewController.showDetailViewController(controller, sender: self)
}
}
}
// MARK: UISplitViewControllerDelegate // MARK: UISplitViewControllerDelegate
extension AppCoordinator: UISplitViewControllerDelegate { extension AppCoordinator: UISplitViewControllerDelegate {