updated cell
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
6ce40e1a39
commit
cfecae528b
@ -9,8 +9,8 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
open class CollectionViewCell<ModelType: Modelable>: UICollectionViewCell, ModelHandlerable, ViewProtocol, Resettable {
|
open class CollectionViewCell<ModelHandlerType: ModelHandlerable & UIView>: UICollectionViewCell, ModelHandlerable, ViewProtocol, Resettable {
|
||||||
|
public typealias ModelType = ModelHandlerType.ModelType
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Combine Properties
|
// MARK: - Combine Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -23,6 +23,8 @@ open class CollectionViewCell<ModelType: Modelable>: UICollectionViewCell, Model
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private var initialSetupPerformed = false
|
private var initialSetupPerformed = false
|
||||||
|
|
||||||
|
public var modelHandler: ModelHandlerType = ModelHandlerType()
|
||||||
|
|
||||||
@Proxy(\.model.surface)
|
@Proxy(\.model.surface)
|
||||||
open var surface: Surface
|
open var surface: Surface
|
||||||
|
|
||||||
@ -85,11 +87,11 @@ open class CollectionViewCell<ModelType: Modelable>: UICollectionViewCell, Model
|
|||||||
// MARK: - Overrides
|
// MARK: - Overrides
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
open func shouldUpdateView(viewModel: ModelType) -> Bool {
|
open func shouldUpdateView(viewModel: ModelType) -> Bool {
|
||||||
fatalError("Implement shouldUpdateView")
|
return modelHandler.shouldUpdateView(viewModel: viewModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
open func updateView(viewModel: ModelType) {
|
open func updateView(viewModel: ModelType) {
|
||||||
fatalError("Implement updateView")
|
modelHandler.updateView(viewModel: viewModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
open func reset() {
|
open func reset() {
|
||||||
@ -99,10 +101,22 @@ open class CollectionViewCell<ModelType: Modelable>: UICollectionViewCell, Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func set(with model: ModelType) {
|
||||||
|
self.model = model
|
||||||
|
modelHandler.set(with: model)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - ViewProtocol
|
// MARK: - ViewProtocol
|
||||||
/// Will be called only once.
|
/// Will be called only once.
|
||||||
open func setup() {
|
open func setup() {
|
||||||
translatesAutoresizingMaskIntoConstraints = false
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
insetsLayoutMarginsFromSafeArea = false
|
insetsLayoutMarginsFromSafeArea = false
|
||||||
|
|
||||||
|
addSubview(modelHandler)
|
||||||
|
|
||||||
|
modelHandler.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
||||||
|
modelHandler.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
|
||||||
|
modelHandler.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
|
||||||
|
modelHandler.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user