From 953259f0d3778df1192d05dcbb65cb95f14df39e Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 5 Sep 2019 16:04:07 -0500 Subject: [PATCH] Add selected row expanding and collapsing keyboard shortcuts --- iOS/MasterFeed/MasterFeedViewController.swift | 14 ++++++++++++++ iOS/SceneCoordinator.swift | 2 ++ 2 files changed, 16 insertions(+) diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index 36f352fd9..048dfb94a 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -404,6 +404,20 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner { } } + @objc func expandSelectedRows(_ sender: Any?) { + if let indexPath = coordinator.currentFeedIndexPath { + coordinator.expand(indexPath) + self.applyChanges(animate: true) + } + } + + @objc func collapseSelectedRows(_ sender: Any?) { + if let indexPath = coordinator.currentFeedIndexPath { + coordinator.collapse(indexPath) + self.applyChanges(animate: true) + } + } + // MARK: API func updateFeedSelection() { diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index a7c655e07..57ca14d14 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -465,6 +465,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { func expand(_ indexPath: IndexPath) { let expandNode = shadowTable[indexPath.section][indexPath.row] + guard !expandedNodes.contains(expandNode) else { return } expandedNodes.append(expandNode) animatingChanges = true @@ -499,6 +500,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { animatingChanges = true let collapseNode = shadowTable[indexPath.section][indexPath.row] + guard expandedNodes.contains(collapseNode) else { return } if let removeNode = expandedNodes.firstIndex(of: collapseNode) { expandedNodes.remove(at: removeNode) }