shifting and improving

This commit is contained in:
Kevin G Christiano 2020-03-06 17:06:20 -05:00
parent d3aacadb71
commit 9bce3f02a1
6 changed files with 28 additions and 14 deletions

View File

@ -176,6 +176,9 @@ import UIKit
let backgroundColor = moleculeModel.backgroundColor {
self.backgroundColor = backgroundColor.uiColor
}
// align if needed.
containerHelper.set(with: model, for: molecule as? MVMCoreUIViewConstrainingProtocol)
}
open func reset() {

View File

@ -14,4 +14,9 @@ public struct ImageHeadlineBodyModel: MoleculeModelProtocol {
public var backgroundColor: Color?
public var image: ImageViewModel
public var headlineBody: HeadlineBodyModel
public init(image: ImageViewModel, headlineBody: HeadlineBodyModel) {
self.image = image
self.headlineBody = headlineBody
}
}

View File

@ -109,7 +109,9 @@ import UIKit
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData)
guard let model = model as? TwoButtonViewModel else { return }
if let secondaryModel = model.secondaryButton {
showSecondaryButton()
secondaryButton.set(with: secondaryModel, delegateObject, additionalData)

View File

@ -14,18 +14,18 @@ import UIKit
// MARK: - MVMCoreUIMoleculeViewProtocol
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData)
guard let model = model as? MoleculeListItemModel else { return }
if molecule != nil {
(molecule as? ModelMoleculeViewProtocol)?.set(with: model.molecule, delegateObject, additionalData)
} else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model.molecule, delegateObject, false) {
addMolecule(moleculeView)
guard let castModel = model as? MoleculeListItemModel else {
super.set(with: model, delegateObject, additionalData)
return
}
containerHelper.set(with: model, for: molecule as? MVMCoreUIViewConstrainingProtocol)
if molecule != nil {
(molecule as? ModelMoleculeViewProtocol)?.set(with: castModel.molecule, delegateObject, additionalData)
} else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(castModel.molecule, delegateObject, false) {
addMolecule(moleculeView)
}
super.set(with: model, delegateObject, additionalData)
}
public override class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {

View File

@ -8,7 +8,7 @@
import Foundation
@objcMembers public class HeadlineBodyModel: MoleculeModelProtocol {
@objcMembers open class HeadlineBodyModel: MoleculeModelProtocol {
public static var identifier: String = "headlineBody"
public var moleculeName: String? = HeadlineBodyModel.identifier
public var headline: LabelModel?
@ -19,4 +19,8 @@ import Foundation
public init(headline: LabelModel) {
self.headline = headline
}
public init(body: LabelModel) {
self.body = body
}
}

View File

@ -178,7 +178,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
}
}
public override func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) {
open override func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) {
var tmpMolecules = [ListItemModelProtocol & MoleculeModelProtocol]()
@ -207,7 +207,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
}
}
public override func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) {
open override func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) {
var tmpMolecules = [ListItemModelProtocol & MoleculeModelProtocol]()
@ -235,7 +235,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
view.layoutIfNeeded()
}
public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) {
open func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) {
// This dispatch is needed to fix a race condition that can occur if this function is called during the table setup.
DispatchQueue.main.async {
@ -257,7 +257,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
}
}
public func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) {
open func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) {
var indexPaths: [IndexPath] = []
//TODO: cehck for molecule protocola eqality