diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift index 2edb4b9a..06d1173d 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift @@ -78,6 +78,10 @@ import Foundation return 140 } + //-------------------------------------------------- + // MARK: - Accessibility + //-------------------------------------------------- + func updateAccessibilityLabel() { var message = "" diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxBodyText.swift index 92e31c68..326c9320 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxBodyText.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxBodyText.swift @@ -62,6 +62,7 @@ import Foundation //---------------------------------------------------- // MARK: - Molecule //---------------------------------------------------- + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) @@ -80,6 +81,10 @@ import Foundation checkbox.isSelected.toggle() } + //---------------------------------------------------- + // MARK: - Accessibility + //---------------------------------------------------- + func updateAccessibilityLabel() { var message = "" diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift index 40579a09..2c271d78 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheel.swift @@ -7,8 +7,14 @@ // import Foundation + + @objcMembers open class ListRVWheel: TableViewCell { - let wheel = Wheel(frame: .zero) + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + let wheel = Wheel() let leftLabel = Label.createLabelBoldBodySmall(true) let rightLabel = Label.createLabelRegularBodySmall(true) var stack: Stack @@ -16,6 +22,7 @@ import Foundation //----------------------------------------------------- // MARK: - Initializers //----------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: leftLabel, model: StackItemModel(horizontalAlignment: .leading)), (view: wheel, model: StackItemModel(horizontalAlignment: .fill)), @@ -31,6 +38,7 @@ import Foundation //------------------------------------------------- // MARK: - Setup //------------------------------------------------- + open override func setupView() { super.setupView() rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) @@ -41,17 +49,17 @@ import Foundation //------------------------------------------------- // MARK: - MoleculeViewProtocol //------------------------------------------------- - 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) + guard let model = model as? ListRVWheelModel else { return } + leftLabel.set(with: model.leftLabel, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData) wheel.set(with: model.wheel, delegateObject, additionalData) } - //------------------------------------------------- - // MARK: - MoleculeViewProtocol - //------------------------------------------------- open override func reset() { super.reset() leftLabel.styleBoldBodySmall(true) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift index a5df2cfe..1da9d9bb 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRVWheelModel.swift @@ -7,12 +7,22 @@ // import Foundation + + public class ListRVWheelModel: ListItemModel, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "listRVWheel" public var leftLabel: LabelModel public var rightLabel: LabelModel public var wheel: WheelModel + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(leftLabel: LabelModel, rightLabel: LabelModel, wheel: WheelModel) { self.leftLabel = leftLabel self.rightLabel = rightLabel @@ -20,12 +30,19 @@ public class ListRVWheelModel: ListItemModel, MoleculeModelProtocol { super.init() } - /// Defaults to set + //-------------------------------------------------- + // MARK: - Method + //-------------------------------------------------- + override public func setDefaults() { super.setDefaults() rightLabel.hero = 0 } + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case moleculeName case leftLabel @@ -33,6 +50,10 @@ public class ListRVWheelModel: ListItemModel, MoleculeModelProtocol { case wheel } + //-------------------------------------------------- + // 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) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift index 25885044..2dd6e53e 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift @@ -7,19 +7,24 @@ // import Foundation + + @objcMembers open class ListRightVariableButtonAllTextAndLinks: TableViewCell { - //----------------------------------------------------- // MARK: - Outlets //----------------------------------------------------- - public var stack: Stack - public let button = PillButton(frame: .zero) - public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) + public var stack: Stack + public let button = PillButton() + public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink() + + //-------------------------------------------------- // MARK: - Initializers + //-------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading)), - (view: button, model: StackItemModel(horizontalAlignment:.fill))], + (view: button, model: StackItemModel(horizontalAlignment: .fill))], axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -29,23 +34,81 @@ import Foundation } //----------------------------------------------------- - // MARK: - View Lifecycle + // MARK: - Lifecycle //----------------------------------------------------- + override open func setupView() { super.setupView() addMolecule(stack) stack.restack() + updateAccessibilityLabel() } - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + //----------------------------------------------------- + // MARK: - Molecular + //----------------------------------------------------- + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListRightVariableButtonAllTextAndLinksModel else { return } + button.set(with: model.button, delegateObject, additionalData) eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) + updateAccessibilityLabel() } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 90 } + + //---------------------------------------------------- + // MARK: - Accessibility + //---------------------------------------------------- + + func updateAccessibilityLabel() { + + var message = "" + + if let checkboxLabel = button.accessibilityLabel { + message += checkboxLabel + ", " + } + + if let eyebrowLabel = eyebrowHeadlineBodyLink.eyebrow.text { + message += eyebrowLabel + ", " + } + + if let headlineLabel = eyebrowHeadlineBodyLink.headline.text { + message += headlineLabel + ", " + } + + if let bodyLabel = eyebrowHeadlineBodyLink.body.text { + message += bodyLabel + } + + let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0 + + isAccessibilityElement = !linkShowing + button.isAccessibilityElement = linkShowing + eyebrowHeadlineBodyLink.link.isAccessibilityElement = linkShowing + + if !linkShowing { + // Make whole cell focusable if no link. + accessibilityLabel = message + } else { + // Allow only radio button and link to be focused on. + button.accessibilityLabel = message + var elements: [UIView] = [] + + if !message.isEmpty { + elements.append(button) + } + + if linkShowing { + elements.append(eyebrowHeadlineBodyLink.link) + } + + accessibilityElements = elements + } + } } - diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift index de9e5d63..ff41a2b0 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift @@ -7,30 +7,51 @@ // import Foundation + + public class ListRightVariableButtonAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "listRVBtn" public var button: ButtonModel public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(button: ButtonModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) { self.button = button self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink super.init() } - /// Defaults to set + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + override public func setDefaults() { super.setDefaults() self.button.size = .tiny self.button.style = .secondary } + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case moleculeName case button case eyebrowHeadlineBodyLink } + //-------------------------------------------------- + // MARK: - codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) button = try typeContainer.decode(ButtonModel.self, forKey: .button) @@ -46,4 +67,3 @@ public class ListRightVariableButtonAllTextAndLinksModel: ListItemModel, Molecul try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) } } - diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift index ce73c082..55fa8e3a 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift @@ -8,11 +8,12 @@ import Foundation + @objcMembers open class ListRightVariablePayments: TableViewCell { - //----------------------------------------------------- // MARK: - Outlets - //------------------------------------------------------- + //----------------------------------------------------- + let leftLabel = Label.createLabelBoldBodySmall(true) let rightImage = LoadImageView(pinnedEdges: .all) var stack: Stack @@ -32,8 +33,9 @@ import Foundation } //----------------------------------------------------- - // MARK: - View Lifecycle - //------------------------------------------------------- + // MARK: - Lifecycle + //----------------------------------------------------- + override open func setupView() { super.setupView() rightImage.addSizeConstraintsForAspectRatio = true @@ -44,9 +46,12 @@ import Foundation //---------------------------------------------------- // MARK: - Molecule //------------------------------------------------------ - 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) + guard let model = model as? ListRightVariablePaymentsModel else { return } + leftLabel.set(with: model.leftLabel, delegateObject, additionalData) rightImage.set(with: model.image, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift index 4842b60a..5cfd64f8 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift @@ -8,19 +8,30 @@ import Foundation + public class ListRightVariablePaymentsModel: ListItemModel, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- public static var identifier: String = "listRVImg" public var image: ImageViewModel public var leftLabel: LabelModel + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(image: ImageViewModel, leftLabel: LabelModel) { self.leftLabel = leftLabel self.image = image super.init() } - /// Defaults to set + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + override public func setDefaults() { super.setDefaults() leftLabel.hero = 0 @@ -35,12 +46,20 @@ public class ListRightVariablePaymentsModel: ListItemModel, MoleculeModelProtoco return image } + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case moleculeName case leftLabel case image } + //-------------------------------------------------- + // 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) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift index ab135eb6..a47ecfbe 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinks.swift @@ -8,13 +8,14 @@ import Foundation + @objcMembers open class ListRightVariablePriceChangeAllTextAndLinks: TableViewCell { - //----------------------------------------------------- // MARK: - Outlets //----------------------------------------------------- - public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) - public let arrow = Arrow(frame: .zero) + + public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink() + public let arrow = Arrow() public let rightLabel = Label.createLabelRegularBodySmall(true) private let stack: Stack private let arrowStackItem: StackItem @@ -23,6 +24,7 @@ import Foundation //----------------------------------------------------- // MARK: - Initializers //----------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { let stackModel = StackModel(molecules: [StackItemModel(horizontalAlignment: .leading), StackItemModel(horizontalAlignment: .fill), @@ -40,7 +42,7 @@ import Foundation } //----------------------------------------------------- - // MARK: - View Lifecycle + // MARK: - Lifecycle //----------------------------------------------------- open override func alignAccessoryToHero() -> CGPoint? { @@ -52,11 +54,13 @@ import Foundation arrowStackItem.containerHelper.alignCenterVerticalConstraint?.constant = convertedPoint.y - stack.bounds.midY rightLabelStackItem.containerHelper.alignCenterVerticalConstraint?.constant = convertedPoint.y - stack.bounds.midY } + return heroCenter } open override func setupView() { super.setupView() + rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.numberOfLines = 1 @@ -67,9 +71,11 @@ import Foundation stack.restack() } - 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) + guard let model = model as? ListRightVariablePriceChangeAllTextAndLinksModel else { return } + eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData) arrow.set(with: model.arrow, delegateObject, additionalData) @@ -78,5 +84,56 @@ import Foundation open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 121 } + + //-------------------------------------------------- + // MARK: - Accessibility + //-------------------------------------------------- + + func updateAccessibilityLabel() { + + var message = "" + + checkbox.updateAccessibilityLabel() + + if let checkboxLabel = checkbox.accessibilityLabel { + message += checkboxLabel + ", " + } + + if let eyebrowLabel = eyebrowHeadlineBodyLink.eyebrow.text { + message += eyebrowLabel + ", " + } + + if let headlineLabel = eyebrowHeadlineBodyLink.headline.text { + message += headlineLabel + ", " + } + + if let bodyLabel = eyebrowHeadlineBodyLink.body.text { + message += bodyLabel + } + + let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0 + + isAccessibilityElement = !linkShowing + checkbox.isAccessibilityElement = linkShowing + eyebrowHeadlineBodyLink.link.isAccessibilityElement = linkShowing + + if !linkShowing { + // Make whole cell focusable if no link. + accessibilityLabel = message + } else { + // Allow only radio button and link to be focused on. + checkbox.accessibilityLabel = message + var elements: [UIView] = [] + + if message.count > 0 { + elements.append(checkbox) + } + + if linkShowing { + elements.append(eyebrowHeadlineBodyLink.link) + } + + accessibilityElements = elements + } + } } - diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinksModel.swift index ae4be269..2b2a569b 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeAllTextAndLinksModel.swift @@ -8,12 +8,21 @@ import Foundation + public class ListRightVariablePriceChangeAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "listRVArwAll" public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel public var rightLabel: LabelModel public var arrow: ArrowModel + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel, rightLabel: LabelModel, arrow: ArrowModel) { self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink self.rightLabel = rightLabel @@ -21,6 +30,10 @@ public class ListRightVariablePriceChangeAllTextAndLinksModel: ListItemModel, Mo super.init() } + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case moleculeName case eyebrowHeadlineBodyLink @@ -28,6 +41,10 @@ public class ListRightVariablePriceChangeAllTextAndLinksModel: ListItemModel, Mo case arrow } + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyText.swift index 63e90d34..c1e91e7f 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyText.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyText.swift @@ -7,19 +7,23 @@ // import Foundation + + @objcMembers open class ListRightVariablePriceChangeBodyText: TableViewCell { - //----------------------------------------------------- // MARK: - Outlets //----------------------------------------------------- + private let stack: Stack - public let headlineBody = HeadlineBody(frame: .zero) - public let arrow = Arrow(frame: .zero) + public let headlineBody = HeadlineBody() + public let arrow = Arrow() public let rightLabel = Label.createLabelRegularBodySmall(true) let arrowAndRightLabelStack: Stack - + //-------------------------------------------------- // MARK: - Initializers + //-------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { arrowAndRightLabelStack = Stack.createStack(with: [(view: arrow, model: StackItemModel(horizontalAlignment: .fill)), (view: rightLabel, model: StackItemModel(horizontalAlignment: .fill))], @@ -35,8 +39,9 @@ import Foundation } //----------------------------------------------------- - // MARK: - View Lifecycle + // MARK: - Lifecycle //----------------------------------------------------- + open override func setupView() { super.setupView() headlineBody.styleListItem() @@ -51,9 +56,15 @@ import Foundation arrowAndRightLabelStack.restack() } - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + //-------------------------------------------------- + // MARK: - Molecular + //-------------------------------------------------- + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListRightVariablePriceChangeBodyTextModel else { return } + headlineBody.set(with: model.headlineBody, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData) arrow.set(with: model.arrow, delegateObject, additionalData) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyTextModel.swift index 7bf118df..fd3f865d 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePriceChangeBodyTextModel.swift @@ -7,12 +7,22 @@ // import Foundation + + public class ListRightVariablePriceChangeBodyTextModel: ListItemModel, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "listRVArwBdy" public var headlineBody: HeadlineBodyModel public var rightLabel: LabelModel public var arrow: ArrowModel - + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(headlineBody: HeadlineBodyModel,rightLabel: LabelModel,arrow: ArrowModel) { self.headlineBody = headlineBody self.rightLabel = rightLabel @@ -20,7 +30,10 @@ public class ListRightVariablePriceChangeBodyTextModel: ListItemModel, MoleculeM super.init() } - /// Defaults to set + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + public override func setDefaults() { super.setDefaults() if let headline = headlineBody.headline { @@ -28,6 +41,10 @@ public class ListRightVariablePriceChangeBodyTextModel: ListItemModel, MoleculeM } } + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case moleculeName case headlineBody @@ -35,6 +52,10 @@ public class ListRightVariablePriceChangeBodyTextModel: ListItemModel, MoleculeM case arrow } + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift index 88d9448b..84848aff 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift @@ -7,16 +7,21 @@ // import Foundation + + @objcMembers open class ListRightVariableTextLinkAllTextAndLinks: TableViewCell { - - //----------------------------------------------------- + //-------------------------------------------------- // MARK: - Outlets - //----------------------------------------------------- - public var stack: Stack - public let link = Link(frame: .zero) - public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) + //-------------------------------------------------- + public var stack: Stack + public let link = Link() + public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink() + + //-------------------------------------------------- // MARK: - Initializers + //-------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .top)), (view: link, model: StackItemModel(horizontalAlignment:.fill, verticalAlignment: .top))], @@ -29,17 +34,24 @@ import Foundation } //----------------------------------------------------- - // MARK: - View Lifecycle + // MARK: - Lifecycle //----------------------------------------------------- + override open func setupView() { super.setupView() addMolecule(stack) stack.restack() } - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + //-------------------------------------------------- + // MARK: - Molecular + //-------------------------------------------------- + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListRightVariableTextLinkAllTextAndLinksModel else { return } + link.set(with: model.link, delegateObject, additionalData) eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift index 9f6392fc..9e49eda0 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinksModel.swift @@ -7,23 +7,41 @@ // import Foundation + + public class ListRightVariableTextLinkAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "listRVLink" public var link: LinkModel public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(link: LinkModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) { self.link = link self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink super.init() } + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case moleculeName case link case eyebrowHeadlineBodyLink } + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) link = try typeContainer.decode(LinkModel.self, forKey: .link) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift index bb6ebd9e..8dae61e6 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalData.swift @@ -8,11 +8,12 @@ import Foundation + @objcMembers open class ListRightVariableTotalData: TableViewCell { - //----------------------------------------------------- // MARK: - Outlets //----------------------------------------------------- + public var stack: Stack public let leftLabel = Label.createLabelBoldBodySmall(true) public let rightLabel = Label.createLabelRegularBodySmall(true) @@ -35,8 +36,8 @@ import Foundation } //----------------------------------------------------- - // MARK: - View Lifecycle - //------------------------------------------------------- + // MARK: - Lifecycle + //----------------------------------------------------- override open func setupView() { super.setupView() @@ -47,15 +48,21 @@ import Foundation stack.restack() } - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ + //-------------------------------------------------- + // MARK: - Molecular + //-------------------------------------------------- + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListRightVariableTotalDataModel else { return } + leftLabel.set(with: model.leftLabel, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData) bar.set(with: model.bar, delegateObject, additionalData) } - open override class func estimatedHeight(with molecule: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat?{ + open override class func estimatedHeight(with molecule: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 70 } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift index f0790391..806cd602 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTotalDataModel.swift @@ -8,13 +8,21 @@ import Foundation + public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- public static var identifier: String = "listRVLine" public var leftLabel: LabelModel public var rightLabel: LabelModel public var bar: LineModel + //-------------------------------------------------- + // MARK: - Method + //-------------------------------------------------- + override public func setDefaults() { super.setDefaults() rightLabel.hero = 0 @@ -24,13 +32,21 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc } } - public init (leftLabel: LabelModel, rightlabel:LabelModel, bar: LineModel){ + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(leftLabel: LabelModel, rightlabel:LabelModel, bar: LineModel){ self.leftLabel = leftLabel self.rightLabel = rightlabel self.bar = bar super.init() } + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey{ case moleculeName case leftLabel @@ -38,6 +54,10 @@ public class ListRightVariableTotalDataModel: ListItemModel, MoleculeModelProtoc case bar } + //-------------------------------------------------- + // 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)