TitleLockup model changes

This commit is contained in:
Sumanth Nadigadda 2022-05-04 01:35:21 +05:30
parent 6125005639
commit 083e52bc19
4 changed files with 95 additions and 92 deletions

View File

@ -145,9 +145,9 @@
32D2609724C19E2100B56344 /* LockupsPlanSMLXLModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32D2609524C19E2100B56344 /* LockupsPlanSMLXLModel.swift */; }; 32D2609724C19E2100B56344 /* LockupsPlanSMLXLModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32D2609524C19E2100B56344 /* LockupsPlanSMLXLModel.swift */; };
32F8804624765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F8804524765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift */; }; 32F8804624765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F8804524765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift */; };
32F8804824765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F8804724765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift */; }; 32F8804824765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F8804724765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift */; };
444FB7C12821B73200DFE692 /* TitleLockup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 444FB7C02821B73200DFE692 /* TitleLockup.swift */; };
444FB7C32821B76B00DFE692 /* TitleLockupModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 444FB7C22821B76B00DFE692 /* TitleLockupModel.swift */; };
4457904E27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4457904D27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift */; }; 4457904E27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4457904D27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift */; };
4461F77A2800AB2D00BA0222 /* EyebrowHeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4461F7792800AB2D00BA0222 /* EyebrowHeadlineBodyModel.swift */; };
4461F77C2800AB6C00BA0222 /* EyebrowHeadlineBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4461F77B2800AB6C00BA0222 /* EyebrowHeadlineBody.swift */; };
522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; }; 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; };
522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */; }; 522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */; };
52267A0723FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */; }; 52267A0723FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */; };
@ -735,9 +735,9 @@
32D2609524C19E2100B56344 /* LockupsPlanSMLXLModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LockupsPlanSMLXLModel.swift; sourceTree = "<group>"; }; 32D2609524C19E2100B56344 /* LockupsPlanSMLXLModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LockupsPlanSMLXLModel.swift; sourceTree = "<group>"; };
32F8804524765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListAllTextAndLinksModel.swift; sourceTree = "<group>"; }; 32F8804524765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListAllTextAndLinksModel.swift; sourceTree = "<group>"; };
32F8804724765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListAllTextAndLinks.swift; sourceTree = "<group>"; }; 32F8804724765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListAllTextAndLinks.swift; sourceTree = "<group>"; };
444FB7C02821B73200DFE692 /* TitleLockup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitleLockup.swift; sourceTree = "<group>"; };
444FB7C22821B76B00DFE692 /* TitleLockupModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitleLockupModel.swift; sourceTree = "<group>"; };
4457904D27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImageRenderingMode+Extension.swift"; sourceTree = "<group>"; }; 4457904D27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImageRenderingMode+Extension.swift"; sourceTree = "<group>"; };
4461F7792800AB2D00BA0222 /* EyebrowHeadlineBodyModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EyebrowHeadlineBodyModel.swift; sourceTree = "<group>"; };
4461F77B2800AB6C00BA0222 /* EyebrowHeadlineBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EyebrowHeadlineBody.swift; sourceTree = "<group>"; };
522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = "<group>"; }; 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = "<group>"; };
522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinksModel.swift; sourceTree = "<group>"; }; 522679C023FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinksModel.swift; sourceTree = "<group>"; };
52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinks.swift; sourceTree = "<group>"; }; 52267A0623FFE25000906CBA /* ListOneColumnFullWidthTextAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinks.swift; sourceTree = "<group>"; };
@ -1435,6 +1435,8 @@
525019DC2406430800EED91C /* ListProgressBarData.swift */, 525019DC2406430800EED91C /* ListProgressBarData.swift */,
AA45AA0A24BF0263007A6EA7 /* LockUpsPlanNamesModel.swift */, AA45AA0A24BF0263007A6EA7 /* LockUpsPlanNamesModel.swift */,
AA45AA0C24BF0276007A6EA7 /* LockUpsPlanNames.swift */, AA45AA0C24BF0276007A6EA7 /* LockUpsPlanNames.swift */,
444FB7C22821B76B00DFE692 /* TitleLockupModel.swift */,
444FB7C02821B73200DFE692 /* TitleLockup.swift */,
); );
path = LockUps; path = LockUps;
sourceTree = "<group>"; sourceTree = "<group>";
@ -1641,8 +1643,6 @@
EA5124FC243601600051A3A4 /* BGImageHeadlineBodyButton.swift */, EA5124FC243601600051A3A4 /* BGImageHeadlineBodyButton.swift */,
0A775F2524893916009EFB58 /* ThreeHeadlineBodyLink.swift */, 0A775F2524893916009EFB58 /* ThreeHeadlineBodyLink.swift */,
0A775F2724893937009EFB58 /* ThreeHeadlineBodyLinkModel.swift */, 0A775F2724893937009EFB58 /* ThreeHeadlineBodyLinkModel.swift */,
4461F7792800AB2D00BA0222 /* EyebrowHeadlineBodyModel.swift */,
4461F77B2800AB6C00BA0222 /* EyebrowHeadlineBody.swift */,
); );
path = VerticalCombinationViews; path = VerticalCombinationViews;
sourceTree = "<group>"; sourceTree = "<group>";
@ -2669,6 +2669,7 @@
0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */,
3265B30424BCA749000D154B /* HeadersH1NoButtonsBodyText.swift in Sources */, 3265B30424BCA749000D154B /* HeadersH1NoButtonsBodyText.swift in Sources */,
AAA7CD69250641F90045B959 /* HeartModel.swift in Sources */, AAA7CD69250641F90045B959 /* HeartModel.swift in Sources */,
444FB7C12821B73200DFE692 /* TitleLockup.swift in Sources */,
D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */, D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */,
D28BA7452481652D00B75CB8 /* TabBarProtocol.swift in Sources */, D28BA7452481652D00B75CB8 /* TabBarProtocol.swift in Sources */,
AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */, AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */,
@ -2737,7 +2738,6 @@
D260106323D0C05000764D80 /* StackItemModel.swift in Sources */, D260106323D0C05000764D80 /* StackItemModel.swift in Sources */,
D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */, D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */,
D28764AC245898A400CB882D /* ThreeLayerFillMiddleTemplateModel.swift in Sources */, D28764AC245898A400CB882D /* ThreeLayerFillMiddleTemplateModel.swift in Sources */,
4461F77A2800AB2D00BA0222 /* EyebrowHeadlineBodyModel.swift in Sources */,
BBBBC87D24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift in Sources */, BBBBC87D24374A4900B0F079 /* ListThreeColumnBillChangesDividerModel.swift in Sources */,
D2ED2800254B0E0300A1C293 /* MVMCoreAlertHandler+Extension.swift in Sources */, D2ED2800254B0E0300A1C293 /* MVMCoreAlertHandler+Extension.swift in Sources */,
D2ED27EE254B0CE700A1C293 /* ActionAlertModel.swift in Sources */, D2ED27EE254B0CE700A1C293 /* ActionAlertModel.swift in Sources */,
@ -2863,6 +2863,7 @@
525019E52406852100EED91C /* ListFourColumnDataUsageDividerModel.swift in Sources */, 525019E52406852100EED91C /* ListFourColumnDataUsageDividerModel.swift in Sources */,
32D2609624C19E2100B56344 /* LockupsPlanSMLXL.swift in Sources */, 32D2609624C19E2100B56344 /* LockupsPlanSMLXL.swift in Sources */,
0A7EF86723D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift in Sources */, 0A7EF86723D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift in Sources */,
444FB7C32821B76B00DFE692 /* TitleLockupModel.swift in Sources */,
D29C94D5242901C9003813BA /* MVMCoreUICommonViewsUtility+Extension.swift in Sources */, D29C94D5242901C9003813BA /* MVMCoreUICommonViewsUtility+Extension.swift in Sources */,
D260105323CEA61600764D80 /* ToggleModel.swift in Sources */, D260105323CEA61600764D80 /* ToggleModel.swift in Sources */,
014AA72523C501E2006F3E93 /* ContainerModel.swift in Sources */, 014AA72523C501E2006F3E93 /* ContainerModel.swift in Sources */,
@ -2930,7 +2931,6 @@
32F8804624765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift in Sources */, 32F8804624765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift in Sources */,
011D958524042432000E3791 /* RulesProtocol.swift in Sources */, 011D958524042432000E3791 /* RulesProtocol.swift in Sources */,
4457904E27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift in Sources */, 4457904E27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift in Sources */,
4461F77C2800AB6C00BA0222 /* EyebrowHeadlineBody.swift in Sources */,
D23118B325124E18001C8440 /* Notification.swift in Sources */, D23118B325124E18001C8440 /* Notification.swift in Sources */,
AA9972502475309F00FC7472 /* ListLeftVariableIconAllTextLinksModel.swift in Sources */, AA9972502475309F00FC7472 /* ListLeftVariableIconAllTextLinksModel.swift in Sources */,
AA69AAF62445BF5700AF3D3B /* ListLeftVariableCheckboxBodyText.swift in Sources */, AA69AAF62445BF5700AF3D3B /* ListLeftVariableCheckboxBodyText.swift in Sources */,

