From 3f388d847185bc2e74e721c610e526216789dca1 Mon Sep 17 00:00:00 2001 From: jeantimex Date: Thu, 3 Aug 2017 10:32:30 -0700 Subject: [PATCH] Simplify heightForRowAt. --- CollapsibleTableSectionViewController.podspec | 2 +- ...ollapsibleTableSectionViewController.swift | 3 +-- ...sibleTableSectionViewControllerTests.swift | 22 ------------------- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/CollapsibleTableSectionViewController.podspec b/CollapsibleTableSectionViewController.podspec index 27d60a9..904fde1 100644 --- a/CollapsibleTableSectionViewController.podspec +++ b/CollapsibleTableSectionViewController.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |s| # s.name = "CollapsibleTableSectionViewController" - s.version = "1.0.0" + s.version = "1.0.1" s.summary = "Swift 3.0 library to support collapsible sections in a table view." # This description is used to generate tags and improve search results. diff --git a/CollapsibleTableSectionViewController/CollapsibleTableSectionViewController.swift b/CollapsibleTableSectionViewController/CollapsibleTableSectionViewController.swift index cd98d6d..a4b4ed6 100644 --- a/CollapsibleTableSectionViewController/CollapsibleTableSectionViewController.swift +++ b/CollapsibleTableSectionViewController/CollapsibleTableSectionViewController.swift @@ -109,8 +109,7 @@ extension CollapsibleTableSectionViewController: UITableViewDataSource, UITableV } public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - let section = (indexPath as NSIndexPath).section - return isSectionCollapsed(section) ? 0 : UITableViewAutomaticDimension + return UITableViewAutomaticDimension } public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { diff --git a/CollapsibleTableSectionViewControllerTests/CollapsibleTableSectionViewControllerTests.swift b/CollapsibleTableSectionViewControllerTests/CollapsibleTableSectionViewControllerTests.swift index 7f4e230..26eee3c 100644 --- a/CollapsibleTableSectionViewControllerTests/CollapsibleTableSectionViewControllerTests.swift +++ b/CollapsibleTableSectionViewControllerTests/CollapsibleTableSectionViewControllerTests.swift @@ -150,29 +150,7 @@ class CollapsibleTableSectionViewControllerTests: XCTestCase { // Test heightForRowAt // - func testReturnsZeroWhenSectionIsCollapsed() { - class MockCollapsibleTableSectionViewController: CollapsibleTableSectionViewController { - override public func isSectionCollapsed(_ section: Int) -> Bool { - return true - } - } - - viewController = MockCollapsibleTableSectionViewController() - - let heightForRowAt = viewController.tableView(tableView, heightForRowAt: IndexPath(row: 0, section: 0)) - - XCTAssertEqual(heightForRowAt, 0) - } - func testReturnsUITableViewAutomaticDimension() { - class MockCollapsibleTableSectionViewController: CollapsibleTableSectionViewController { - override public func isSectionCollapsed(_ section: Int) -> Bool { - return false - } - } - - viewController = MockCollapsibleTableSectionViewController() - let heightForRowAt = viewController.tableView(tableView, heightForRowAt: IndexPath(row: 0, section: 0)) XCTAssertEqual(heightForRowAt, UITableViewAutomaticDimension)