Merge branch 'feature/lockups_plan_SMLXL' into 'develop'
Feature/lockups plan smlxl See merge request BPHV_MIPS/mvm_core_ui!539
This commit is contained in:
commit
f9ce6e9f0f
@ -126,6 +126,8 @@
|
|||||||
324FB6AC24936717002552C7 /* ListLeftVariableNumberedListBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 324FB6AB24936717002552C7 /* ListLeftVariableNumberedListBodyText.swift */; };
|
324FB6AC24936717002552C7 /* ListLeftVariableNumberedListBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 324FB6AB24936717002552C7 /* ListLeftVariableNumberedListBodyText.swift */; };
|
||||||
3265B30224BCA737000D154B /* HeadersH1NoButtonsBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3265B30124BCA737000D154B /* HeadersH1NoButtonsBodyTextModel.swift */; };
|
3265B30224BCA737000D154B /* HeadersH1NoButtonsBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3265B30124BCA737000D154B /* HeadersH1NoButtonsBodyTextModel.swift */; };
|
||||||
3265B30424BCA749000D154B /* HeadersH1NoButtonsBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3265B30324BCA749000D154B /* HeadersH1NoButtonsBodyText.swift */; };
|
3265B30424BCA749000D154B /* HeadersH1NoButtonsBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3265B30324BCA749000D154B /* HeadersH1NoButtonsBodyText.swift */; };
|
||||||
|
32D2609624C19E2100B56344 /* LockupsPlanSMLXL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32D2609424C19E2100B56344 /* LockupsPlanSMLXL.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 */; };
|
||||||
522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; };
|
522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; };
|
||||||
@ -595,6 +597,8 @@
|
|||||||
324FB6AB24936717002552C7 /* ListLeftVariableNumberedListBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListBodyText.swift; sourceTree = "<group>"; };
|
324FB6AB24936717002552C7 /* ListLeftVariableNumberedListBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListBodyText.swift; sourceTree = "<group>"; };
|
||||||
3265B30124BCA737000D154B /* HeadersH1NoButtonsBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH1NoButtonsBodyTextModel.swift; sourceTree = "<group>"; };
|
3265B30124BCA737000D154B /* HeadersH1NoButtonsBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH1NoButtonsBodyTextModel.swift; sourceTree = "<group>"; };
|
||||||
3265B30324BCA749000D154B /* HeadersH1NoButtonsBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH1NoButtonsBodyText.swift; sourceTree = "<group>"; };
|
3265B30324BCA749000D154B /* HeadersH1NoButtonsBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH1NoButtonsBodyText.swift; sourceTree = "<group>"; };
|
||||||
|
32D2609424C19E2100B56344 /* LockupsPlanSMLXL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LockupsPlanSMLXL.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>"; };
|
||||||
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>"; };
|
||||||
@ -1110,6 +1114,8 @@
|
|||||||
525239C32407FFCC00454969 /* LockUps */ = {
|
525239C32407FFCC00454969 /* LockUps */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
32D2609524C19E2100B56344 /* LockupsPlanSMLXLModel.swift */,
|
||||||
|
32D2609424C19E2100B56344 /* LockupsPlanSMLXL.swift */,
|
||||||
525019DB2406430700EED91C /* ListProgressBarDataModel.swift */,
|
525019DB2406430700EED91C /* ListProgressBarDataModel.swift */,
|
||||||
525019DC2406430800EED91C /* ListProgressBarData.swift */,
|
525019DC2406430800EED91C /* ListProgressBarData.swift */,
|
||||||
AA45AA0A24BF0263007A6EA7 /* LockUpsPlanNamesModel.swift */,
|
AA45AA0A24BF0263007A6EA7 /* LockUpsPlanNamesModel.swift */,
|
||||||
@ -2216,6 +2222,7 @@
|
|||||||
D2E2A98323D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift in Sources */,
|
D2E2A98323D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift in Sources */,
|
||||||
012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */,
|
012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */,
|
||||||
BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */,
|
BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */,
|
||||||
|
32D2609724C19E2100B56344 /* LockupsPlanSMLXLModel.swift in Sources */,
|
||||||
D2092351244F7BE80044AD09 /* ThreeLayerCenterTemplateModel.swift in Sources */,
|
D2092351244F7BE80044AD09 /* ThreeLayerCenterTemplateModel.swift in Sources */,
|
||||||
D21B7F77243BB70700051ABF /* MoleculeCollectionItemModel.swift in Sources */,
|
D21B7F77243BB70700051ABF /* MoleculeCollectionItemModel.swift in Sources */,
|
||||||
AAB9C10A243496DD00151545 /* RadioSwatch.swift in Sources */,
|
AAB9C10A243496DD00151545 /* RadioSwatch.swift in Sources */,
|
||||||
@ -2324,6 +2331,7 @@
|
|||||||
D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */,
|
D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */,
|
||||||
D209234F244F77FD0044AD09 /* ThreeLayerCenterTemplate.swift in Sources */,
|
D209234F244F77FD0044AD09 /* ThreeLayerCenterTemplate.swift in Sources */,
|
||||||
525019E52406852100EED91C /* ListFourColumnDataUsageDividerModel.swift in Sources */,
|
525019E52406852100EED91C /* ListFourColumnDataUsageDividerModel.swift in Sources */,
|
||||||
|
32D2609624C19E2100B56344 /* LockupsPlanSMLXL.swift in Sources */,
|
||||||
0A7EF86723D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift in Sources */,
|
0A7EF86723D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.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 */,
|
||||||
|
|||||||
@ -127,6 +127,7 @@ import Foundation
|
|||||||
MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyToggle.self, viewModelClass: HeadlineBodyToggleModel.self)
|
MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyToggle.self, viewModelClass: HeadlineBodyToggleModel.self)
|
||||||
MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self)
|
MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self)
|
||||||
MoleculeObjectMapping.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self)
|
MoleculeObjectMapping.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self)
|
||||||
|
MoleculeObjectMapping.shared()?.register(viewClass: LockupsPlanSMLXL.self, viewModelClass: LockupsPlanSMLXLModel.self)
|
||||||
|
|
||||||
// MARK:- List items
|
// MARK:- List items
|
||||||
MoleculeObjectMapping.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.self)
|
MoleculeObjectMapping.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.self)
|
||||||
@ -225,6 +226,7 @@ import Foundation
|
|||||||
|
|
||||||
// MARK:- LockUps
|
// MARK:- LockUps
|
||||||
MoleculeObjectMapping.shared()?.register(viewClass: LockUpsPlanNames.self, viewModelClass: LockUpsPlanNamesModel.self)
|
MoleculeObjectMapping.shared()?.register(viewClass: LockUpsPlanNames.self, viewModelClass: LockUpsPlanNamesModel.self)
|
||||||
|
MoleculeObjectMapping.shared()?.register(viewClass: LockupsPlanSMLXL.self, viewModelClass: LockupsPlanSMLXLModel.self)
|
||||||
|
|
||||||
// MARK:- Helper models
|
// MARK:- Helper models
|
||||||
try? ModelRegistry.register(RuleRequiredModel.self)
|
try? ModelRegistry.register(RuleRequiredModel.self)
|
||||||
|
|||||||
@ -0,0 +1,137 @@
|
|||||||
|
//
|
||||||
|
// LockupsPlanSMLXL.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Subhankar Acharya on 15/07/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
@objcMembers open class LockupsPlanSMLXL: View {
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Outlets
|
||||||
|
//--------------------------------------------------
|
||||||
|
public let planLabel = Label()
|
||||||
|
public let headline = Label(fontStyle: .BoldTitleLarge)
|
||||||
|
public let subHeadline = Label(fontStyle: .RegularTitleLarge)
|
||||||
|
public let body = Label(fontStyle: .RegularBodySmall)
|
||||||
|
public let verticalStack: Stack<StackModel>
|
||||||
|
public var stack: Stack<StackModel>
|
||||||
|
|
||||||
|
//-------------------------------------------------------
|
||||||
|
// MARK: - Initializers
|
||||||
|
//-------------------------------------------------------
|
||||||
|
public override init(frame: CGRect) {
|
||||||
|
verticalStack = Stack<StackModel>.createStack(with: [(view: headline, model: StackItemModel()),
|
||||||
|
(view: subHeadline, model: StackItemModel()),
|
||||||
|
(view: body, model: StackItemModel(horizontalAlignment: .fill))],
|
||||||
|
axis: .vertical, spacing: 0)
|
||||||
|
stack = Stack<StackModel>.createStack(with: [(view: planLabel, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading)),
|
||||||
|
(view: verticalStack, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading))],
|
||||||
|
axis: .horizontal)
|
||||||
|
super.init(frame: frame)
|
||||||
|
}
|
||||||
|
|
||||||
|
public required init?(coder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------
|
||||||
|
// MARK: - Lifecycle
|
||||||
|
//-------------------------------------------------------
|
||||||
|
open override func setupView() {
|
||||||
|
super.setupView()
|
||||||
|
planLabel.font = MFStyler.getMVA3FontSize(96, bold: true)
|
||||||
|
planLabel.standardFontSize = 96
|
||||||
|
addSubview(stack)
|
||||||
|
planLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
|
||||||
|
planLabel.setContentHuggingPriority(.defaultHigh, for: .vertical)
|
||||||
|
planLabel.setContentHuggingPriority(.defaultHigh, for: .horizontal)
|
||||||
|
NSLayoutConstraint.constraintPinSubview(toSuperview: stack)
|
||||||
|
stack.restack()
|
||||||
|
verticalStack.restack()
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func updateView(_ size: CGFloat) {
|
||||||
|
super.updateView(size)
|
||||||
|
stack.updateView(size)
|
||||||
|
cropPlanLabel()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Ensures the label is the size of capital letters.
|
||||||
|
public func cropPlanLabel() {
|
||||||
|
guard let text = planLabel.text else { return }
|
||||||
|
let attributedString = NSMutableAttributedString(attributedString: planLabel.attributedText ?? NSAttributedString(string: text))
|
||||||
|
let range = NSRange(location: 0, length: attributedString.length)
|
||||||
|
attributedString.removeAttribute(.paragraphStyle, range: range)
|
||||||
|
attributedString.removeAttribute(.baselineOffset, range: range)
|
||||||
|
|
||||||
|
// Accounts for the overshoot of non flat characters. 5% is typically the highest.
|
||||||
|
let overshoot: CGFloat = planLabel.font.pointSize * 0.05
|
||||||
|
|
||||||
|
// When messing with the maximum line height, the baseline needs to be adjusted.
|
||||||
|
let baseLineOffset = planLabel.font.descender + (overshoot / 2.0)
|
||||||
|
|
||||||
|
// We want the top to align with the top of the headline capitals, ignoring ascenders.
|
||||||
|
let headlineMatchingOffset = headline.font.ascender - headline.font.capHeight
|
||||||
|
|
||||||
|
let paragraphStyle = NSMutableParagraphStyle()
|
||||||
|
paragraphStyle.maximumLineHeight = planLabel.font.capHeight + overshoot + headlineMatchingOffset
|
||||||
|
attributedString.addAttribute(.paragraphStyle, value: paragraphStyle, range: range)
|
||||||
|
attributedString.addAttribute(.baselineOffset, value: baseLineOffset, range: range)
|
||||||
|
planLabel.attributedText = attributedString
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------
|
||||||
|
// MARK: - Molecule
|
||||||
|
//------------------------------------------------------
|
||||||
|
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
|
super.set(with: model, delegateObject, additionalData)
|
||||||
|
guard let model = model as? LockupsPlanSMLXLModel else { return }
|
||||||
|
planLabel.set(with: model.planLabel, delegateObject, additionalData)
|
||||||
|
headline.set(with: model.headline, delegateObject, additionalData)
|
||||||
|
subHeadline.set(with: model.subHeadline, delegateObject, additionalData)
|
||||||
|
body.set(with: model.body, delegateObject, additionalData)
|
||||||
|
updateAccessibilityLabel()
|
||||||
|
}
|
||||||
|
|
||||||
|
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||||
|
return 121
|
||||||
|
}
|
||||||
|
|
||||||
|
open override func reset() {
|
||||||
|
super.reset()
|
||||||
|
stack.reset()
|
||||||
|
planLabel.font = MFStyler.getMVA3FontSize(96, bold: true)
|
||||||
|
planLabel.standardFontSize = 96
|
||||||
|
headline.setFontStyle(.BoldTitleLarge)
|
||||||
|
subHeadline.setFontStyle(.RegularTitleLarge)
|
||||||
|
body.setFontStyle(.RegularBodySmall)
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Accessibility
|
||||||
|
//--------------------------------------------------
|
||||||
|
func updateAccessibilityLabel() {
|
||||||
|
isAccessibilityElement = true
|
||||||
|
var message = ""
|
||||||
|
|
||||||
|
if let planLabel = planLabel.text, !planLabel.isEmpty {
|
||||||
|
message += planLabel + ", "
|
||||||
|
}
|
||||||
|
if let headline = headline.text, !headline.isEmpty {
|
||||||
|
message += headline + ", "
|
||||||
|
}
|
||||||
|
if let subHeadline = subHeadline.text, !subHeadline.isEmpty {
|
||||||
|
message += subHeadline + ", "
|
||||||
|
}
|
||||||
|
if let body = body.text, !body.isEmpty {
|
||||||
|
message += body
|
||||||
|
}
|
||||||
|
accessibilityLabel = message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,78 @@
|
|||||||
|
//
|
||||||
|
// LockupsPlanSMLXLModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Subhankar Acharya on 15/07/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public class LockupsPlanSMLXLModel: MoleculeModelProtocol {
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public static var identifier: String = "planLockup"
|
||||||
|
public var backgroundColor: Color?
|
||||||
|
public var planLabel : LabelModel
|
||||||
|
public var headline : LabelModel
|
||||||
|
public var subHeadline: LabelModel
|
||||||
|
public var body: LabelModel
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Initializer
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public init(planLabel: LabelModel, headline: LabelModel, subHeadline: LabelModel, body: LabelModel) {
|
||||||
|
self.planLabel = planLabel
|
||||||
|
self.headline = headline
|
||||||
|
self.subHeadline = subHeadline
|
||||||
|
self.body = body
|
||||||
|
setDefaults()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Defaults to set
|
||||||
|
public func setDefaults() {
|
||||||
|
planLabel.fontName = DSBold
|
||||||
|
planLabel.fontSize = 96.0
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Keys
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case moleculeName
|
||||||
|
case backgroundColor
|
||||||
|
case planLabel
|
||||||
|
case headline
|
||||||
|
case subHeadline
|
||||||
|
case body
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Codec
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
|
planLabel = try typeContainer.decode(LabelModel.self, forKey: .planLabel)
|
||||||
|
headline = try typeContainer.decode(LabelModel.self, forKey: .headline)
|
||||||
|
subHeadline = try typeContainer.decode(LabelModel.self, forKey: .subHeadline)
|
||||||
|
body = try typeContainer.decode(LabelModel.self, forKey: .body)
|
||||||
|
setDefaults()
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
|
try container.encode(planLabel, forKey: .planLabel)
|
||||||
|
try container.encode(headline, forKey: .headline)
|
||||||
|
try container.encode(subHeadline, forKey: .subHeadline)
|
||||||
|
try container.encode(body, forKey: .body)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user