View File

@ -1,28 +1,28 @@
// //
// EyebrowHeadlineBody.swift // TitleLockup.swift
// MVMCoreUI // MVMCoreUI
// //
// Created by Nadigadda, Sumanth on 08/04/22. // Created by Nadigadda, Sumanth on 04/05/22.
// Copyright © 2022 Verizon Wireless. All rights reserved. // Copyright © 2022 Verizon Wireless. All rights reserved.
// //
@objcMembers open class EyebrowHeadlineBody: View { @objcMembers open class TitleLockup: View {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Outlets // MARK: - Outlets
//-------------------------------------------------- //--------------------------------------------------
public let eyebrow = Label(fontStyle: .RegularBodySmall) public let eyebrow = Label(fontStyle: .RegularBodySmall)
public let headline = Label(fontStyle: .RegularBodySmall) public let title = Label(fontStyle: .RegularBodySmall)
public let body = Label(fontStyle: .RegularBodySmall) public let subTitle = Label(fontStyle: .RegularBodySmall)
public lazy var stack: Stack<StackModel> = { public lazy var stack: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [(view: eyebrow, model: StackItemModel(horizontalAlignment: .fill)), return Stack<StackModel>.createStack(with: [(view: eyebrow, model: StackItemModel(horizontalAlignment: .fill)),
(view: headline, model: StackItemModel(horizontalAlignment: .fill)), (view: title, model: StackItemModel(horizontalAlignment: .fill)),
(view: body, model: StackItemModel(horizontalAlignment: .fill))], (view: subTitle, model: StackItemModel(horizontalAlignment: .fill))],
axis: .vertical) axis: .vertical)
}() }()
var castModel: EyebrowHeadlineBodyModel? { var castModel: TitleLockupModel? {
get { return model as? EyebrowHeadlineBodyModel } get { return model as? TitleLockupModel }
} }
//-------------------------------------------------- //--------------------------------------------------
@ -31,7 +31,6 @@
public convenience init() { public convenience init() {
self.init(frame: .zero) self.init(frame: .zero)
stack.restack()
} }
//-------------------------------------------------- //--------------------------------------------------
@ -47,7 +46,7 @@
open override func updateView(_ size: CGFloat) { open override func updateView(_ size: CGFloat) {
super.updateView(size) super.updateView(size)
stack.stackModel?.spacing = castModel?.style.defaultSpacing() ?? EyebrowHeadlineBodyModel.Style.large.defaultSpacing() stack.stackModel?.spacing = castModel?.style.defaultSpacing() ?? TitleLockupModel.Style.large.defaultSpacing()
stack.updateView(size) stack.updateView(size)
} }
@ -66,24 +65,11 @@
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData) super.set(with: model, delegateObject, additionalData)
guard let model = model as? EyebrowHeadlineBodyModel else { return } guard let model = model as? TitleLockupModel else { return }
setStyle(style: model.style)
///Updating the text color
model.eyebrow?.textColor = model.headlineColor
model.headline.textColor = model.headlineColor
model.body?.textColor = model.bodyColor
if let textAlignment = NSTextAlignment(rawValue: model.alignment.rawValue) {
model.eyebrow?.textAlignment = textAlignment
model.headline.textAlignment = textAlignment
model.body?.textAlignment = textAlignment
}
stack.updateContainedMolecules(with: [model.eyebrow, stack.updateContainedMolecules(with: [model.eyebrow,
model.headline, model.title,
model.body], model.subTitle],
delegateObject, additionalData) delegateObject, additionalData)
} }
@ -91,29 +77,6 @@
return 65 return 65
} }
//--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------
public func setStyle(style: EyebrowHeadlineBodyModel.Style? = .large) {
///If eyebrow style is not available, will set font style based on the component
///Eyebrow and body share the same font size
if castModel?.eyebrow?.fontStyle == nil {
castModel?.eyebrow?.fontStyle = style?.defaultBodyFontStyle()
}
///If headline style is not available, will set font style based on the component
if castModel?.headline.fontStyle == nil {
castModel?.headline.fontStyle = style?.defaultHeadlineFontStyle()
}
///If body style is not available, will set font style based on the component
if castModel?.body?.fontStyle == nil {
castModel?.body?.fontStyle = style?.defaultBodyFontStyle()
}
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Accessibility Helpers // MARK: - Accessibility Helpers
//-------------------------------------------------- //--------------------------------------------------
@ -127,11 +90,11 @@
message += eyebrowLabel + ", " message += eyebrowLabel + ", "
} }
if let headlineLabel = headline.text { if let headlineLabel = title.text {
message += headlineLabel + ", " message += headlineLabel + ", "
} }
if let bodyLabel = body.text { if let bodyLabel = subTitle.text {
message += bodyLabel message += bodyLabel
} }
@ -147,14 +110,15 @@
elements.append(eyebrow) elements.append(eyebrow)
} }
if headline.hasText { if title.hasText {
elements.append(headline) elements.append(title)
} }
if body.hasText { if subTitle.hasText {
elements.append(body) elements.append(subTitle)
} }
return elements.count > 0 ? elements : nil return elements.count > 0 ? elements : nil
} }
} }

