From f245d0c32170ae0b206e3ced848f95a19988c84a Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Mon, 8 Jun 2020 19:44:45 +0530 Subject: [PATCH] carousel itemILC added --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + .../Molecules/Items/CarouselItemILC.swift | 71 +++++++++++++++++++ .../Items/CarouselItemILCModel.swift | 61 ++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/Items/CarouselItemILC.swift create mode 100644 MVMCoreUI/Atomic/Molecules/Items/CarouselItemILCModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 331da73c..b9dc159f 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -241,6 +241,8 @@ C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69323C9909000BFB94E /* DoughnutChartModel.swift */; }; C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69523C990BC00BFB94E /* DoughnutChart.swift */; }; C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69723C990C200BFB94E /* DoughnutChartView.swift */; }; + C6A4920F248E17EB00643D3F /* CarouselItemILCModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6A4920E248E17EB00643D3F /* CarouselItemILCModel.swift */; }; + C6A49211248E180600643D3F /* CarouselItemILC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6A49210248E180600643D3F /* CarouselItemILC.swift */; }; C6FA7D5223C77A4A00A3614A /* UnOrderedList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D4F23C77A4700A3614A /* UnOrderedList.swift */; }; C6FA7D5323C77A4A00A3614A /* StringAndMoleculeStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D5023C77A4800A3614A /* StringAndMoleculeStack.swift */; }; C6FA7D5423C77A4A00A3614A /* NumberedList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FA7D5123C77A4900A3614A /* NumberedList.swift */; }; @@ -678,6 +680,8 @@ C695A69323C9909000BFB94E /* DoughnutChartModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartModel.swift; sourceTree = ""; }; C695A69523C990BC00BFB94E /* DoughnutChart.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChart.swift; sourceTree = ""; }; C695A69723C990C200BFB94E /* DoughnutChartView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartView.swift; sourceTree = ""; }; + C6A4920E248E17EB00643D3F /* CarouselItemILCModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselItemILCModel.swift; sourceTree = ""; }; + C6A49210248E180600643D3F /* CarouselItemILC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselItemILC.swift; sourceTree = ""; }; C6FA7D4F23C77A4700A3614A /* UnOrderedList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedList.swift; sourceTree = ""; }; C6FA7D5023C77A4800A3614A /* StringAndMoleculeStack.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringAndMoleculeStack.swift; sourceTree = ""; }; C6FA7D5123C77A4900A3614A /* NumberedList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedList.swift; sourceTree = ""; }; @@ -1284,6 +1288,8 @@ D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */, 012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */, D21B7F74243BAC8900051ABF /* CarouselItem.swift */, + C6A4920E248E17EB00643D3F /* CarouselItemILCModel.swift */, + C6A49210248E180600643D3F /* CarouselItemILC.swift */, ); path = Items; sourceTree = ""; @@ -2096,6 +2102,7 @@ 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */, D2A92884241ACB25004E01C6 /* ProgrammaticScrollViewController.swift in Sources */, 0A21DB7F235DECC500C160A2 /* EntryField.swift in Sources */, + C6A49211248E180600643D3F /* CarouselItemILC.swift in Sources */, D2E2A99F23E07F8A000B42E6 /* PillButton.swift in Sources */, D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */, @@ -2128,6 +2135,7 @@ 94C0150C2421564A005811A9 /* ActionCollapseNotificationModel.swift in Sources */, 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, + C6A4920F248E17EB00643D3F /* CarouselItemILCModel.swift in Sources */, D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */, 94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */, 943820842432382400B43AF3 /* WebView.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 4f151642..1602bd8d 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -134,6 +134,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: StackItem.self, viewModelClass: StackItemModel.self) MoleculeObjectMapping.shared()?.register(viewClass: MoleculeCollectionViewCell.self, viewModelClass: MoleculeCollectionItemModel.self) MoleculeObjectMapping.shared()?.register(viewClass: CarouselItem.self, viewModelClass: CarouselItemModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: CarouselItemILC.self, viewModelClass: CarouselItemILCModel.self) // Other Container Molecules diff --git a/MVMCoreUI/Atomic/Molecules/Items/CarouselItemILC.swift b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemILC.swift new file mode 100644 index 00000000..548de74f --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemILC.swift @@ -0,0 +1,71 @@ +// +// CarouselItemILC.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 08/06/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class CarouselItemILC: CollectionViewCell { + + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public let image = LoadImageView(frame: .zero) + public let label = Label(frame: .zero) + public let caretLink = CaretLink(frame: .zero) + public var stack: Stack + + public override init(frame: CGRect) { + stack = Stack.createStack(with: [ + (view: image, model: StackItemModel(horizontalAlignment: .fill)), + (view: label, model: StackItemModel(spacing: 6.0, horizontalAlignment: .fill)), + (view: caretLink, model: StackItemModel(spacing:52.0, horizontalAlignment: .leading, verticalAlignment: .trailing))], + axis: .vertical) + super.init(frame: frame) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + open override func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + // Make the whole cell focusable. + isAccessibilityElement = true + caretLink.isAccessibilityElement = false + accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "radio_action_hint") + } + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? CarouselItemILCModel else { return } + stack.updateContainedMolecules(with: [model.image, model.label, model.caretLink], + delegateObject, additionalData) + + updateAccessibilityLabel() + } + + public override func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + guard let action = (model as? CarouselItemILCModel)?.caretLink.action else { return } + Button.performButtonAction(with: action, button: self, delegateObject: delegateObject, additionalData: additionalData) + } + + func updateAccessibilityLabel() { + var message = "" + if let labelText = label.accessibilityLabel { + message += labelText + ", " + } + + if let caretLinkText = caretLink.titleLabel?.text { + message += caretLinkText + } + accessibilityLabel = message + } + +} diff --git a/MVMCoreUI/Atomic/Molecules/Items/CarouselItemILCModel.swift b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemILCModel.swift new file mode 100644 index 00000000..dad7551c --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/Items/CarouselItemILCModel.swift @@ -0,0 +1,61 @@ +// +// CarouselItemILCModel.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 08/06/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class CarouselItemILCModel: ContainerModel, MoleculeModelProtocol, CarouselItemModelProtocol, CollectionItemModelProtocol { + + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public var backgroundColor: Color? + public var image: ImageViewModel + public var label: LabelModel + public var caretLink: CaretLinkModel + + public class var identifier: String { + return "carouselItemILC" + } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case label + case image + case caretLink + } + + //-------------------------------------------------- + // 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) + image = try typeContainer.decode(ImageViewModel.self, forKey: .image) + label = try typeContainer.decode(LabelModel.self, forKey: .label) + caretLink = try typeContainer.decode(CaretLinkModel.self, forKey: .caretLink) + 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.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encode(image, forKey: .image) + try container.encode(label, forKey: .label) + try container.encode(caretLink, forKey: .caretLink) + try container.encode(moleculeName, forKey: .moleculeName) + } + +}