add isPrototype property

This commit is contained in:
Max Sokolov 2016-06-15 20:42:10 +03:00
parent 98c481be71
commit a2f8bdde30
6 changed files with 8 additions and 8 deletions

View File

@ -17,7 +17,7 @@ class StoryboardImageTableViewCell: UITableViewCell, ConfigurableCell {
@IBOutlet var subtitleLabel: UILabel!
@IBOutlet var customImageView: UIImageView!
func configure(string: T) {
func configure(string: T, isPrototype: Bool) {
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"

View File

@ -13,7 +13,7 @@ class StoryboardTableViewCell: UITableViewCell, ConfigurableCell {
typealias T = String
func configure(value: T) {
func configure(value: T, isPrototype: Bool) {
textLabel?.text = value
}
}

View File

@ -27,7 +27,7 @@ public protocol ConfigurableCell {
static func reusableIdentifier() -> String
static func estimatedHeight() -> CGFloat
static func defaultHeight() -> CGFloat?
func configure(_: T)
func configure(_: T, isPrototype: Bool)
}
public extension ConfigurableCell where Self: UITableViewCell {

View File

@ -48,7 +48,7 @@ public class PrototypeHeightStrategy: CellHeightCalculatable {
cell.bounds = CGRectMake(0, 0, tableView?.bounds.size.width ?? 0, cell.bounds.height)
row.configure(cell)
row.configure(cell, isPrototype: true)
cell.setNeedsLayout()
cell.layoutIfNeeded()

View File

@ -118,7 +118,7 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate
cell.layoutIfNeeded()
}
row.configure(cell)
row.configure(cell, isPrototype: false)
return cell
}

View File

@ -22,7 +22,7 @@ import UIKit
public protocol RowConfigurable {
func configure(cell: UITableViewCell)
func configure(cell: UITableViewCell, isPrototype: Bool)
}
public protocol RowActionable {
@ -72,8 +72,8 @@ public class TableRow<ItemType, CellType: ConfigurableCell where CellType.T == I
// MARK: - RowConfigurable -
public func configure(cell: UITableViewCell) {
(cell as? CellType)?.configure(item)
public func configure(cell: UITableViewCell, isPrototype: Bool) {
(cell as? CellType)?.configure(item, isPrototype: isPrototype)
}
// MARK: - RowActionable -