View File

@ -1,25 +1,25 @@
// //
// EyebrowHeadlineBodyModel.swift // TitleLockupModel.swift
// MVMCoreUI // MVMCoreUI
// //
// Created by Nadigadda, Sumanth on 08/04/22. // Created by Nadigadda, Sumanth on 04/05/22.
// Copyright © 2022 Verizon Wireless. All rights reserved. // Copyright © 2022 Verizon Wireless. All rights reserved.
// //
import VDSColorTokens import VDSColorTokens
public class EyebrowHeadlineBodyModel: MoleculeModelProtocol, ParentMoleculeModelProtocol { public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
public static var identifier: String = "eyebrowHeadlineBody" public static var identifier: String = "titleLockup"
public var moleculeName: String = EyebrowHeadlineBodyModel.identifier public var moleculeName: String = TitleLockupModel.identifier
public var eyebrow: LabelModel? public var eyebrow: LabelModel?
public var headline: LabelModel public var title: LabelModel
public var body: LabelModel? public var subTitle: LabelModel?
public var style: Style = .large public var style: Style = .large
public var alignment: Alignment = .left public var alignment: Alignment = .left
@ -35,27 +35,27 @@ public class EyebrowHeadlineBodyModel: MoleculeModelProtocol, ParentMoleculeMode
} }
} }
public var headlineColor: Color? { public var titleColor: Color? {
return inverted ? Color(uiColor: VDSColor.elementsPrimaryOndark) : Color(uiColor: VDSColor.elementsPrimaryOnlight) return inverted ? Color(uiColor: VDSColor.elementsPrimaryOndark) : Color(uiColor: VDSColor.elementsPrimaryOnlight)
} }
public var bodyColor: Color? { public var subTitleColor: Color? {
return inverted ? Color(uiColor: VDSColor.elementsSecondaryOndark) : Color(uiColor: VDSColor.elementsSecondaryOnlight) return inverted ? Color(uiColor: VDSColor.elementsSecondaryOndark) : Color(uiColor: VDSColor.elementsSecondaryOnlight)
} }
public var children: [MoleculeModelProtocol] { public var children: [MoleculeModelProtocol] {
[eyebrow, headline, body].compactMap { (molecule: MoleculeModelProtocol?) in molecule } [eyebrow, title, subTitle].compactMap { (molecule: MoleculeModelProtocol?) in molecule }
} }
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Initializer // MARK: - Initializer
//-------------------------------------------------- //--------------------------------------------------
public init(eyebrow: LabelModel? = nil, headline: LabelModel, body: LabelModel? = nil) throws { public init(eyebrow: LabelModel? = nil, title: LabelModel, subTitle: LabelModel? = nil) throws {
self.eyebrow = eyebrow self.eyebrow = eyebrow
self.headline = headline self.title = title
self.body = body self.subTitle = subTitle
} }
//-------------------------------------------------- //--------------------------------------------------
@ -122,8 +122,8 @@ public class EyebrowHeadlineBodyModel: MoleculeModelProtocol, ParentMoleculeMode
case moleculeName case moleculeName
case backgroundColor case backgroundColor
case eyebrow case eyebrow
case headline case title
case body case subTitle
case inverted case inverted
case alignment case alignment
case style case style
@ -136,32 +136,71 @@ public class EyebrowHeadlineBodyModel: MoleculeModelProtocol, ParentMoleculeMode
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)
eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow) eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow)
headline = try typeContainer.decodeMolecule(codingKey: .headline) title = try typeContainer.decodeMolecule(codingKey: .title)
body = try typeContainer.decodeMoleculeIfPresent(codingKey: .body) subTitle = try typeContainer.decodeMoleculeIfPresent(codingKey: .subTitle)
if let style = try typeContainer.decodeIfPresent(Style.self, forKey: .style) { if let newStyle = try typeContainer.decodeIfPresent(Style.self, forKey: .style) {
self.style = style style = newStyle
setStyle(style: newStyle)
} }
if let alignment = try typeContainer.decodeIfPresent(Alignment.self, forKey: .alignment) { if let newAlignment = try typeContainer.decodeIfPresent(Alignment.self, forKey: .alignment) {
self.alignment = alignment alignment = newAlignment
} }
if let inverted = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) { if let invertedStatus = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) {
self.inverted = inverted inverted = invertedStatus
} }
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
updateLabelAttributes()
} }
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
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.encodeIfPresent(eyebrow, forKey: .eyebrow) try container.encodeIfPresent(eyebrow, forKey: .eyebrow)
try container.encodeModelIfPresent(headline, forKey: .headline) try container.encodeModel(title, forKey: .title)
try container.encodeIfPresent(body, forKey: .body) try container.encodeIfPresent(subTitle, forKey: .subTitle)
try container.encodeIfPresent(style, forKey: .style) try container.encodeIfPresent(style, forKey: .style)
try container.encode(alignment, forKey: .alignment) try container.encode(alignment, forKey: .alignment)
try container.encode(inverted, forKey: .inverted) try container.encode(inverted, forKey: .inverted)
try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor)
} }
//--------------------------------------------------
// MARK: - Model updates
//--------------------------------------------------
private func setStyle(style: Style) {
///If eyebrow style is not available, will set font style based on the component
///Eyebrow and body share the same font size
if eyebrow?.fontStyle == nil {
eyebrow?.fontStyle = style.defaultBodyFontStyle()
}
///If title style is not available, will set font style based on the component
if title.fontStyle == nil {
title.fontStyle = style.defaultHeadlineFontStyle()
}
///If subtitle style is not available, will set font style based on the component
if subTitle?.fontStyle == nil {
subTitle?.fontStyle = style.defaultBodyFontStyle()
}
}
private func updateLabelAttributes() {
///Updating the text color
eyebrow?.textColor = titleColor
title.textColor = titleColor
subTitle?.textColor = subTitleColor
///Updating the text alignment for all labels
if let textAlignment = NSTextAlignment(rawValue: alignment.rawValue) {
eyebrow?.textAlignment = textAlignment
title.textAlignment = textAlignment
subTitle?.textAlignment = textAlignment
}
}
} }

