comment fix
This commit is contained in:
parent
4eb4cf9741
commit
f3224b371e
@ -9,22 +9,14 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// A model for a collection item that is a container for any molecule.
|
/// A model for a collection item that is a container for any molecule.
|
||||||
@objcMembers open class MoleculeCollectionItemModel: CollectionItemModelProtocol, ContainerModelProtocol, MoleculeModelProtocol {
|
@objcMembers public class MoleculeCollectionItemModel: MoleculeContainerModel, CollectionItemModelProtocol, MoleculeModelProtocol {
|
||||||
open class var identifier: String {
|
open class var identifier: String {
|
||||||
return "collectionItem"
|
return "collectionItem"
|
||||||
}
|
}
|
||||||
open var molecule: MoleculeModelProtocol
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
|
||||||
public var horizontalAlignment: UIStackView.Alignment?
|
|
||||||
public var verticalAlignment: UIStackView.Alignment?
|
|
||||||
public var useHorizontalMargins: Bool?
|
|
||||||
public var useVerticalMargins: Bool?
|
|
||||||
public var topMarginPadding: CGFloat?
|
|
||||||
public var bottomMarginPadding: CGFloat?
|
|
||||||
|
|
||||||
/// Defaults to set
|
/// Defaults to set
|
||||||
open func setDefaults() {
|
public func setDefaults() {
|
||||||
if useHorizontalMargins == nil {
|
if useHorizontalMargins == nil {
|
||||||
useHorizontalMargins = true
|
useHorizontalMargins = true
|
||||||
}
|
}
|
||||||
@ -41,26 +33,25 @@ import Foundation
|
|||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case molecule
|
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(with moleculeModel: MoleculeModelProtocol) {
|
public override init(with moleculeModel: MoleculeModelProtocol) {
|
||||||
molecule = moleculeModel
|
super.init(with: moleculeModel)
|
||||||
setDefaults()
|
setDefaults()
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
molecule = try typeContainer.decodeModel(codingKey: .molecule)
|
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
|
try super.init(from: decoder)
|
||||||
setDefaults()
|
setDefaults()
|
||||||
}
|
}
|
||||||
|
|
||||||
open func encode(to encoder: Encoder) throws {
|
public override func encode(to encoder: Encoder) throws {
|
||||||
|
try super.encode(to: encoder)
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeModel(molecule, forKey: .molecule)
|
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user