diff --git a/TableKit/Tablet.swift b/TableKit/TableCellAction.swift similarity index 91% rename from TableKit/Tablet.swift rename to TableKit/TableCellAction.swift index 2d52800..8c81bef 100644 --- a/TableKit/Tablet.swift +++ b/TableKit/TableCellAction.swift @@ -20,12 +20,10 @@ import UIKit -struct TabletNotifications { - static let CellAction = "TabletNotificationsCellAction" +struct TableKitNotifications { + static let CellAction = "TableKitNotificationsCellAction" } - - /** A custom action that you can trigger from your cell. You can eacily catch actions using a chaining manner with your row builder. @@ -49,6 +47,6 @@ public class TableCellAction { } public func invoke() { - NSNotificationCenter.defaultCenter().postNotificationName(TabletNotifications.CellAction, object: self, userInfo: userInfo) + NSNotificationCenter.defaultCenter().postNotificationName(TableKitNotifications.CellAction, object: self, userInfo: userInfo) } } \ No newline at end of file diff --git a/TableKit/TableDirector.swift b/TableKit/TableDirector.swift index a935721..03545f6 100644 --- a/TableKit/TableDirector.swift +++ b/TableKit/TableDirector.swift @@ -37,7 +37,7 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate self.tableView?.delegate = self self.tableView?.dataSource = self - NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(didReceiveAction), name: TabletNotifications.CellAction, object: nil) + NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(didReceiveAction), name: TableKitNotifications.CellAction, object: nil) } deinit { @@ -69,12 +69,9 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate } func didReceiveAction(notification: NSNotification) { - - //if let action = notification.object as? Action, indexPath = tableView?.indexPathForCell(action.cell) { - - //let builder = builderAtIndexPath(indexPath) - //builder.0.invoke(action: .custom(action.key), cell: action.cell, indexPath: indexPath, itemIndex: builder.1, userInfo: notification.userInfo) - //} + + guard let action = notification.object as? TableCellAction, indexPath = tableView?.indexPathForCell(action.cell) else { return } + invoke(action: .custom(action.key), cell: action.cell, indexPath: indexPath) } // MARK: - Height diff --git a/TableKit/TableKit.xcodeproj/project.pbxproj b/TableKit/TableKit.xcodeproj/project.pbxproj index e812f36..449e067 100644 --- a/TableKit/TableKit.xcodeproj/project.pbxproj +++ b/TableKit/TableKit.xcodeproj/project.pbxproj @@ -14,7 +14,7 @@ DA9EA7751D0B68460021F650 /* TableRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA76C1D0B68460021F650 /* TableRow.swift */; }; DA9EA7761D0B68460021F650 /* TableRowAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA76D1D0B68460021F650 /* TableRowAction.swift */; }; DA9EA7781D0B68460021F650 /* TableSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA76F1D0B68460021F650 /* TableSection.swift */; }; - DA9EA7791D0B68460021F650 /* Tablet.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7701D0B68460021F650 /* Tablet.swift */; }; + DA9EA7791D0B68460021F650 /* TableCellAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7701D0B68460021F650 /* TableCellAction.swift */; }; DA9EA7801D0B689C0021F650 /* TableKit.h in Headers */ = {isa = PBXBuildFile; fileRef = DA9EA77E1D0B689C0021F650 /* TableKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; /* End PBXBuildFile section */ @@ -27,7 +27,7 @@ DA9EA76C1D0B68460021F650 /* TableRow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableRow.swift; sourceTree = ""; }; DA9EA76D1D0B68460021F650 /* TableRowAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableRowAction.swift; sourceTree = ""; }; DA9EA76F1D0B68460021F650 /* TableSection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableSection.swift; sourceTree = ""; }; - DA9EA7701D0B68460021F650 /* Tablet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Tablet.swift; sourceTree = ""; }; + DA9EA7701D0B68460021F650 /* TableCellAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableCellAction.swift; sourceTree = ""; }; DA9EA77D1D0B689C0021F650 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; DA9EA77E1D0B689C0021F650 /* TableKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableKit.h; sourceTree = ""; }; /* End PBXFileReference section */ @@ -67,10 +67,10 @@ DA9EA76F1D0B68460021F650 /* TableSection.swift */, DA9EA76C1D0B68460021F650 /* TableRow.swift */, DA9EA76D1D0B68460021F650 /* TableRowAction.swift */, + DA9EA7701D0B68460021F650 /* TableCellAction.swift */, DA9EA7681D0B68460021F650 /* ConfigurableCell.swift */, DA9EA7691D0B68460021F650 /* HeightStrategy.swift */, DA9EA76A1D0B68460021F650 /* Operators.swift */, - DA9EA7701D0B68460021F650 /* Tablet.swift */, ); name = Classes; sourceTree = ""; @@ -168,7 +168,7 @@ DA9EA7751D0B68460021F650 /* TableRow.swift in Sources */, DA9EA7761D0B68460021F650 /* TableRowAction.swift in Sources */, DA9EA7741D0B68460021F650 /* TableDirector.swift in Sources */, - DA9EA7791D0B68460021F650 /* Tablet.swift in Sources */, + DA9EA7791D0B68460021F650 /* TableCellAction.swift in Sources */, DA9EA7731D0B68460021F650 /* Operators.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/TableKitDemo/Classes/Presentation/Views/StoryboardImageTableViewCell.swift b/TableKitDemo/Classes/Presentation/Views/StoryboardImageTableViewCell.swift index c809967..4cd5631 100644 --- a/TableKitDemo/Classes/Presentation/Views/StoryboardImageTableViewCell.swift +++ b/TableKitDemo/Classes/Presentation/Views/StoryboardImageTableViewCell.swift @@ -22,12 +22,15 @@ class StoryboardImageTableViewCell: UITableViewCell, ConfigurableCell { titleLabel.text = string subtitleLabel.text = "Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.1" } + + static func estimatedHeight() -> CGFloat { + return 500 + } override func layoutSubviews() { super.layoutSubviews() - contentView.layoutIfNeeded() - - subtitleLabel.preferredMaxLayoutWidth = subtitleLabel.bounds.size.width + //contentView.layoutIfNeeded() + //subtitleLabel.preferredMaxLayoutWidth = subtitleLabel.bounds.size.width } } \ No newline at end of file