View File

@ -87,7 +87,6 @@ open class CoreUIModelMapping: ModelMapping {
ModelRegistry.register(handler: BGImageHeadlineBodyButton.self, for: BGImageHeadlineBodyButtonModel.self) ModelRegistry.register(handler: BGImageHeadlineBodyButton.self, for: BGImageHeadlineBodyButtonModel.self)
ModelRegistry.register(handler: ThreeHeadlineBodyLink.self, for: ThreeHeadlineBodyLinkModel.self) ModelRegistry.register(handler: ThreeHeadlineBodyLink.self, for: ThreeHeadlineBodyLinkModel.self)
ModelRegistry.register(handler: ImageButton.self, for: ImageButtonModel.self) ModelRegistry.register(handler: ImageButton.self, for: ImageButtonModel.self)
ModelRegistry.register(handler: EyebrowHeadlineBody.self, for: EyebrowHeadlineBodyModel.self)
// MARK:- Left Right Molecules // MARK:- Left Right Molecules
ModelRegistry.register(handler: CornerLabels.self, for: CornerLabelsModel.self) ModelRegistry.register(handler: CornerLabels.self, for: CornerLabelsModel.self)
@ -205,6 +204,7 @@ open class CoreUIModelMapping: ModelMapping {
// MARK:- LockUps // MARK:- LockUps
ModelRegistry.register(handler: LockUpsPlanNames.self, for: LockUpsPlanNamesModel.self) ModelRegistry.register(handler: LockUpsPlanNames.self, for: LockUpsPlanNamesModel.self)
ModelRegistry.register(handler: LockupsPlanSMLXL.self, for: LockupsPlanSMLXLModel.self) ModelRegistry.register(handler: LockupsPlanSMLXL.self, for: LockupsPlanSMLXLModel.self)
ModelRegistry.register(handler: TitleLockup.self, for: TitleLockupModel.self)
// MARK: - Top Notifications // MARK: - Top Notifications
ModelRegistry.register(handler: NotificationView.self, for: NotificationModel.self) ModelRegistry.register(handler: NotificationView.self, for: NotificationModel.self)