diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 454ef7e7..b61c3aa1 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -240,6 +240,8 @@ AAA905E124D1759A00D1EFAB /* ListThreeColumnBillHistory.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA905E024D1759A00D1EFAB /* ListThreeColumnBillHistory.swift */; }; AAB7EDEF246ADA1600E54929 /* ListProgressBarThinModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAB7EDEE246ADA1600E54929 /* ListProgressBarThinModel.swift */; }; AAB7EDF1246ADA2A00E54929 /* ListProgressBarThin.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAB7EDF0246ADA2A00E54929 /* ListProgressBarThin.swift */; }; + AAB8549824DC01BD00477C40 /* ListThreeColumnBillHistoryDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAB8549724DC01BD00477C40 /* ListThreeColumnBillHistoryDividerModel.swift */; }; + AAB8549A24DC01DB00477C40 /* ListThreeColumnBillHistoryDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAB8549924DC01DB00477C40 /* ListThreeColumnBillHistoryDivider.swift */; }; AAB9C10824346F4B00151545 /* RadioSwatches.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAB9C10724346F4B00151545 /* RadioSwatches.swift */; }; AAB9C10A243496DD00151545 /* RadioSwatch.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAB9C109243496DD00151545 /* RadioSwatch.swift */; }; AAC23FAD24D92A0D009208DF /* ListThreeColumnSpeedTestModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAC23FAC24D92A0D009208DF /* ListThreeColumnSpeedTestModel.swift */; }; @@ -719,6 +721,8 @@ AAA905E024D1759A00D1EFAB /* ListThreeColumnBillHistory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnBillHistory.swift; sourceTree = ""; }; AAB7EDEE246ADA1600E54929 /* ListProgressBarThinModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListProgressBarThinModel.swift; sourceTree = ""; }; AAB7EDF0246ADA2A00E54929 /* ListProgressBarThin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListProgressBarThin.swift; sourceTree = ""; }; + AAB8549724DC01BD00477C40 /* ListThreeColumnBillHistoryDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnBillHistoryDividerModel.swift; sourceTree = ""; }; + AAB8549924DC01DB00477C40 /* ListThreeColumnBillHistoryDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnBillHistoryDivider.swift; sourceTree = ""; }; AAB9C10724346F4B00151545 /* RadioSwatches.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioSwatches.swift; sourceTree = ""; }; AAB9C109243496DD00151545 /* RadioSwatch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioSwatch.swift; sourceTree = ""; }; AAC23FAC24D92A0D009208DF /* ListThreeColumnSpeedTestModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnSpeedTestModel.swift; sourceTree = ""; }; @@ -1463,6 +1467,8 @@ AA1EC59824373994003D6F50 /* ListThreeColumnSpeedTestDivider.swift */, 8DEFA95B243DAC20000D27E5 /* ListThreeColumnDataUsageDividerModel.swift */, 8DEFA95D243DAC2F000D27E5 /* ListThreeColumnDataUsageDivider.swift */, + AAB8549724DC01BD00477C40 /* ListThreeColumnBillHistoryDividerModel.swift */, + AAB8549924DC01DB00477C40 /* ListThreeColumnBillHistoryDivider.swift */, ); path = ThreeColumn; sourceTree = ""; @@ -2317,6 +2323,7 @@ D2E2A99C23D8D975000B42E6 /* ImageHeadlineBodyModel.swift in Sources */, 525019DE2406430800EED91C /* ListProgressBarData.swift in Sources */, D28A837F23CCA96400DFE4FC /* TabsModel.swift in Sources */, + AAB8549A24DC01DB00477C40 /* ListThreeColumnBillHistoryDivider.swift in Sources */, 012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */, 8DDD6C1F244D90E1006A2232 /* ListThreeColumnDataUsageModel.swift in Sources */, BB55B51F244482D2002001AD /* ListRightVariablePriceChangeBodyTextModel.swift in Sources */, @@ -2514,6 +2521,7 @@ BB2FB3BB247E7EBC00DF73CD /* TagCollectionViewCell.swift in Sources */, 012A88C6238DA34000FE3DA1 /* ModuleMoleculeModel.swift in Sources */, 94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */, + AAB8549824DC01BD00477C40 /* ListThreeColumnBillHistoryDividerModel.swift in Sources */, D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */, D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */, 0A21DB94235E24ED00C160A2 /* DigitEntryField.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index f5b91c52..a08347c7 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -208,6 +208,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnSpeedTestDivider.self, viewModelClass: ListThreeColumnSpeedTestDividerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnBillChangesDivider.self, viewModelClass: ListThreeColumnBillChangesDividerModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnDataUsageDivider.self, viewModelClass: ListThreeColumnDataUsageDividerModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnBillHistoryDivider.self, viewModelClass: ListThreeColumnBillHistoryDividerModel.self) // MARK:- Designed Headers MoleculeObjectMapping.shared()?.register(viewClass: HeadersH1Button.self, viewModelClass: HeadersH1ButtonModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillHistoryDivider.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillHistoryDivider.swift new file mode 100644 index 00000000..1246e98c --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillHistoryDivider.swift @@ -0,0 +1,80 @@ +// +// ListThreeColumnBillHistoryDivider.swift +// MVMCoreUI +// +// Created by Lekshmi S on 06/08/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +@objcMembers open class ListThreeColumnBillHistoryDivider: TableViewCell { + //----------------------------------------------------- + // MARK: - Outlets + //------------------------------------------------------- + public let leftLabel = Label(fontStyle: .BoldBodySmall) + public let centerLabel = Label(fontStyle: .BoldBodySmall) + public let rightLabel = Label(fontStyle: .BoldBodySmall) + var stack: Stack + + //------------------------------------------------------ + // MARK: - Initializers + //------------------------------------------------------ + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 34, horizontalAlignment: .leading)), (view: centerLabel, model: StackItemModel(percent: 42, horizontalAlignment: .leading)), (view: rightLabel, model: StackItemModel(percent: 24, horizontalAlignment: .trailing))], axis: .horizontal) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //------------------------------------------------------ + // MARK: - Lifecycle + //------------------------------------------------------ + open override func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + //-------------------------------------------------- + // MARK: - ModelMoleculeViewProtocol + //-------------------------------------------------- + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListThreeColumnBillHistoryDividerModel else { return } + leftLabel.set(with: model.leftLabel, delegateObject, additionalData) + centerLabel.set(with: model.centerLabel, delegateObject, additionalData) + rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + updateAccessibilityLabel() + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 121 + } + + open override func reset() { + super.reset() + leftLabel.setFontStyle(.BoldBodySmall) + centerLabel.setFontStyle(.BoldBodySmall) + rightLabel.setFontStyle(.BoldBodySmall) + } + + //-------------------------------------------------- + // MARK: - Accessibility + //-------------------------------------------------- + func updateAccessibilityLabel() { + isAccessibilityElement = true + var message = "" + if let leftText = leftLabel.text, !leftText.isEmpty { + message += leftText + ", " + } + if let centerText = centerLabel.text, !centerText.isEmpty { + message += centerText + ", " + } + if let rightText = rightLabel.text, !rightText.isEmpty { + message += rightText + } + accessibilityLabel = message + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillHistoryDividerModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillHistoryDividerModel.swift new file mode 100644 index 00000000..807800bb --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/ThreeColumn/ListThreeColumnBillHistoryDividerModel.swift @@ -0,0 +1,66 @@ +// +// ListThreeColumnBillHistoryDividerModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 06/08/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +public class ListThreeColumnBillHistoryDividerModel: ListItemModel, MoleculeModelProtocol { + //----------------------------------------------------- + // MARK: - Properties + //----------------------------------------------------- + public static var identifier: String = "list3CBillHisDiv" + public var leftLabel: LabelModel + public var centerLabel: LabelModel + public var rightLabel: LabelModel + + //----------------------------------------------------- + // MARK: - Initializer + //----------------------------------------------------- + public init(leftLabel: LabelModel, centerLabel: LabelModel, rightLabel: LabelModel) { + self.leftLabel = leftLabel + self.centerLabel = centerLabel + self.rightLabel = rightLabel + super.init() + } + + //----------------------------------------------------- + // MARK: - Method + //----------------------------------------------------- + override public func setDefaults() { + style = .tallDivider + super.setDefaults() + } + + //----------------------------------------------------- + // MARK: - Keys + //----------------------------------------------------- + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftLabel + case centerLabel + case rightLabel + } + + //----------------------------------------------------- + // MARK: - Codec + //----------------------------------------------------- + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) + centerLabel = try typeContainer.decode(LabelModel.self, forKey: .centerLabel) + rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) + try super.init(from: decoder) + } + + 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.encode(leftLabel, forKey: .leftLabel) + try container.encode(centerLabel, forKey: .centerLabel) + try container.encode(rightLabel, forKey: .rightLabel) + } +}