Add expand and collapse all folders shortcuts
This commit is contained in:
parent
734ce4bc67
commit
6d24ea642a
@ -418,6 +418,16 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func expandAll(_ sender: Any?) {
|
||||||
|
coordinator.expandAllSectionsAndFolders()
|
||||||
|
self.applyChanges(animate: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func collapseAllExceptForGroupItems(_ sender: Any?) {
|
||||||
|
coordinator.collapseAllFolders()
|
||||||
|
self.applyChanges(animate: true)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: API
|
// MARK: API
|
||||||
|
|
||||||
func updateFeedSelection() {
|
func updateFeedSelection() {
|
||||||
|
@ -437,9 +437,10 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func expandSection(_ section: Int) {
|
func expandSection(_ section: Int) {
|
||||||
guard let expandNode = treeController.rootNode.childAtIndex(section) else {
|
guard let expandNode = treeController.rootNode.childAtIndex(section), !expandedNodes.contains(expandNode) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
expandedNodes.append(expandNode)
|
expandedNodes.append(expandNode)
|
||||||
|
|
||||||
animatingChanges = true
|
animatingChanges = true
|
||||||
@ -463,6 +464,20 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
animatingChanges = false
|
animatingChanges = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func expandAllSectionsAndFolders() {
|
||||||
|
for (sectionIndex, sectionNode) in treeController.rootNode.childNodes.enumerated() {
|
||||||
|
|
||||||
|
expandSection(sectionIndex)
|
||||||
|
|
||||||
|
for topLevelNode in sectionNode.childNodes {
|
||||||
|
if topLevelNode.representedObject is Folder, let indexPath = indexPathFor(topLevelNode) {
|
||||||
|
expandFolder(indexPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func expandFolder(_ indexPath: IndexPath) {
|
func expandFolder(_ indexPath: IndexPath) {
|
||||||
let expandNode = shadowTable[indexPath.section][indexPath.row]
|
let expandNode = shadowTable[indexPath.section][indexPath.row]
|
||||||
guard !expandedNodes.contains(expandNode) else { return }
|
guard !expandedNodes.contains(expandNode) else { return }
|
||||||
@ -481,12 +496,12 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func collapseSection(_ section: Int) {
|
func collapseSection(_ section: Int) {
|
||||||
animatingChanges = true
|
guard let collapseNode = treeController.rootNode.childAtIndex(section), expandedNodes.contains(collapseNode) else {
|
||||||
|
|
||||||
guard let collapseNode = treeController.rootNode.childAtIndex(section) else {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
animatingChanges = true
|
||||||
|
|
||||||
if let removeNode = expandedNodes.firstIndex(of: collapseNode) {
|
if let removeNode = expandedNodes.firstIndex(of: collapseNode) {
|
||||||
expandedNodes.remove(at: removeNode)
|
expandedNodes.remove(at: removeNode)
|
||||||
}
|
}
|
||||||
@ -496,6 +511,16 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
animatingChanges = false
|
animatingChanges = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func collapseAllFolders() {
|
||||||
|
for sectionNode in treeController.rootNode.childNodes {
|
||||||
|
for topLevelNode in sectionNode.childNodes {
|
||||||
|
if topLevelNode.representedObject is Folder, let indexPath = indexPathFor(topLevelNode) {
|
||||||
|
collapseFolder(indexPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func collapseFolder(_ indexPath: IndexPath) {
|
func collapseFolder(_ indexPath: IndexPath) {
|
||||||
animatingChanges = true
|
animatingChanges = true
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user