set estimatedHeight and defaultHeight as static properties
This commit is contained in:
parent
f90db7de16
commit
7438856134
|
|
@ -19,13 +19,13 @@ class AutolayoutTableViewCell: UITableViewCell, ConfigurableCell {
|
|||
@IBOutlet var titleLabel: UILabel!
|
||||
@IBOutlet var subtitleLabel: UILabel!
|
||||
|
||||
static var estimatedHeight: CGFloat? {
|
||||
return 500
|
||||
}
|
||||
|
||||
func configure(with string: T) {
|
||||
|
||||
titleLabel.text = LoremIpsumTitle
|
||||
subtitleLabel.text = LoremIpsumBody
|
||||
}
|
||||
|
||||
static func estimatedHeight() -> CGFloat? {
|
||||
return 500
|
||||
}
|
||||
}
|
||||
|
|
@ -13,11 +13,11 @@ class NibTableViewCell: UITableViewCell, ConfigurableCell {
|
|||
|
||||
@IBOutlet weak var titleLabel: UILabel!
|
||||
|
||||
static var defaultHeight: CGFloat? {
|
||||
return 100
|
||||
}
|
||||
|
||||
func configure(with number: Int) {
|
||||
titleLabel.text = "\(number)"
|
||||
}
|
||||
|
||||
static func defaultHeight() -> CGFloat? {
|
||||
return 100
|
||||
}
|
||||
}
|
||||
|
|
@ -21,17 +21,18 @@
|
|||
import UIKit
|
||||
|
||||
public protocol ReusableCell {
|
||||
|
||||
|
||||
static func reusableIdentifier() -> String
|
||||
static func nib() -> UINib?
|
||||
}
|
||||
|
||||
public protocol ConfigurableCell: ReusableCell {
|
||||
|
||||
|
||||
associatedtype T
|
||||
|
||||
static func estimatedHeight() -> CGFloat?
|
||||
static func defaultHeight() -> CGFloat?
|
||||
|
||||
static var estimatedHeight: CGFloat? { get }
|
||||
static var defaultHeight: CGFloat? { get }
|
||||
|
||||
func configure(with _: T)
|
||||
}
|
||||
|
||||
|
|
@ -48,11 +49,16 @@ public extension ReusableCell where Self: UITableViewCell {
|
|||
|
||||
public extension ConfigurableCell where Self: UITableViewCell {
|
||||
|
||||
static func estimatedHeight() -> CGFloat? {
|
||||
return UITableViewAutomaticDimension
|
||||
static var estimatedHeight: CGFloat? {
|
||||
get {
|
||||
return UITableViewAutomaticDimension
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static func defaultHeight() -> CGFloat? {
|
||||
return nil
|
||||
static var defaultHeight: CGFloat? {
|
||||
get {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -59,11 +59,11 @@ public class TableRow<ItemType, CellType: ConfigurableCell where CellType.T == I
|
|||
}
|
||||
|
||||
public var estimatedHeight: CGFloat? {
|
||||
return CellType.estimatedHeight()
|
||||
return CellType.estimatedHeight
|
||||
}
|
||||
|
||||
public var defaultHeight: CGFloat? {
|
||||
return CellType.defaultHeight()
|
||||
return CellType.defaultHeight
|
||||
}
|
||||
|
||||
public var cellType: AnyClass {
|
||||
|
|
|
|||
Loading…
Reference in New Issue