updated more model properties
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
908c3bddc3
commit
8daf1a2b72
@ -21,6 +21,7 @@ import VDS
|
||||
//--------------------------------------------------
|
||||
open func viewModelDidUpdate() {
|
||||
surface = viewModel.surface
|
||||
textAlignment = viewModel.textAlignment
|
||||
eyebrowModel = viewModel.eyebrowModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||
titleModel = viewModel.titleModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||
subTitleModel = viewModel.subTitleModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||
|
||||
@ -19,9 +19,11 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
||||
public var moleculeName: String = TitleLockupModel.identifier
|
||||
public var id: String = UUID().uuidString
|
||||
|
||||
public var textAlignment: TitleLockup.TextAlignment = .left
|
||||
public var eyebrow: LabelModel?
|
||||
public var title: LabelModel
|
||||
public var subTitle: LabelModel?
|
||||
public var subTitleColor: Use = .primary
|
||||
|
||||
public var alignment: VDS.TitleLockup.TextAlignment = .left
|
||||
public var inverted: Bool = false
|
||||
@ -49,9 +51,11 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
case moleculeName
|
||||
case textAlignment
|
||||
case eyebrow
|
||||
case title
|
||||
case subTitle
|
||||
case subTitleColor
|
||||
case inverted
|
||||
case alignment
|
||||
}
|
||||
@ -63,10 +67,12 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||
textAlignment = try typeContainer.decodeIfPresent(TitleLockup.TextAlignment.self, forKey: .textAlignment) ?? .left
|
||||
title = try typeContainer.decode(LabelModel.self, forKey: .title)
|
||||
eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow)
|
||||
subTitle = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .subTitle)
|
||||
|
||||
subTitleColor = try typeContainer.decodeIfPresent(Use.self, forKey: .subTitleColor) ?? .primary
|
||||
|
||||
if let newAlignment = try typeContainer.decodeIfPresent(VDS.TitleLockup.TextAlignment.self, forKey: .alignment) {
|
||||
alignment = newAlignment
|
||||
}
|
||||
@ -80,9 +86,11 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(id, forKey: .id)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encode(textAlignment, forKey: .textAlignment)
|
||||
try container.encodeIfPresent(eyebrow, forKey: .eyebrow)
|
||||
try container.encodeModel(title, forKey: .title)
|
||||
try container.encodeIfPresent(subTitle, forKey: .subTitle)
|
||||
try container.encode(subTitleColor, forKey: .subTitleColor)
|
||||
try container.encode(alignment, forKey: .alignment)
|
||||
try container.encode(inverted, forKey: .inverted)
|
||||
}
|
||||
@ -131,6 +139,7 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
||||
if let style = subTitle.fontStyle {
|
||||
return .init(text: subTitle.text,
|
||||
standardStyle: try style.vdsSubsetStyle(),
|
||||
textColor: subTitleColor,
|
||||
textAttributes: attrs,
|
||||
numberOfLines: subTitle.numberOfLines ?? 0)
|
||||
}
|
||||
@ -138,7 +147,7 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
||||
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
|
||||
} catch { }
|
||||
|
||||
return .init(text: subTitle.text, textAttributes: attrs, numberOfLines: subTitle.numberOfLines ?? 0)
|
||||
return .init(text: subTitle.text, textColor: subTitleColor, textAttributes: attrs, numberOfLines: subTitle.numberOfLines ?? 0)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user