comment fix
This commit is contained in:
parent
4eb4cf9741
commit
f3224b371e
@ -9,22 +9,14 @@
|
||||
import Foundation
|
||||
|
||||
/// 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 {
|
||||
return "collectionItem"
|
||||
}
|
||||
open var molecule: MoleculeModelProtocol
|
||||
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
|
||||
open func setDefaults() {
|
||||
public func setDefaults() {
|
||||
if useHorizontalMargins == nil {
|
||||
useHorizontalMargins = true
|
||||
}
|
||||
@ -41,26 +33,25 @@ import Foundation
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case molecule
|
||||
case backgroundColor
|
||||
}
|
||||
|
||||
public init(with moleculeModel: MoleculeModelProtocol) {
|
||||
molecule = moleculeModel
|
||||
public override init(with moleculeModel: MoleculeModelProtocol) {
|
||||
super.init(with: moleculeModel)
|
||||
setDefaults()
|
||||
}
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
molecule = try typeContainer.decodeModel(codingKey: .molecule)
|
||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
try super.init(from: decoder)
|
||||
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)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encodeModel(molecule, forKey: .molecule)
|
||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user