diff --git a/Demo/Classes/Presentation/Controllers/RowBuilderCellsController.swift b/Demo/Classes/Presentation/Controllers/RowBuilderCellsController.swift deleted file mode 100644 index 02ec115..0000000 --- a/Demo/Classes/Presentation/Controllers/RowBuilderCellsController.swift +++ /dev/null @@ -1,42 +0,0 @@ -// -// RowBuilderCellsController.swift -// TableKitDemo -// -// Created by Max Sokolov on 18/06/16. -// Copyright © 2016 Tablet. All rights reserved. -// - -import UIKit -import TableKit - -class RowBuilderCellsController: UIViewController { - - @IBOutlet weak var tableView: UITableView! { - didSet { - tableDirector = TableDirector(tableView: tableView) - tableDirector.register(ConfigurableTableViewCell.self) - } - } - var tableDirector: TableDirector! - - override func viewDidLoad() { - super.viewDidLoad() - - title = "Row builder cells" - - let numbers = ["1", "2", "3", "4", "5"] - - let clickAction = TableRowAction(.click) { (data) in - - print(data.item) - } - - let rowBuilder = TableRowBuilder(items: numbers, actions: [clickAction]) - - let section = TableSection(headerTitle: "Header title", footerTitle: "Footer title") - - section.append(builder: rowBuilder) - - tableDirector.append(section: section) - } -} \ No newline at end of file diff --git a/Demo/Resources/Storyboards/LaunchScreen.storyboard b/Demo/Resources/Storyboards/LaunchScreen.storyboard index f4fc7f7..d995c7c 100644 --- a/Demo/Resources/Storyboards/LaunchScreen.storyboard +++ b/Demo/Resources/Storyboards/LaunchScreen.storyboard @@ -1,5 +1,5 @@ - + diff --git a/Demo/Resources/Storyboards/Main.storyboard b/Demo/Resources/Storyboards/Main.storyboard index 2aeae2e..620edcb 100644 --- a/Demo/Resources/Storyboards/Main.storyboard +++ b/Demo/Resources/Storyboards/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -43,7 +43,7 @@ - + diff --git a/Demo/TableKitDemo.xcodeproj/project.pbxproj b/Demo/TableKitDemo.xcodeproj/project.pbxproj index 0de8bcb..c230c79 100644 --- a/Demo/TableKitDemo.xcodeproj/project.pbxproj +++ b/Demo/TableKitDemo.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ DA08A0531CF4E9B500BBF1F8 /* AutolayoutTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA08A0521CF4E9B500BBF1F8 /* AutolayoutTableViewCell.swift */; }; DA55465D1D1569CC00AA83EE /* AutolayoutCellsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA55465C1D1569CC00AA83EE /* AutolayoutCellsController.swift */; }; DA5546601D156A4F00AA83EE /* ConfigurableTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA55465F1D156A4F00AA83EE /* ConfigurableTableViewCell.swift */; }; - DA5546621D1573D300AA83EE /* RowBuilderCellsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5546611D1573D300AA83EE /* RowBuilderCellsController.swift */; }; DA5546641D15762000AA83EE /* NibTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5546631D15762000AA83EE /* NibTableViewCell.swift */; }; DA5546661D15765900AA83EE /* NibTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DA5546651D15765900AA83EE /* NibTableViewCell.xib */; }; DA5546681D15771D00AA83EE /* NibCellsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5546671D15771D00AA83EE /* NibCellsController.swift */; }; @@ -65,7 +64,6 @@ DA08A0521CF4E9B500BBF1F8 /* AutolayoutTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutolayoutTableViewCell.swift; sourceTree = ""; }; DA55465C1D1569CC00AA83EE /* AutolayoutCellsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutolayoutCellsController.swift; sourceTree = ""; }; DA55465F1D156A4F00AA83EE /* ConfigurableTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfigurableTableViewCell.swift; sourceTree = ""; }; - DA5546611D1573D300AA83EE /* RowBuilderCellsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowBuilderCellsController.swift; sourceTree = ""; }; DA5546631D15762000AA83EE /* NibTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NibTableViewCell.swift; sourceTree = ""; }; DA5546651D15765900AA83EE /* NibTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NibTableViewCell.xib; sourceTree = ""; }; DA5546671D15771D00AA83EE /* NibCellsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NibCellsController.swift; sourceTree = ""; }; @@ -184,7 +182,6 @@ children = ( DACB71751CC2D63D00432BD3 /* MainController.swift */, DA55465C1D1569CC00AA83EE /* AutolayoutCellsController.swift */, - DA5546611D1573D300AA83EE /* RowBuilderCellsController.swift */, DA5546671D15771D00AA83EE /* NibCellsController.swift */, ); path = Controllers; @@ -300,7 +297,6 @@ buildActionMask = 2147483647; files = ( DACB71761CC2D63D00432BD3 /* MainController.swift in Sources */, - DA5546621D1573D300AA83EE /* RowBuilderCellsController.swift in Sources */, DA55465D1D1569CC00AA83EE /* AutolayoutCellsController.swift in Sources */, DA5546681D15771D00AA83EE /* NibCellsController.swift in Sources */, DAC2D5CA1C9D303E009E9C19 /* AppDelegate.swift in Sources */, diff --git a/Sources/TableRowBuilder.swift b/Sources/TableRowBuilder.swift deleted file mode 100644 index 23158c2..0000000 --- a/Sources/TableRowBuilder.swift +++ /dev/null @@ -1,58 +0,0 @@ -// -// Copyright (c) 2015 Max Sokolov https://twitter.com/max_sokolov -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import UIKit - -public protocol RowBuilder { - - func rows() -> [Row]? -} - -public class TableRowBuilder: RowBuilder { - - public var items: [ItemType]? - public var actions: [TableRowAction]? - - public init(handler: (TableRowBuilder) -> ()) { - handler(self) - } - - public init(items: [ItemType], actions: [TableRowAction]? = nil) { - - self.items = items - self.actions = actions - } - - // MARK: - RowBuilder - - - public func rows() -> [Row]? { - return items?.map { TableRow(item: $0, actions: actions) } - } -} - -public extension TableSection { - - public func append(builder builder: RowBuilder) { - - if let rows = builder.rows() { - append(rows: rows) - } - } -} \ No newline at end of file diff --git a/TableKit.xcodeproj/project.pbxproj b/TableKit.xcodeproj/project.pbxproj index 9695039..b72ffe3 100644 --- a/TableKit.xcodeproj/project.pbxproj +++ b/TableKit.xcodeproj/project.pbxproj @@ -14,7 +14,6 @@ DA9EA7B31D0EC2C90021F650 /* TableDirector.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7AA1D0EC2C90021F650 /* TableDirector.swift */; }; DA9EA7B41D0EC2C90021F650 /* TableRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7AB1D0EC2C90021F650 /* TableRow.swift */; }; DA9EA7B51D0EC2C90021F650 /* TableRowAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7AC1D0EC2C90021F650 /* TableRowAction.swift */; }; - DA9EA7B61D0EC2C90021F650 /* TableRowBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7AD1D0EC2C90021F650 /* TableRowBuilder.swift */; }; DA9EA7B71D0EC2C90021F650 /* TableSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7AE1D0EC2C90021F650 /* TableSection.swift */; }; DA9EA7C91D0EC45F0021F650 /* TableKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA9EA7561D0B679A0021F650 /* TableKit.framework */; }; DA9EA7CF1D0EC4930021F650 /* TableKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7BE1D0EC41D0021F650 /* TableKitTests.swift */; }; @@ -39,7 +38,6 @@ DA9EA7AA1D0EC2C90021F650 /* TableDirector.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableDirector.swift; sourceTree = ""; }; DA9EA7AB1D0EC2C90021F650 /* TableRow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableRow.swift; sourceTree = ""; }; DA9EA7AC1D0EC2C90021F650 /* TableRowAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableRowAction.swift; sourceTree = ""; }; - DA9EA7AD1D0EC2C90021F650 /* TableRowBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableRowBuilder.swift; sourceTree = ""; }; DA9EA7AE1D0EC2C90021F650 /* TableSection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableSection.swift; sourceTree = ""; }; DA9EA7B91D0EC34E0021F650 /* TableKit.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = TableKit.plist; sourceTree = ""; }; DA9EA7BA1D0EC34E0021F650 /* TableKitTests.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = TableKitTests.plist; sourceTree = ""; }; @@ -90,7 +88,6 @@ children = ( DA9EA7AA1D0EC2C90021F650 /* TableDirector.swift */, DA9EA7AB1D0EC2C90021F650 /* TableRow.swift */, - DA9EA7AD1D0EC2C90021F650 /* TableRowBuilder.swift */, DA9EA7AC1D0EC2C90021F650 /* TableRowAction.swift */, DA9EA7AE1D0EC2C90021F650 /* TableSection.swift */, DA9EA7A91D0EC2C90021F650 /* TableCellAction.swift */, @@ -233,7 +230,6 @@ DA9EA7B21D0EC2C90021F650 /* TableCellAction.swift in Sources */, DA9EA7B11D0EC2C90021F650 /* Operators.swift in Sources */, DA9EA7B41D0EC2C90021F650 /* TableRow.swift in Sources */, - DA9EA7B61D0EC2C90021F650 /* TableRowBuilder.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };