Encapsulate more of the NavigationModelController structures.

This commit is contained in:
Maurice Parker 2019-04-21 15:26:37 -05:00
parent 6468f2c333
commit 73500e0244
2 changed files with 11 additions and 7 deletions

View File

@ -77,8 +77,8 @@ class MasterViewController: UITableViewController, UndoableCommandRunner {
}
if let account = representedObject as? Account {
if let node = nmc.treeController.rootNode.childNodeRepresentingObject(account) {
let sectionIndex = nmc.treeController.rootNode.indexOfChild(node)!
if let node = nmc.rootNode.childNodeRepresentingObject(account) {
let sectionIndex = nmc.rootNode.indexOfChild(node)!
let headerView = tableView.headerView(forSection: sectionIndex) as! MasterTableViewSectionHeader
headerView.unreadCount = account.unreadCount
}
@ -108,7 +108,7 @@ class MasterViewController: UITableViewController, UndoableCommandRunner {
@objc func userDidAddFeed(_ notification: Notification) {
guard let feed = notification.userInfo?[UserInfoKey.feed],
let node = nmc.treeController.rootNode.descendantNodeRepresentingObject(feed as AnyObject) else {
let node = nmc.rootNode.descendantNodeRepresentingObject(feed as AnyObject) else {
return
}
@ -150,14 +150,14 @@ class MasterViewController: UITableViewController, UndoableCommandRunner {
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
guard let nameProvider = nmc.treeController.rootNode.childAtIndex(section)?.representedObject as? DisplayNameProvider else {
guard let nameProvider = nmc.rootNode.childAtIndex(section)?.representedObject as? DisplayNameProvider else {
return nil
}
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! MasterTableViewSectionHeader
headerView.name = nameProvider.nameForDisplay
guard let sectionNode = nmc.treeController.rootNode.childAtIndex(section) else {
guard let sectionNode = nmc.rootNode.childAtIndex(section) else {
return headerView
}
@ -325,7 +325,7 @@ class MasterViewController: UITableViewController, UndoableCommandRunner {
// Based on the drop we have to determine a node to start looking for a parent container.
let destNode: Node = {
if destinationIndexPath.row == 0 {
return nmc.treeController.rootNode.childAtIndex(destinationIndexPath.section)!
return nmc.rootNode.childAtIndex(destinationIndexPath.section)!
} else {
let movementAdjustment = sourceIndexPath > destinationIndexPath ? 1 : 0
let adjustedDestIndexPath = IndexPath(row: destinationIndexPath.row - movementAdjustment, section: destinationIndexPath.section)
@ -452,7 +452,7 @@ class MasterViewController: UITableViewController, UndoableCommandRunner {
@objc func toggleSectionHeader(_ sender: UITapGestureRecognizer) {
guard let sectionIndex = sender.view?.tag,
let sectionNode = nmc.treeController.rootNode.childAtIndex(sectionIndex),
let sectionNode = nmc.rootNode.childAtIndex(sectionIndex),
let headerView = sender.view as? MasterTableViewSectionHeader
else {
return

View File

@ -33,6 +33,10 @@ class NavigationModelController {
return TreeController(delegate: treeControllerDelegate)
}()
var rootNode: Node {
return treeController.rootNode
}
private var sortDirection = AppDefaults.timelineSortDirection {
didSet {
if sortDirection != oldValue {