Changes to get grid wall working

This commit is contained in:
Scott Pfeil 2022-09-21 16:05:46 -04:00
parent 1ea70f3b97
commit 2a7cff7e03
4 changed files with 15 additions and 9 deletions

View File

@ -16,6 +16,7 @@
open override class var identifier: String { "collectionItem" } open override class var identifier: String { "collectionItem" }
public var action: ActionModelProtocol? public var action: ActionModelProtocol?
public var border = false
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Keys // MARK: - Keys
@ -23,6 +24,7 @@
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case action case action
case border
} }
//-------------------------------------------------- //--------------------------------------------------
@ -59,12 +61,16 @@
required public init(from decoder: Decoder) throws { required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self) let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
action = try typeContainer.decodeModelIfPresent(codingKey: .action) action = try typeContainer.decodeModelIfPresent(codingKey: .action)
if let border = try typeContainer.decodeIfPresent(Bool.self, forKey: .border) {
self.border = border
}
try super.init(from: decoder) try super.init(from: decoder)
} }
public override func encode(to encoder: Encoder) throws { public override func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeModelIfPresent(action, forKey: .action) try container.encodeModelIfPresent(action, forKey: .action)
try container.encodeIfPresent(border, forKey: .border)
try super.encode(to: encoder) try super.encode(to: encoder)
} }
} }

View File

@ -15,6 +15,13 @@ open class MoleculeCollectionViewCell: CollectionViewCell {
super.set(with: model, delegateObject, additionalData) super.set(with: model, delegateObject, additionalData)
guard let collectionModel = model as? MoleculeCollectionItemModel else { return } guard let collectionModel = model as? MoleculeCollectionItemModel else { return }
if collectionModel.border {
contentView.layer.borderColor = UIColor.black.cgColor
contentView.layer.borderWidth = 1
} else {
contentView.layer.borderWidth = 0
}
if molecule == nil { if molecule == nil {
if let moleculeView = ModelRegistry.createMolecule(collectionModel.molecule, delegateObject: delegateObject, additionalData: additionalData) { if let moleculeView = ModelRegistry.createMolecule(collectionModel.molecule, delegateObject: delegateObject, additionalData: additionalData) {
addMolecule(moleculeView) addMolecule(moleculeView)

View File

@ -100,7 +100,7 @@
let columns = templateModel?.columns, columns > 0, let columns = templateModel?.columns, columns > 0,
let cell = cell as? CollectionTemplateItemProtocol { let cell = cell as? CollectionTemplateItemProtocol {
let width = (size - collectionView.adjustedContentInset.left - collectionView.adjustedContentInset.right) / CGFloat(columns) let width = (size - collectionView.adjustedContentInset.left - collectionView.adjustedContentInset.right) / CGFloat(columns)
cell.set(width: width - 0.6) cell.set(width: width - 0.1)
} }
} }
@ -141,14 +141,6 @@
(cell as? CollectionTemplateItemProtocol)?.willDisplay() (cell as? CollectionTemplateItemProtocol)?.willDisplay()
} }
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 1
}
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 1
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Convenience // MARK: - Convenience
//-------------------------------------------------- //--------------------------------------------------

View File

@ -19,6 +19,7 @@ public extension MVMCoreUIViewControllerMappingObject {
add(toTemplateViewControllerMapping: ["modalStack": MVMCoreViewControllerProgrammaticMappingObject(with: ModalMoleculeStackTemplate.self)!]) add(toTemplateViewControllerMapping: ["modalStack": MVMCoreViewControllerProgrammaticMappingObject(with: ModalMoleculeStackTemplate.self)!])
register(template: MoleculeListTemplate.self) register(template: MoleculeListTemplate.self)
register(template: CollectionTemplate.self)
add(toTemplateViewControllerMapping: ["modalList": MVMCoreViewControllerProgrammaticMappingObject(with: ModalMoleculeListTemplate.self)!]) add(toTemplateViewControllerMapping: ["modalList": MVMCoreViewControllerProgrammaticMappingObject(with: ModalMoleculeListTemplate.self)!])
add(toTemplateViewControllerMapping: [SectionListTemplateModel.identifier: MVMCoreViewControllerProgrammaticMappingObject(with: SectionListTemplate.self)!]) add(toTemplateViewControllerMapping: [SectionListTemplateModel.identifier: MVMCoreViewControllerProgrammaticMappingObject(with: SectionListTemplate.self)!])
add(toTemplateViewControllerMapping: [ModalSectionListTemplateModel.identifier: MVMCoreViewControllerProgrammaticMappingObject(with: ModalSectionListTemplate.self)!]) add(toTemplateViewControllerMapping: [ModalSectionListTemplateModel.identifier: MVMCoreViewControllerProgrammaticMappingObject(with: ModalSectionListTemplate.self)!])