fixes
This commit is contained in:
parent
0648ec0191
commit
d00a04831d
@ -11,28 +11,38 @@ import Foundation
|
||||
@objcMembers public class HeadlineBodyModel: MoleculeProtocol {
|
||||
public static var identifier: String = "headlineBody"
|
||||
public var moleculeName: String?
|
||||
public var headline: LabelModel?
|
||||
public var style: String?
|
||||
public var headline: LabelModel
|
||||
public var body: LabelModel
|
||||
|
||||
public init(headline: LabelModel?) {
|
||||
self.headline = headline
|
||||
public init(style: String?, headline: LabelModel, body: LabelModel) {
|
||||
self.moleculeName = Self.identifier
|
||||
self.style = style
|
||||
self.headline = headline
|
||||
self.body = body
|
||||
}
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case style
|
||||
case headline
|
||||
case body
|
||||
}
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName)
|
||||
self.headline = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .headline)
|
||||
self.headline = try typeContainer.decode(LabelModel.self, forKey: .headline)
|
||||
self.body = try typeContainer.decode(LabelModel.self, forKey: .body)
|
||||
self.style = try typeContainer.decodeIfPresent(String.self, forKey: .style)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encodeIfPresent(self.headline, forKey: .headline)
|
||||
try container.encode(headline, forKey: .headline)
|
||||
try container.encode(body, forKey: .body)
|
||||
try container.encodeIfPresent(self.style, forKey: .style)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
open class HeadlineBody: ViewConstrainingView {
|
||||
open class HeadlineBody: ViewConstrainingView, ModelMoleculeViewProtocol {
|
||||
let headlineLabel = Label.commonLabelH2(true)
|
||||
let messageLabel = Label.commonLabelB2(true)
|
||||
var spaceBetweenLabelsConstant = PaddingTwo
|
||||
@ -118,18 +118,31 @@ open class HeadlineBody: ViewConstrainingView {
|
||||
spaceBetweenLabels?.constant = 0
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
|
||||
style(with: json?.optionalStringForKey("style"))
|
||||
|
||||
let headlineJSON = json?.optionalDictionaryForKey("headline")
|
||||
headlineLabel.setWithJSON(headlineJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
let bodyJSON = json?.optionalDictionaryForKey("body")
|
||||
messageLabel.setWithJSON(bodyJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
|
||||
public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
||||
|
||||
setUpWithModel(model, delegateObject, additionalData)
|
||||
guard let headlineBodyModel = model as? HeadlineBodyModel else {
|
||||
return
|
||||
}
|
||||
|
||||
style(with: headlineBodyModel.style)
|
||||
|
||||
headlineLabel.setWithModel(headlineBodyModel.headline, delegateObject, additionalData)
|
||||
messageLabel.setWithModel(headlineBodyModel.body, delegateObject, additionalData)
|
||||
}
|
||||
// // MARK: - MVMCoreUIMoleculeViewProtocol
|
||||
// open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
// super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
//
|
||||
// style(with: json?.optionalStringForKey("style"))
|
||||
//
|
||||
// let headlineJSON = json?.optionalDictionaryForKey("headline")
|
||||
// headlineLabel.setWithJSON(headlineJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
//
|
||||
// let bodyJSON = json?.optionalDictionaryForKey("body")
|
||||
// messageLabel.setWithJSON(bodyJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
// }
|
||||
|
||||
open override func reset() {
|
||||
super.reset()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user