designed component accessibility

This commit is contained in:
Kevin G Christiano 2020-06-03 16:58:47 -04:00
parent 01ad16d9ff
commit 77dbd5d473
38 changed files with 1105 additions and 81 deletions

View File

@ -8,17 +8,20 @@
import Foundation import Foundation
@objcMembers open class HeadersH2Buttons: HeaderView { @objcMembers open class HeadersH2Buttons: HeaderView {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Outlets // MARK: - Outlets
//-------------------------------------------------- //--------------------------------------------------
public let headlineBody = HeadlineBody(frame: .zero)
public let buttons = TwoButtonView(frame: .zero) public let headlineBody = HeadlineBody()
public let buttons = TwoButtonView()
public let stack: Stack<StackModel> public let stack: Stack<StackModel>
//------------------------------------------------------- //-------------------------------------------------------
// MARK: - Initializers // MARK: - Initializers
//------------------------------------------------------- //-------------------------------------------------------
public override init(frame: CGRect) { public override init(frame: CGRect) {
stack = Stack<StackModel>.createStack(with: [headlineBody, buttons], spacing: PaddingDefaultVerticalSpacing3) stack = Stack<StackModel>.createStack(with: [headlineBody, buttons], spacing: PaddingDefaultVerticalSpacing3)
super.init(frame: frame) super.init(frame: frame)
@ -29,23 +32,29 @@ import Foundation
} }
//------------------------------------------------------- //-------------------------------------------------------
// MARK: - View Lifecycle // MARK: - Lifecycle
//------------------------------------------------------- //-------------------------------------------------------
open override func setupView() { open override func setupView() {
super.setupView() super.setupView()
headlineBody.stylePageHeader() headlineBody.stylePageHeader()
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
updateAccessibilityLabel()
} }
//---------------------------------------------------- //----------------------------------------------------
// MARK: - Molecule // 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) super.set(with: model, delegateObject, additionalData)
guard let model = model as? HeadersH2ButtonsModel else { return } guard let model = model as? HeadersH2ButtonsModel else { return }
headlineBody.set(with: model.headlineBody, delegateObject, additionalData) headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
buttons.set(with: model.buttons, delegateObject, additionalData) buttons.set(with: model.buttons, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
@ -56,4 +65,72 @@ import Foundation
super.reset() super.reset()
headlineBody.stylePageHeader() headlineBody.stylePageHeader()
} }
//--------------------------------------------------
// MARK: - Accessibility
//--------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let headlineText = headlineBody.headlineLabel.text, !headlineText.isEmpty {
message += headlineText + ", "
}
if let messageText = headlineBody.messageLabel.text, !messageText.isEmpty {
message += messageText + ", "
}
let secondaryButtonIsDisplayed = !buttons.secondaryButton.isHidden
let primaryButtonIsDisplayed = !buttons.primaryButton.isHidden
// Both links are displayed
if secondaryButtonIsDisplayed && primaryButtonIsDisplayed {
isAccessibilityElement = false
var views = [UIView]()
if let headlineText = headlineBody.headlineLabel.text, !headlineText.isEmpty {
views.append(headlineBody.headlineLabel)
}
if let messageText = headlineBody.messageLabel.text, !messageText.isEmpty {
views.append(headlineBody.messageLabel)
}
views.append(buttons.secondaryButton)
views.append(buttons.primaryButton)
accessibilityElements = views
return
} else if secondaryButtonIsDisplayed {
accessibilityHint = buttons.secondaryButton.accessibilityHint
accessibilityTraits = buttons.secondaryButton.accessibilityTraits
message += buttons.secondaryButton.accessibilityLabel ?? ""
} else if primaryButtonIsDisplayed {
accessibilityHint = buttons.primaryButton.accessibilityHint
accessibilityTraits = buttons.primaryButton.accessibilityTraits
message += buttons.primaryButton.accessibilityLabel ?? ""
}
isAccessibilityElement = true
accessibilityLabel = message
}
open override func accessibilityActivate() -> Bool {
if isAccessibilityElement {
if !buttons.secondaryButton.isHidden {
return buttons.secondaryButton.accessibilityActivate()
} else if !buttons.primaryButton.isHidden {
return buttons.primaryButton.accessibilityActivate()
}
}
return false
}
} }

View File

@ -8,10 +8,12 @@
import Foundation import Foundation
public class HeadersH2ButtonsModel: HeaderModel, MoleculeModelProtocol { public class HeadersH2ButtonsModel: HeaderModel, MoleculeModelProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
public static var identifier: String = "headerH2Btns" public static var identifier: String = "headerH2Btns"
public var headlineBody: HeadlineBodyModel public var headlineBody: HeadlineBodyModel
public var buttons: TwoButtonViewModel public var buttons: TwoButtonViewModel
@ -19,12 +21,17 @@ public class HeadersH2ButtonsModel: HeaderModel, MoleculeModelProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Initializer // MARK: - Initializer
//-------------------------------------------------- //--------------------------------------------------
public init(headlineBody: HeadlineBodyModel, buttons: TwoButtonViewModel) { public init(headlineBody: HeadlineBodyModel, buttons: TwoButtonViewModel) {
self.headlineBody = headlineBody self.headlineBody = headlineBody
self.buttons = buttons self.buttons = buttons
super.init() super.init()
} }
//--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------
public override func setDefaults() { public override func setDefaults() {
super.setDefaults() super.setDefaults()
topPadding = PaddingDefaultVerticalSpacing3 topPadding = PaddingDefaultVerticalSpacing3
@ -34,6 +41,7 @@ public class HeadersH2ButtonsModel: HeaderModel, MoleculeModelProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Keys // MARK: - Keys
//-------------------------------------------------- //--------------------------------------------------
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case headlineBody case headlineBody
@ -43,6 +51,7 @@ public class HeadersH2ButtonsModel: HeaderModel, MoleculeModelProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Codec // MARK: - Codec
//-------------------------------------------------- //--------------------------------------------------
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)
headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody) headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody)

View File

@ -8,29 +8,36 @@
import Foundation import Foundation
@objcMembers open class HeadersH2NoButtonsBodyText: HeaderView { @objcMembers open class HeadersH2NoButtonsBodyText: HeaderView {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Outlets // MARK: - Outlets
//-------------------------------------------------- //--------------------------------------------------
let headlineBody = HeadlineBody(frame: .zero) public let headlineBody = HeadlineBody()
//------------------------------------------------------- //-------------------------------------------------------
// MARK: - View Lifecycle // MARK: - View Lifecycle
//------------------------------------------------------- //-------------------------------------------------------
open override func setupView() { open override func setupView() {
super.setupView() super.setupView()
headlineBody.stylePageHeader() headlineBody.stylePageHeader()
addMolecule(headlineBody) addMolecule(headlineBody)
isAccessibilityElement = true
updateAccessibilityLabel()
} }
//---------------------------------------------------- //----------------------------------------------------
// MARK: - Molecule // 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) super.set(with: model, delegateObject, additionalData)
guard let model = model as? HeadersH2NoButtonsBodyTextModel else { return } guard let model = model as? HeadersH2NoButtonsBodyTextModel else { return }
headlineBody.set(with: model.headlineBody, delegateObject, additionalData) headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
@ -41,4 +48,23 @@ import Foundation
super.reset() super.reset()
headlineBody.stylePageHeader() headlineBody.stylePageHeader()
} }
//----------------------------------------------------
// MARK: - Accessibility
//----------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let headlineLabel = headlineBody.headlineLabel.text {
message += headlineLabel + ", "
}
if let messageLabel = headlineBody.messageLabel.text {
message += messageLabel
}
accessibilityLabel = message
}
} }

View File

@ -8,16 +8,19 @@
import Foundation import Foundation
public class HeadersH2NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol { public class HeadersH2NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
public static var identifier: String = "headerH2" public static var identifier: String = "headerH2"
public var headlineBody: HeadlineBodyModel public var headlineBody: HeadlineBodyModel
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Initializer // MARK: - Initializer
//-------------------------------------------------- //--------------------------------------------------
public init(headlineBody: HeadlineBodyModel) { public init(headlineBody: HeadlineBodyModel) {
self.headlineBody = headlineBody self.headlineBody = headlineBody
super.init() super.init()
@ -32,6 +35,7 @@ public class HeadersH2NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Keys // MARK: - Keys
//-------------------------------------------------- //--------------------------------------------------
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case headlineBody case headlineBody
@ -40,6 +44,7 @@ public class HeadersH2NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Codec // MARK: - Codec
//-------------------------------------------------- //--------------------------------------------------
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)
headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody) headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody)

View File

@ -8,19 +8,24 @@
import Foundation import Foundation
@objcMembers open class HeadersH2TinyButton: HeaderView { @objcMembers open class HeadersH2TinyButton: HeaderView {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Outlets // MARK: - Outlets
//-------------------------------------------------- //--------------------------------------------------
public let headlineBody = HeadlineBody(frame: .zero)
public let button = PillButton(frame: .zero) public let headlineBody = HeadlineBody()
public let button = PillButton()
public let stack: Stack<StackModel> public let stack: Stack<StackModel>
//------------------------------------------------------- //-------------------------------------------------------
// MARK: - Initializers // MARK: - Initializers
//------------------------------------------------------- //-------------------------------------------------------
public override init(frame: CGRect) { public override init(frame: CGRect) {
stack = Stack<StackModel>.createStack(with: [(view: headlineBody, model: StackItemModel(horizontalAlignment: .fill)), (view: button, model: StackItemModel(spacing: spacingBetwenHeadlineBodyAndButton, horizontalAlignment: .leading))], axis: .vertical) stack = Stack<StackModel>.createStack(with: [(view: headlineBody, model: StackItemModel(horizontalAlignment: .fill)),
(view: button, model: StackItemModel(spacing: spacingBetwenHeadlineBodyAndButton, horizontalAlignment: .leading))],
axis: .vertical)
super.init(frame: frame) super.init(frame: frame)
} }
@ -31,26 +36,36 @@ import Foundation
//------------------------------------------------------ //------------------------------------------------------
// MARK: - Constants // MARK: - Constants
//------------------------------------------------------ //------------------------------------------------------
let spacingBetwenHeadlineBodyAndButton: CGFloat = 16.0 let spacingBetwenHeadlineBodyAndButton: CGFloat = 16.0
//------------------------------------------------------- //-------------------------------------------------------
// MARK: - View Lifecycle // MARK: - Lifecycle
//------------------------------------------------------- //-------------------------------------------------------
open override func setupView() { open override func setupView() {
super.setupView() super.setupView()
headlineBody.stylePageHeader() headlineBody.stylePageHeader()
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
isAccessibilityElement = true
accessibilityHint = button.accessibilityHint
accessibilityTraits = button.accessibilityTraits
updateAccessibilityLabel()
} }
//---------------------------------------------------- //----------------------------------------------------
// MARK: - Molecule // 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) super.set(with: model, delegateObject, additionalData)
guard let model = model as? HeadersH2TinyButtonModel else { return } guard let model = model as? HeadersH2TinyButtonModel else { return }
headlineBody.set(with: model.headlineBody, delegateObject, additionalData) headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
button.set(with: model.button, delegateObject, additionalData) button.set(with: model.button, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
@ -61,4 +76,31 @@ import Foundation
super.reset() super.reset()
headlineBody.stylePageHeader() headlineBody.stylePageHeader()
} }
//----------------------------------------------------
// MARK: - Accessibility
//----------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let headlineLabel = headlineBody.headlineLabel.text, !headlineLabel.isEmpty {
message += headlineLabel + ", "
}
if let bodyLabel = headlineBody.messageLabel.text, !bodyLabel.isEmpty {
message += bodyLabel + ", "
}
if let buttonLabel = button.accessibilityLabel {
message += buttonLabel
}
accessibilityLabel = message
}
open override func accessibilityActivate() -> Bool {
return button.accessibilityActivate()
}
} }

View File

@ -8,6 +8,7 @@
import Foundation import Foundation
public class HeadersH2TinyButtonModel: HeaderModel, MoleculeModelProtocol { public class HeadersH2TinyButtonModel: HeaderModel, MoleculeModelProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
@ -20,12 +21,17 @@ public class HeadersH2TinyButtonModel: HeaderModel, MoleculeModelProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Initializer // MARK: - Initializer
//-------------------------------------------------- //--------------------------------------------------
public init(headlineBody: HeadlineBodyModel, button: ButtonModel) { public init(headlineBody: HeadlineBodyModel, button: ButtonModel) {
self.headlineBody = headlineBody self.headlineBody = headlineBody
self.button = button self.button = button
super.init() super.init()
} }
//--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------
public override func setDefaults() { public override func setDefaults() {
super.setDefaults() super.setDefaults()
topPadding = PaddingDefaultVerticalSpacing3 topPadding = PaddingDefaultVerticalSpacing3
@ -37,6 +43,7 @@ public class HeadersH2TinyButtonModel: HeaderModel, MoleculeModelProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Keys // MARK: - Keys
//-------------------------------------------------- //--------------------------------------------------
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case headlineBody case headlineBody
@ -46,6 +53,7 @@ public class HeadersH2TinyButtonModel: HeaderModel, MoleculeModelProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Codec // MARK: - Codec
//-------------------------------------------------- //--------------------------------------------------
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)
headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody) headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody)

View File

@ -7,18 +7,26 @@
// //
import Foundation import Foundation
@objcMembers open class ListDeviceComplexButtonMedium: TableViewCell { @objcMembers open class ListDeviceComplexButtonMedium: TableViewCell {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var verticalStack: Stack<StackModel> public var verticalStack: Stack<StackModel>
public let eyebrow = Label.createLabelRegularMicro(true) public let eyebrow = Label.createLabelRegularMicro(true)
public let headline = Label.createLabelBoldTitleMedium(true) public let headline = Label.createLabelBoldTitleMedium(true)
public let body = Label.createLabelRegularBodySmall(true) public let body = Label.createLabelRegularBodySmall(true)
public let body2 = Label.createLabelRegularBodySmall(true) public let body2 = Label.createLabelRegularBodySmall(true)
public let button = PillButton(frame: .zero) public let button = PillButton()
public let rightImageView = LoadImageView() public let rightImageView = LoadImageView()
public var stack: Stack<StackModel> public var stack: Stack<StackModel>
//--------------------------------------------------
// MARK: - Initializers // MARK: - Initializers
//--------------------------------------------------
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
rightImageView.addSizeConstraintsForAspectRatio = true rightImageView.addSizeConstraintsForAspectRatio = true
rightImageView.imageView.contentMode = .scaleAspectFit rightImageView.imageView.contentMode = .scaleAspectFit
@ -40,26 +48,35 @@ import Foundation
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
// MARK: - MFViewProtocol //--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------
open override func setupView() { open override func setupView() {
super.setupView() super.setupView()
rightImageView.shouldNotifyDelegateOnUpdate = false rightImageView.shouldNotifyDelegateOnUpdate = false
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
verticalStack.restack() verticalStack.restack()
isAccessibilityElement = true
accessibilityTraits = button.accessibilityTraits
accessibilityHint = button.accessibilityHint
updateAccessibilityLabel()
} }
//--------------------------------------------------
// MARK: - ModelMoleculeViewProtocol // MARK: - ModelMoleculeViewProtocol
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? ListDeviceComplexButtonMediumModel else { return } guard let model = model as? ListDeviceComplexButtonMediumModel else { return }
verticalStack.updateContainedMolecules(with: [model.eyebrow,
model.headline, verticalStack.updateContainedMolecules(with: [model.eyebrow, model.headline, model.body, model.body2, model.button],
model.body,
model.body2,
model.button],
delegateObject, additionalData) delegateObject, additionalData)
rightImageView.set(with: model.image, delegateObject, additionalData) rightImageView.set(with: model.image, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
@ -78,4 +95,39 @@ import Foundation
super.reset() super.reset()
setDefault() setDefault()
} }
//--------------------------------------------------
// MARK: - Accessibility
//--------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let eyebrowText = eyebrow.text, !eyebrowText.isEmpty {
message += eyebrowText + ", "
}
if let headlineText = headline.text, !headlineText.isEmpty {
message += headlineText + ", "
}
if let bodyText = body.text, !bodyText.isEmpty {
message += bodyText + ", "
}
if let body2Text = body2.text, !body2Text.isEmpty {
message += body2Text + ", "
}
if let rightImageViewText = rightImageView.accessibilityLabel, !rightImageViewText.isEmpty {
message += rightImageViewText
}
accessibilityLabel = message
}
open override func accessibilityActivate() -> Bool {
return button.accessibilityActivate()
}
} }

View File

@ -7,7 +7,13 @@
// //
import Foundation import Foundation
public class ListDeviceComplexButtonMediumModel: ListItemModel, MoleculeModelProtocol { public class ListDeviceComplexButtonMediumModel: ListItemModel, MoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public static var identifier: String = "listDvcBtnM" public static var identifier: String = "listDvcBtnM"
public var eyebrow: LabelModel? public var eyebrow: LabelModel?
public var headline: LabelModel? public var headline: LabelModel?
@ -16,6 +22,10 @@ public class ListDeviceComplexButtonMediumModel: ListItemModel, MoleculeModelPro
public var button: ButtonModel public var button: ButtonModel
public var image: ImageViewModel public var image: ImageViewModel
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(eyebrow: LabelModel, headline:LabelModel, body: LabelModel, body2: LabelModel, button: ButtonModel, image: ImageViewModel) { public init(eyebrow: LabelModel, headline:LabelModel, body: LabelModel, body2: LabelModel, button: ButtonModel, image: ImageViewModel) {
self.eyebrow = eyebrow self.eyebrow = eyebrow
self.headline = headline self.headline = headline
@ -26,13 +36,20 @@ public class ListDeviceComplexButtonMediumModel: ListItemModel, MoleculeModelPro
super.init() super.init()
} }
/// Defaults to set //--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------
override public func setDefaults() { override public func setDefaults() {
super.setDefaults() super.setDefaults()
button.size = .tiny button.size = .tiny
button.style = .secondary button.style = .secondary
} }
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case eyebrow case eyebrow
@ -43,6 +60,10 @@ public class ListDeviceComplexButtonMediumModel: ListItemModel, MoleculeModelPro
case image case image
} }
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
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)

View File

@ -7,23 +7,31 @@
// //
import Foundation import Foundation
@objcMembers open class ListDeviceComplexButtonSmall: TableViewCell { @objcMembers open class ListDeviceComplexButtonSmall: TableViewCell {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var verticalStack: Stack<StackModel> public var verticalStack: Stack<StackModel>
public let eyebrow = Label.createLabelRegularMicro(true) public let eyebrow = Label.createLabelRegularMicro(true)
public let headline = Label.createLabelBoldTitleMedium(true) public let headline = Label.createLabelBoldTitleMedium(true)
public let body = Label.createLabelRegularBodySmall(true) public let body = Label.createLabelRegularBodySmall(true)
public let body2 = Label.createLabelRegularBodySmall(true) public let body2 = Label.createLabelRegularBodySmall(true)
public let button = PillButton(frame: .zero) public let button = PillButton()
public let rightImageView = LoadImageView() public let rightImageView = LoadImageView()
public var stack: Stack<StackModel> public var stack: Stack<StackModel>
//--------------------------------------------------
// MARK: - Initializers // MARK: - Initializers
//--------------------------------------------------
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
rightImageView.addSizeConstraintsForAspectRatio = true rightImageView.addSizeConstraintsForAspectRatio = true
rightImageView.imageView.contentMode = .scaleAspectFit rightImageView.imageView.contentMode = .scaleAspectFit
rightImageView.heightAnchor.constraint(equalToConstant: 71.0).isActive = true rightImageView.heightAnchor.constraint(equalToConstant: 71).isActive = true
rightImageView.widthAnchor.constraint(equalToConstant: 71.0).isActive = true rightImageView.widthAnchor.constraint(equalToConstant: 71).isActive = true
verticalStack = Stack<StackModel>.createStack(with: [(view: eyebrow, model: StackItemModel(horizontalAlignment: .leading)), verticalStack = Stack<StackModel>.createStack(with: [(view: eyebrow, model: StackItemModel(horizontalAlignment: .leading)),
(view: headline, model: StackItemModel(horizontalAlignment: .leading)), (view: headline, model: StackItemModel(horizontalAlignment: .leading)),
(view: body, model: StackItemModel(horizontalAlignment: .leading)), (view: body, model: StackItemModel(horizontalAlignment: .leading)),
@ -40,26 +48,35 @@ import Foundation
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
// MARK: - MFViewProtocol //--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------
open override func setupView() { open override func setupView() {
super.setupView() super.setupView()
rightImageView.shouldNotifyDelegateOnUpdate = false rightImageView.shouldNotifyDelegateOnUpdate = false
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
verticalStack.restack() verticalStack.restack()
isAccessibilityElement = true
accessibilityTraits = button.accessibilityTraits
accessibilityHint = button.accessibilityHint
updateAccessibilityLabel()
} }
//--------------------------------------------------
// MARK: - ModelMoleculeViewProtocol // MARK: - ModelMoleculeViewProtocol
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? ListDeviceComplexButtonSmallModel else { return } guard let model = model as? ListDeviceComplexButtonSmallModel else { return }
verticalStack.updateContainedMolecules(with: [model.eyebrow,
model.headline, verticalStack.updateContainedMolecules(with: [model.eyebrow, model.headline, model.body, model.body2, model.button],
model.body,
model.body2,
model.button],
delegateObject, additionalData) delegateObject, additionalData)
rightImageView.set(with: model.image, delegateObject, additionalData) rightImageView.set(with: model.image, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
@ -78,4 +95,39 @@ import Foundation
super.reset() super.reset()
setDefault() setDefault()
} }
//--------------------------------------------------
// MARK: - Accessibility
//--------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let eyebrowText = eyebrow.text, !eyebrowText.isEmpty {
message += eyebrowText + ", "
}
if let headlineText = headline.text, !headlineText.isEmpty {
message += headlineText + ", "
}
if let bodyText = body.text, !bodyText.isEmpty {
message += bodyText + ", "
}
if let body2Text = body2.text, !body2Text.isEmpty {
message += body2Text + ", "
}
if let rightImageViewText = rightImageView.accessibilityLabel, !rightImageViewText.isEmpty {
message += rightImageViewText
}
accessibilityLabel = message
}
open override func accessibilityActivate() -> Bool {
return button.accessibilityActivate()
}
} }

View File

@ -7,7 +7,13 @@
// //
import Foundation import Foundation
public class ListDeviceComplexButtonSmallModel: ListItemModel, MoleculeModelProtocol { public class ListDeviceComplexButtonSmallModel: ListItemModel, MoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public static var identifier: String = "listDvcBtnS" public static var identifier: String = "listDvcBtnS"
public var eyebrow: LabelModel? public var eyebrow: LabelModel?
public var headline: LabelModel? public var headline: LabelModel?
@ -16,6 +22,10 @@ public class ListDeviceComplexButtonSmallModel: ListItemModel, MoleculeModelProt
public var button: ButtonModel public var button: ButtonModel
public var image: ImageViewModel public var image: ImageViewModel
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(eyebrow: LabelModel, headline:LabelModel, body: LabelModel, body2: LabelModel, button: ButtonModel, image: ImageViewModel) { public init(eyebrow: LabelModel, headline:LabelModel, body: LabelModel, body2: LabelModel, button: ButtonModel, image: ImageViewModel) {
self.eyebrow = eyebrow self.eyebrow = eyebrow
self.headline = headline self.headline = headline
@ -26,13 +36,20 @@ public class ListDeviceComplexButtonSmallModel: ListItemModel, MoleculeModelProt
super.init() super.init()
} }
/// Defaults to set //--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------
override public func setDefaults() { override public func setDefaults() {
super.setDefaults() super.setDefaults()
button.size = .tiny button.size = .tiny
button.style = .secondary button.style = .secondary
} }
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case eyebrow case eyebrow
@ -43,6 +60,10 @@ public class ListDeviceComplexButtonSmallModel: ListItemModel, MoleculeModelProt
case image case image
} }
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
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)

View File

@ -7,11 +7,13 @@
// //
import Foundation import Foundation
@objcMembers open class ListDeviceComplexLinkMedium: TableViewCell { @objcMembers open class ListDeviceComplexLinkMedium: TableViewCell {
//----------------------------------------------------- //-----------------------------------------------------
// MARK: - Outlets // MARK: - Outlets
//----------------------------------------------------- //-----------------------------------------------------
public let eyebrow = Label.createLabelRegularMicro(true) public let eyebrow = Label.createLabelRegularMicro(true)
public let headline = Label.createLabelBoldTitleMedium(true) public let headline = Label.createLabelBoldTitleMedium(true)
public let body = Label.createLabelRegularBodySmall(true) public let body = Label.createLabelRegularBodySmall(true)
@ -20,16 +22,22 @@ import Foundation
public let rightImage = LoadImageView() public let rightImage = LoadImageView()
let verticalStack: Stack<StackModel> let verticalStack: Stack<StackModel>
public let stack: Stack<StackModel> public let stack: Stack<StackModel>
//------------------------------------------------------ //------------------------------------------------------
// MARK: - Initializers // MARK: - Initializers
//------------------------------------------------------ //------------------------------------------------------
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
rightImage.addSizeConstraintsForAspectRatio = true rightImage.addSizeConstraintsForAspectRatio = true
rightImage.imageView.contentMode = .scaleAspectFit rightImage.imageView.contentMode = .scaleAspectFit
rightImage.heightAnchor.constraint(equalToConstant: 116.0).isActive = true rightImage.heightAnchor.constraint(equalToConstant: 116.0).isActive = true
rightImage.widthAnchor.constraint(equalToConstant: 116.0).isActive = true rightImage.widthAnchor.constraint(equalToConstant: 116.0).isActive = true
verticalStack = Stack<StackModel>.createStack(with: [(view: eyebrow, model: StackItemModel(horizontalAlignment: .leading)), (view: headline, model: StackItemModel(horizontalAlignment: .leading)), (view: body, model: StackItemModel(horizontalAlignment: .leading)), (view: body2, model: StackItemModel(horizontalAlignment: .leading)), (view: twoLinkView, model: StackItemModel(spacing: 16, horizontalAlignment: .leading))], axis: .vertical, spacing: 0) verticalStack = Stack<StackModel>.createStack(with: [(view: eyebrow, model: StackItemModel(horizontalAlignment: .leading)),
(view: headline, model: StackItemModel(horizontalAlignment: .leading)),
(view: body, model: StackItemModel(horizontalAlignment: .leading)),
(view: body2, model: StackItemModel(horizontalAlignment: .leading)),
(view: twoLinkView, model: StackItemModel(spacing: 16, horizontalAlignment: .leading))],
axis: .vertical, spacing: 0)
stack = Stack<StackModel>.createStack(with: [(view: verticalStack, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .leading)), stack = Stack<StackModel>.createStack(with: [(view: verticalStack, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .leading)),
(view: rightImage, model: StackItemModel(verticalAlignment: .center))], (view: rightImage, model: StackItemModel(verticalAlignment: .center))],
@ -42,24 +50,31 @@ import Foundation
} }
//----------------------------------------------------- //-----------------------------------------------------
// MARK: - View Lifecycle // MARK: - Lifecycle
//----------------------------------------------------- //-----------------------------------------------------
open override func setupView() { open override func setupView() {
super.setupView() super.setupView()
rightImage.shouldNotifyDelegateOnUpdate = false rightImage.shouldNotifyDelegateOnUpdate = false
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
verticalStack.restack() verticalStack.restack()
updateAccessibilityLabel()
} }
//------------------------------------------------------ //------------------------------------------------------
// MARK: - Molecule // 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) super.set(with: model, delegateObject, additionalData)
guard let model = model as? ListDeviceComplexLinkMediumModel else { return } guard let model = model as? ListDeviceComplexLinkMediumModel else { return }
verticalStack.updateContainedMolecules(with: [model.eyebrow, model.headline, model.body, model.body2, model.twoLinkView], delegateObject, additionalData) verticalStack.updateContainedMolecules(with: [model.eyebrow, model.headline, model.body, model.body2, model.twoLinkView], delegateObject, additionalData)
rightImage.set(with: model.image, delegateObject, additionalData) rightImage.set(with: model.image, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
@ -74,4 +89,91 @@ import Foundation
body2.styleRegularBodySmall(true) body2.styleRegularBodySmall(true)
eyebrow.textColor = .mvmCoolGray6 eyebrow.textColor = .mvmCoolGray6
} }
//--------------------------------------------------
// MARK: - Accessibility
//--------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let eyebrowText = eyebrow.text, !eyebrowText.isEmpty {
message += eyebrowText + ", "
}
if let headlineText = headline.text, !headlineText.isEmpty {
message += headlineText + ", "
}
if let bodyText = body.text, !bodyText.isEmpty {
message += bodyText + ", "
}
if let body2Text = body2.text, !body2Text.isEmpty {
message += body2Text + ", "
}
if let rightImageLabel = rightImage.accessibilityLabel {
message += rightImageLabel
}
let leftLinkIsDisplayed = !twoLinkView.leftLink.isHidden
let rightLinkIsDisplayed = !twoLinkView.rightLink.isHidden
// Both links are displayed
if leftLinkIsDisplayed && rightLinkIsDisplayed {
isAccessibilityElement = false
var views = [UIView]()
if let eyebrowText = eyebrow.text, !eyebrowText.isEmpty {
views.append(eyebrow)
}
if let headlineText = headline.text, !headlineText.isEmpty {
views.append(headline)
}
if let bodyText = body.text, !bodyText.isEmpty {
views.append(body)
}
if let body2Text = body2.text, !body2Text.isEmpty {
views.append(body2)
}
views.append(twoLinkView.leftLink)
views.append(twoLinkView.rightLink)
accessibilityElements = views
return
} else if leftLinkIsDisplayed {
accessibilityHint = twoLinkView.leftLink.accessibilityHint
accessibilityTraits = twoLinkView.leftLink.accessibilityTraits
message += twoLinkView.leftLink.accessibilityLabel ?? ""
} else if rightLinkIsDisplayed {
accessibilityHint = twoLinkView.rightLink.accessibilityHint
accessibilityTraits = twoLinkView.rightLink.accessibilityTraits
message += twoLinkView.rightLink.accessibilityLabel ?? ""
}
isAccessibilityElement = true
accessibilityLabel = message
}
open override func accessibilityActivate() -> Bool {
if isAccessibilityElement {
if !twoLinkView.leftLink.isHidden {
return twoLinkView.leftLink.accessibilityActivate()
} else if !twoLinkView.rightLink.isHidden {
return twoLinkView.rightLink.accessibilityActivate()
}
}
return false
}
} }

View File

@ -7,7 +7,13 @@
// //
import Foundation import Foundation
public class ListDeviceComplexLinkMediumModel: ListItemModel, MoleculeModelProtocol { public class ListDeviceComplexLinkMediumModel: ListItemModel, MoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public static var identifier: String = "listDvcLnkM" public static var identifier: String = "listDvcLnkM"
public var eyebrow: LabelModel? public var eyebrow: LabelModel?
public var headline: LabelModel? public var headline: LabelModel?
@ -16,6 +22,10 @@ public class ListDeviceComplexLinkMediumModel: ListItemModel, MoleculeModelProto
public var twoLinkView: TwoLinkViewModel public var twoLinkView: TwoLinkViewModel
public var image: ImageViewModel public var image: ImageViewModel
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(eyebrow: LabelModel, headline: LabelModel, body: LabelModel, body2: LabelModel, twoLinkView: TwoLinkViewModel, image: ImageViewModel) { public init(eyebrow: LabelModel, headline: LabelModel, body: LabelModel, body2: LabelModel, twoLinkView: TwoLinkViewModel, image: ImageViewModel) {
self.eyebrow = eyebrow self.eyebrow = eyebrow
self.headline = headline self.headline = headline
@ -26,6 +36,10 @@ public class ListDeviceComplexLinkMediumModel: ListItemModel, MoleculeModelProto
super.init() super.init()
} }
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case eyebrow case eyebrow
@ -36,6 +50,10 @@ public class ListDeviceComplexLinkMediumModel: ListItemModel, MoleculeModelProto
case image case image
} }
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
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)

View File

@ -7,11 +7,13 @@
// //
import Foundation import Foundation
@objcMembers open class ListDeviceComplexLinkSmall: TableViewCell { @objcMembers open class ListDeviceComplexLinkSmall: TableViewCell {
//----------------------------------------------------- //-----------------------------------------------------
// MARK: - Outlets // MARK: - Outlets
//----------------------------------------------------- //-----------------------------------------------------
public let eyebrow = Label.createLabelRegularMicro(true) public let eyebrow = Label.createLabelRegularMicro(true)
public let headline = Label.createLabelBoldTitleMedium(true) public let headline = Label.createLabelBoldTitleMedium(true)
public let body = Label.createLabelRegularBodySmall(true) public let body = Label.createLabelRegularBodySmall(true)
@ -24,12 +26,18 @@ import Foundation
//------------------------------------------------------ //------------------------------------------------------
// MARK: - Initializers // MARK: - Initializers
//------------------------------------------------------ //------------------------------------------------------
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
rightImage.addSizeConstraintsForAspectRatio = true rightImage.addSizeConstraintsForAspectRatio = true
rightImage.imageView.contentMode = .scaleAspectFit rightImage.imageView.contentMode = .scaleAspectFit
rightImage.heightAnchor.constraint(equalToConstant: 71.0).isActive = true rightImage.heightAnchor.constraint(equalToConstant: 71).isActive = true
rightImage.widthAnchor.constraint(equalToConstant: 71.0).isActive = true rightImage.widthAnchor.constraint(equalToConstant: 71).isActive = true
verticalStack = Stack<StackModel>.createStack(with: [(view: eyebrow, model: StackItemModel(horizontalAlignment: .leading)), (view: headline, model: StackItemModel(horizontalAlignment: .leading)), (view: body, model: StackItemModel(horizontalAlignment: .leading)), (view: body2, model: StackItemModel(horizontalAlignment: .leading)), (view: twoLinkView, model: StackItemModel(spacing: 16, horizontalAlignment: .leading))], axis: .vertical, spacing: 0) verticalStack = Stack<StackModel>.createStack(with: [(view: eyebrow, model: StackItemModel(horizontalAlignment: .leading)),
(view: headline, model: StackItemModel(horizontalAlignment: .leading)),
(view: body, model: StackItemModel(horizontalAlignment: .leading)),
(view: body2, model: StackItemModel(horizontalAlignment: .leading)),
(view: twoLinkView, model: StackItemModel(spacing: 16, horizontalAlignment: .leading))],
axis: .vertical, spacing: 0)
stack = Stack<StackModel>.createStack(with: [(view: verticalStack, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .leading)), stack = Stack<StackModel>.createStack(with: [(view: verticalStack, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .leading)),
(view: rightImage, model: StackItemModel(verticalAlignment: .center))], (view: rightImage, model: StackItemModel(verticalAlignment: .center))],
@ -42,24 +50,29 @@ import Foundation
} }
//----------------------------------------------------- //-----------------------------------------------------
// MARK: - View Lifecycle // MARK: - Lifecycle
//----------------------------------------------------- //-----------------------------------------------------
open override func setupView() { open override func setupView() {
super.setupView() super.setupView()
rightImage.shouldNotifyDelegateOnUpdate = false rightImage.shouldNotifyDelegateOnUpdate = false
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
verticalStack.restack() verticalStack.restack()
updateAccessibilityLabel()
} }
//------------------------------------------------------ //------------------------------------------------------
// MARK: - Molecule // 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) super.set(with: model, delegateObject, additionalData)
guard let model = model as? ListDeviceComplexLinkSmallModel else { return } guard let model = model as? ListDeviceComplexLinkSmallModel else { return }
verticalStack.updateContainedMolecules(with: [model.eyebrow, model.headline, model.body, model.body2, model.twoLinkView], delegateObject, additionalData) verticalStack.updateContainedMolecules(with: [model.eyebrow, model.headline, model.body, model.body2, model.twoLinkView], delegateObject, additionalData)
rightImage.set(with: model.image, delegateObject, additionalData) rightImage.set(with: model.image, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
@ -74,4 +87,91 @@ import Foundation
body2.styleRegularBodySmall(true) body2.styleRegularBodySmall(true)
eyebrow.textColor = .mvmCoolGray6 eyebrow.textColor = .mvmCoolGray6
} }
//--------------------------------------------------
// MARK: - Accessibility
//--------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let eyebrowText = eyebrow.text, !eyebrowText.isEmpty {
message += eyebrowText + ", "
}
if let headlineText = headline.text, !headlineText.isEmpty {
message += headlineText + ", "
}
if let bodyText = body.text, !bodyText.isEmpty {
message += bodyText + ", "
}
if let body2Text = body2.text, !body2Text.isEmpty {
message += body2Text + ", "
}
if let rightImageLabel = rightImage.accessibilityLabel {
message += rightImageLabel
}
let leftLinkIsDisplayed = !twoLinkView.leftLink.isHidden
let rightLinkIsDisplayed = !twoLinkView.rightLink.isHidden
// Both links are displayed
if leftLinkIsDisplayed && rightLinkIsDisplayed {
isAccessibilityElement = false
var views = [UIView]()
if let eyebrowText = eyebrow.text, !eyebrowText.isEmpty {
views.append(eyebrow)
}
if let headlineText = headline.text, !headlineText.isEmpty {
views.append(headline)
}
if let bodyText = body.text, !bodyText.isEmpty {
views.append(body)
}
if let body2Text = body2.text, !body2Text.isEmpty {
views.append(body2)
}
views.append(twoLinkView.leftLink)
views.append(twoLinkView.rightLink)
accessibilityElements = views
return
} else if leftLinkIsDisplayed {
accessibilityHint = twoLinkView.leftLink.accessibilityHint
accessibilityTraits = twoLinkView.leftLink.accessibilityTraits
message += twoLinkView.leftLink.accessibilityLabel ?? ""
} else if rightLinkIsDisplayed {
accessibilityHint = twoLinkView.rightLink.accessibilityHint
accessibilityTraits = twoLinkView.rightLink.accessibilityTraits
message += twoLinkView.rightLink.accessibilityLabel ?? ""
}
isAccessibilityElement = true
accessibilityLabel = message
}
open override func accessibilityActivate() -> Bool {
if isAccessibilityElement {
if !twoLinkView.leftLink.isHidden {
return twoLinkView.leftLink.accessibilityActivate()
} else if !twoLinkView.rightLink.isHidden {
return twoLinkView.rightLink.accessibilityActivate()
}
}
return false
}
} }

View File

@ -7,7 +7,13 @@
// //
import Foundation import Foundation
public class ListDeviceComplexLinkSmallModel: ListItemModel, MoleculeModelProtocol { public class ListDeviceComplexLinkSmallModel: ListItemModel, MoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public static var identifier: String = "listDvcLnkS" public static var identifier: String = "listDvcLnkS"
public var eyebrow: LabelModel? public var eyebrow: LabelModel?
public var headline: LabelModel? public var headline: LabelModel?
@ -16,6 +22,10 @@ public class ListDeviceComplexLinkSmallModel: ListItemModel, MoleculeModelProtoc
public var twoLinkView: TwoLinkViewModel public var twoLinkView: TwoLinkViewModel
public var image: ImageViewModel public var image: ImageViewModel
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(eyebrow: LabelModel, headline: LabelModel, body: LabelModel, body2: LabelModel, twoLinkView: TwoLinkViewModel, image: ImageViewModel) { public init(eyebrow: LabelModel, headline: LabelModel, body: LabelModel, body2: LabelModel, twoLinkView: TwoLinkViewModel, image: ImageViewModel) {
self.eyebrow = eyebrow self.eyebrow = eyebrow
self.headline = headline self.headline = headline
@ -26,6 +36,10 @@ public class ListDeviceComplexLinkSmallModel: ListItemModel, MoleculeModelProtoc
super.init() super.init()
} }
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case eyebrow case eyebrow
@ -36,6 +50,10 @@ public class ListDeviceComplexLinkSmallModel: ListItemModel, MoleculeModelProtoc
case image case image
} }
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
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)

View File

@ -8,32 +8,34 @@
import Foundation import Foundation
@objcMembers public class ListFourColumnDataUsageListItem: TableViewCell { @objcMembers public class ListFourColumnDataUsageListItem: TableViewCell {
//----------------------------------------------------- //-----------------------------------------------------
// MARK: - Outlets // MARK: - Outlets
//----------------------------------------------------- //-----------------------------------------------------
var stack: Stack<StackModel> var stack: Stack<StackModel>
let label1 = Label.createLabelRegularBodySmall(true) let label1 = Label.createLabelRegularBodySmall(true)
let label2 = Label.createLabelRegularBodySmall(true) let label2 = Label.createLabelRegularBodySmall(true)
let label3 = Label.createLabelRegularBodySmall(true) let label3 = Label.createLabelRegularBodySmall(true)
let label4 = Label.createLabelRegularBodySmall(true) let label4 = Label.createLabelRegularBodySmall(true)
let arrow = Arrow(frame: .zero) let arrow = Arrow()
let arrowAndLabel2Stack: Stack<StackModel> let arrowAndLabel2Stack: Stack<StackModel>
//----------------------------------------------------- //-----------------------------------------------------
// MARK: - Initializers // MARK: - Initializers
//----------------------------------------------------- //-----------------------------------------------------
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
arrowAndLabel2Stack = Stack<StackModel>.createStack(with: [(view: arrow, model: StackItemModel(horizontalAlignment: .fill)), arrowAndLabel2Stack = Stack<StackModel>.createStack(with: [(view: arrow, model: StackItemModel(horizontalAlignment: .fill)),
(view: label2, model: StackItemModel(horizontalAlignment: .leading))], (view: label2, model: StackItemModel(horizontalAlignment: .leading))],
axis: .horizontal, spacing: 4) axis: .horizontal, spacing: 4)
label2.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) label2.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
label2.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) label2.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal)
stack = Stack<StackModel>.createStack(with: [(view: label1, model: StackItemModel(percent: 19, horizontalAlignment: .leading)), stack = Stack<StackModel>.createStack(with: [(view: label1, model: StackItemModel(percent: 19, horizontalAlignment: .leading)),
(view: arrowAndLabel2Stack, model: StackItemModel(percent: 44, horizontalAlignment: .fill)), (view: arrowAndLabel2Stack, model: StackItemModel(percent: 44, horizontalAlignment: .fill)),
(view: label3, model: StackItemModel(percent:17,horizontalAlignment: .leading)), (view: label3, model: StackItemModel(percent:17, horizontalAlignment: .leading)),
(view: label4, model: StackItemModel(percent:20,horizontalAlignment: .leading))], (view: label4, model: StackItemModel(percent:20, horizontalAlignment: .leading))],
axis: .horizontal,spacing: 8) axis: .horizontal,spacing: 8)
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)
} }
@ -43,24 +45,34 @@ import Foundation
} }
//----------------------------------------------------- //-----------------------------------------------------
// MARK: - View Lifecycle // MARK: - Lifecycle
//----------------------------------------------------- //-----------------------------------------------------
override open func setupView() { override open func setupView() {
super.setupView() super.setupView()
addMolecule(stack) addMolecule(stack)
arrow.pinHeightAndWidth() arrow.pinHeightAndWidth()
arrowAndLabel2Stack.restack() arrowAndLabel2Stack.restack()
stack.restack() stack.restack()
isAccessibilityElement = true
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) super.set(with: model, delegateObject, additionalData)
guard let model = model as? ListFourColumnDataUsageListItemModel else { return } guard let model = model as? ListFourColumnDataUsageListItemModel else { return }
label1.set(with: model.label1, delegateObject, additionalData) label1.set(with: model.label1, delegateObject, additionalData)
label2.set(with: model.label2, delegateObject, additionalData) label2.set(with: model.label2, delegateObject, additionalData)
label3.set(with: model.label3, delegateObject, additionalData) label3.set(with: model.label3, delegateObject, additionalData)
label4.set(with: model.label4, delegateObject, additionalData) label4.set(with: model.label4, delegateObject, additionalData)
arrow.set(with: model.arrow, delegateObject, additionalData) arrow.set(with: model.arrow, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
@ -74,4 +86,31 @@ import Foundation
label3.styleRegularBodySmall(true) label3.styleRegularBodySmall(true)
label4.styleRegularBodySmall(true) label4.styleRegularBodySmall(true)
} }
//-----------------------------------------------------
// MARK: - Accessibility
//-----------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let label1Text = label1.text, !label1Text.isEmpty {
message += label1Text + ", "
}
if let label2Text = label2.text, !label2Text.isEmpty {
message += label2Text + ", "
}
if let label3Text = label3.text, !label3Text.isEmpty {
message += label3Text + ", "
}
if let label4Text = label4.text, !label4Text.isEmpty {
message += label4Text
}
accessibilityLabel = message
}
} }

View File

@ -8,7 +8,12 @@
import Foundation import Foundation
public class ListFourColumnDataUsageListItemModel: ListItemModel, MoleculeModelProtocol { public class ListFourColumnDataUsageListItemModel: ListItemModel, MoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public static var identifier: String = "list4C" public static var identifier: String = "list4C"
public var label1: LabelModel public var label1: LabelModel
public var arrow: ArrowModel public var arrow: ArrowModel
@ -16,6 +21,10 @@ public class ListFourColumnDataUsageListItemModel: ListItemModel, MoleculeModelP
public var label3: LabelModel public var label3: LabelModel
public var label4: LabelModel public var label4: LabelModel
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(label1:LabelModel, label2:LabelModel, label3:LabelModel,label4:LabelModel, arrow:ArrowModel) { public init(label1:LabelModel, label2:LabelModel, label3:LabelModel,label4:LabelModel, arrow:ArrowModel) {
self.label1 = label1 self.label1 = label1
self.label2 = label2 self.label2 = label2
@ -25,6 +34,10 @@ public class ListFourColumnDataUsageListItemModel: ListItemModel, MoleculeModelP
super.init() super.init()
} }
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case label1 case label1
@ -34,6 +47,10 @@ public class ListFourColumnDataUsageListItemModel: ListItemModel, MoleculeModelP
case arrow case arrow
} }
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
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)
label1 = try typeContainer.decode(LabelModel.self, forKey: .label1) label1 = try typeContainer.decode(LabelModel.self, forKey: .label1)

View File

@ -22,6 +22,7 @@ import Foundation
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Initializers // MARK: - Initializers
//-------------------------------------------------- //--------------------------------------------------
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
stack = Stack<StackModel>.createStack(with: [(view: leftImage, model: StackItemModel(horizontalAlignment: .fill)), stack = Stack<StackModel>.createStack(with: [(view: leftImage, model: StackItemModel(horizontalAlignment: .fill)),
(view: headlineBody, model: StackItemModel(horizontalAlignment: .leading)), (view: headlineBody, model: StackItemModel(horizontalAlignment: .leading)),
@ -75,6 +76,10 @@ import Foundation
rightLabel.styleRegularBodySmall(true) rightLabel.styleRegularBodySmall(true)
} }
//--------------------------------------------------
// MARK: - Accessibility
//--------------------------------------------------
func updateAccessibilityLabel() { func updateAccessibilityLabel() {
var message = "" var message = ""

View File

@ -78,6 +78,10 @@ import Foundation
eyebrowHeadlineBodyLink.body.preferredMaxLayoutWidth = eyebrowHeadlineBodyLink.frame.width eyebrowHeadlineBodyLink.body.preferredMaxLayoutWidth = eyebrowHeadlineBodyLink.frame.width
} }
//--------------------------------------------------
// MARK: - Accessibility
//--------------------------------------------------
func updateAccessibilityLabel() { func updateAccessibilityLabel() {
var message = "" var message = ""

View File

@ -46,7 +46,7 @@ import Foundation
accessibilityTraits = radioButton.accessibilityTraits accessibilityTraits = radioButton.accessibilityTraits
accessibilityHint = radioButton.accessibilityHint accessibilityHint = radioButton.accessibilityHint
updateAccessibilityLabel()
// Update accessibility label on radio button state change. // Update accessibility label on radio button state change.
observation = observe(\.radioButton.isSelected, options: [.new]) { [weak self] _, _ in observation = observe(\.radioButton.isSelected, options: [.new]) { [weak self] _, _ in
self?.updateAccessibilityLabel() self?.updateAccessibilityLabel()
@ -59,7 +59,9 @@ import Foundation
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? ListLeftVariableRadioButtonAllTextAndLinksModel else { return}
guard let model = model as? ListLeftVariableRadioButtonAllTextAndLinksModel else { return }
radioButton.set(with: model.radioButton, delegateObject, additionalData) radioButton.set(with: model.radioButton, delegateObject, additionalData)
eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData)
updateAccessibilityLabel() updateAccessibilityLabel()
@ -73,6 +75,10 @@ import Foundation
radioButton.tapAction() radioButton.tapAction()
} }
//--------------------------------------------------
// MARK: - Accessibility
//--------------------------------------------------
func updateAccessibilityLabel() { func updateAccessibilityLabel() {
var message = "" var message = ""

View File

@ -89,6 +89,10 @@ import UIKit
radioButton.tapAction() radioButton.tapAction()
} }
//--------------------------------------------------
// MARK: - Accessibility
//--------------------------------------------------
func updateAccessibilityLabel() { func updateAccessibilityLabel() {
var message = "" var message = ""

View File

@ -80,6 +80,10 @@ open class ListLeftVariableRadioButtonBodyText: TableViewCell {
radioButton.tapAction() radioButton.tapAction()
} }
//--------------------------------------------------
// MARK: - Accessibility
//--------------------------------------------------
func updateAccessibilityLabel() { func updateAccessibilityLabel() {
var message = "" var message = ""

View File

@ -68,6 +68,10 @@ import Foundation
body.styleRegularBodySmall(true) body.styleRegularBodySmall(true)
} }
//--------------------------------------------------
// MARK: - Accessibility
//--------------------------------------------------
func updateAccessibilityLabel() { func updateAccessibilityLabel() {
var message = "" var message = ""

View File

@ -64,9 +64,7 @@ import Foundation
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal)
rightLabel.numberOfLines = 1 rightLabel.numberOfLines = 1
arrow.pinHeightAndWidth() arrow.pinHeightAndWidth()
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
updateAccessibilityLabel() updateAccessibilityLabel()

View File

@ -8,11 +8,12 @@
import Foundation import Foundation
@objcMembers open class ListThreeColumnDataUsage: TableViewCell { @objcMembers open class ListThreeColumnDataUsage: TableViewCell {
//----------------------------------------------------- //-----------------------------------------------------
// MARK: - Outlets // MARK: - Outlets
//------------------------------------------------------- //-----------------------------------------------------
public let leftLabel = Label.createLabelRegularBodySmall(true) public let leftLabel = Label.createLabelRegularBodySmall(true)
public let centerLabel = Label.createLabelRegularBodySmall(true) public let centerLabel = Label.createLabelRegularBodySmall(true)
public let rightLabel = Label.createLabelRegularBodySmall(true) public let rightLabel = Label.createLabelRegularBodySmall(true)
@ -21,6 +22,7 @@ import Foundation
//------------------------------------------------------ //------------------------------------------------------
// MARK: - Initializers // MARK: - Initializers
//------------------------------------------------------ //------------------------------------------------------
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
stack = Stack<StackModel>.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 40, horizontalAlignment: .leading)), stack = Stack<StackModel>.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 40, horizontalAlignment: .leading)),
(view: centerLabel, model: StackItemModel(percent: 37, horizontalAlignment: .leading)), (view: centerLabel, model: StackItemModel(percent: 37, horizontalAlignment: .leading)),
@ -33,24 +35,36 @@ import Foundation
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
//------------------------------------------------------
// MARK: - Lifecycle
//------------------------------------------------------
open override func setupView() { open override func setupView() {
super.setupView() super.setupView()
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
} isAccessibilityElement = true
updateAccessibilityLabel()
// 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? ListThreeColumnDataUsageModel else { return } // MARK: - ModelMoleculeViewProtocol
leftLabel.set(with: model.leftLabel, delegateObject, additionalData) //--------------------------------------------------
centerLabel.set(with: model.centerLabel, delegateObject, additionalData)
rightLabel.set(with: model.rightLabel, delegateObject, additionalData) open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
} super.set(with: model, delegateObject, additionalData)
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { guard let model = model as? ListThreeColumnDataUsageModel else { return }
return 121
} 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() { open override func reset() {
super.reset() super.reset()
@ -58,4 +72,27 @@ import Foundation
centerLabel.styleRegularBodySmall(true) centerLabel.styleRegularBodySmall(true)
rightLabel.styleRegularBodySmall(true) rightLabel.styleRegularBodySmall(true)
} }
//--------------------------------------------------
// MARK: - Accessibility
//--------------------------------------------------
func updateAccessibilityLabel() {
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
}
} }

View File

@ -8,12 +8,21 @@
import Foundation import Foundation
public class ListThreeColumnDataUsageModel: ListItemModel, MoleculeModelProtocol { public class ListThreeColumnDataUsageModel: ListItemModel, MoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public static var identifier: String = "list3CDataUsg" public static var identifier: String = "list3CDataUsg"
public var leftLabel: LabelModel public var leftLabel: LabelModel
public var centerLabel: LabelModel public var centerLabel: LabelModel
public var rightLabel: LabelModel public var rightLabel: LabelModel
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(leftLabel:LabelModel, centerLabel:LabelModel, rightLabel:LabelModel) { public init(leftLabel:LabelModel, centerLabel:LabelModel, rightLabel:LabelModel) {
self.leftLabel = leftLabel self.leftLabel = leftLabel
self.centerLabel = centerLabel self.centerLabel = centerLabel
@ -21,6 +30,10 @@ public class ListThreeColumnDataUsageModel: ListItemModel, MoleculeModelProtocol
super.init() super.init()
} }
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case leftLabel case leftLabel
@ -28,6 +41,10 @@ public class ListThreeColumnDataUsageModel: ListItemModel, MoleculeModelProtocol
case rightLabel case rightLabel
} }
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
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)
leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel)
@ -45,4 +62,3 @@ public class ListThreeColumnDataUsageModel: ListItemModel, MoleculeModelProtocol
try container.encode(rightLabel, forKey: .rightLabel) try container.encode(rightLabel, forKey: .rightLabel)
} }
} }

View File

@ -8,24 +8,28 @@
import Foundation import Foundation
@objcMembers public class ListThreeColumnInternationalData: TableViewCell { @objcMembers public class ListThreeColumnInternationalData: TableViewCell {
//----------------------------------------------------- //-----------------------------------------------------
// MARK: - Outlets // MARK: - Outlets
//----------------------------------------------------- //-----------------------------------------------------
open var stack: Stack<StackModel> open var stack: Stack<StackModel>
public let leftLabel = Label.createLabelRegularBodySmall(true) public let leftLabel = Label.createLabelRegularBodySmall(true)
public let centerLabel = Label.createLabelRegularBodySmall(true) public let centerLabel = Label.createLabelRegularBodySmall(true)
public let rightLabel = Label.createLabelRegularBodySmall(true) public let rightLabel = Label.createLabelRegularBodySmall(true)
public let arrow = Arrow(frame: .zero) public let arrow = Arrow()
public let arrowAndLabel2Stack: Stack<StackModel> public let arrowAndLabel2Stack: Stack<StackModel>
//----------------------------------------------------- //-----------------------------------------------------
// MARK: - Initializers // MARK: - Initializers
//----------------------------------------------------- //-----------------------------------------------------
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
arrowAndLabel2Stack = Stack<StackModel>.createStack(with: [(view: arrow, model: StackItemModel(horizontalAlignment: .fill)), arrowAndLabel2Stack = Stack<StackModel>.createStack(with: [(view: arrow, model: StackItemModel(horizontalAlignment: .fill)),
(view: centerLabel, model: StackItemModel(horizontalAlignment: .leading))], (view: centerLabel, model: StackItemModel(horizontalAlignment: .leading))],
axis: .horizontal, spacing: 4) axis: .horizontal, spacing: 4)
centerLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) centerLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
centerLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) centerLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal)
@ -41,23 +45,30 @@ import Foundation
} }
//----------------------------------------------------- //-----------------------------------------------------
// MARK: - View Lifecycle // MARK: - Lifecycle
//----------------------------------------------------- //-----------------------------------------------------
override open func setupView() { override open func setupView() {
super.setupView() super.setupView()
addMolecule(stack) addMolecule(stack)
arrow.pinHeightAndWidth() arrow.pinHeightAndWidth()
arrowAndLabel2Stack.restack() arrowAndLabel2Stack.restack()
stack.restack() stack.restack()
isAccessibilityElement = true
updateAccessibilityLabel()
} }
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? ListThreeColumnInternationalDataModel else { return } guard let model = model as? ListThreeColumnInternationalDataModel else { return }
leftLabel.set(with: model.leftLabel, delegateObject, additionalData) leftLabel.set(with: model.leftLabel, delegateObject, additionalData)
centerLabel.set(with: model.centerLabel, delegateObject, additionalData) centerLabel.set(with: model.centerLabel, delegateObject, additionalData)
rightLabel.set(with: model.rightLabel, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData)
arrow.set(with: model.arrow, delegateObject, additionalData) arrow.set(with: model.arrow, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
@ -70,4 +81,27 @@ import Foundation
centerLabel.styleRegularBodySmall(true) centerLabel.styleRegularBodySmall(true)
rightLabel.styleRegularBodySmall(true) rightLabel.styleRegularBodySmall(true)
} }
//--------------------------------------------------
// MARK: - Accessibility
//--------------------------------------------------
func updateAccessibilityLabel() {
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
}
} }

View File

@ -8,13 +8,22 @@
import Foundation import Foundation
public class ListThreeColumnInternationalDataModel: ListItemModel, MoleculeModelProtocol { public class ListThreeColumnInternationalDataModel: ListItemModel, MoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public static var identifier: String = "list3CIntData" public static var identifier: String = "list3CIntData"
public var leftLabel: LabelModel public var leftLabel: LabelModel
public var centerLabel: LabelModel public var centerLabel: LabelModel
public var rightLabel: LabelModel public var rightLabel: LabelModel
public var arrow: ArrowModel public var arrow: ArrowModel
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(leftLabel:LabelModel, centerLabel:LabelModel, rightLabel:LabelModel, arrow:ArrowModel) { public init(leftLabel:LabelModel, centerLabel:LabelModel, rightLabel:LabelModel, arrow:ArrowModel) {
self.leftLabel = leftLabel self.leftLabel = leftLabel
self.centerLabel = centerLabel self.centerLabel = centerLabel
@ -23,6 +32,10 @@ public class ListThreeColumnInternationalDataModel: ListItemModel, MoleculeModel
super.init() super.init()
} }
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case leftLabel case leftLabel
@ -31,6 +44,10 @@ public class ListThreeColumnInternationalDataModel: ListItemModel, MoleculeModel
case arrow case arrow
} }
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
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)
leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel)

View File

@ -45,6 +45,8 @@ import Foundation
super.setupView() super.setupView()
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
isAccessibilityElement = true
updateAccessibilityLabel()
} }
//-------------------------------------------------- //--------------------------------------------------
@ -60,6 +62,7 @@ import Foundation
label2.set(with: model.label2, delegateObject, additionalData) label2.set(with: model.label2, delegateObject, additionalData)
label3.set(with: model.label3, delegateObject, additionalData) label3.set(with: model.label3, delegateObject, additionalData)
label4.set(with: model.label4, delegateObject, additionalData) label4.set(with: model.label4, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
@ -73,4 +76,29 @@ import Foundation
label3.styleBoldBodySmall(true) label3.styleBoldBodySmall(true)
label4.styleBoldBodySmall(true) label4.styleBoldBodySmall(true)
} }
//----------------------------------------------------
// MARK: - Accessibility
//----------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let label1Text = label1.text, !label1Text.isEmpty {
message += label1Text + ", "
}
if let label2Text = label2.text, !label2Text.isEmpty {
message += label2Text + ", "
}
if let label3Text = label3.text, !label3Text.isEmpty {
message += label3Text + ", "
}
if let label4Text = label4.text, !label4Text.isEmpty {
message += label4Text
}
accessibilityLabel = message
}
} }

View File

@ -41,6 +41,8 @@ import Foundation
super.setupView() super.setupView()
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
isAccessibilityElement = true
updateAccessibilityLabel()
} }
//-------------------------------------------------- //--------------------------------------------------
@ -54,6 +56,7 @@ import Foundation
headline.set(with: model.headline, delegateObject, additionalData) headline.set(with: model.headline, delegateObject, additionalData)
body.set(with: model.body, delegateObject, additionalData) body.set(with: model.body, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
@ -65,4 +68,23 @@ import Foundation
headline.styleBoldBodySmall(true) headline.styleBoldBodySmall(true)
body.styleRegularBodySmall(true) body.styleRegularBodySmall(true)
} }
//----------------------------------------------------
// MARK: - Accessibility
//----------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let headlineLabel = headline.text, !headlineLabel.isEmpty {
message += headlineLabel + ", "
}
if let bodyLabel = body.text, !bodyLabel.isEmpty {
message += bodyLabel
}
accessibilityLabel = message
}
} }

View File

@ -41,6 +41,8 @@ import Foundation
super.setupView() super.setupView()
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
isAccessibilityElement = true
updateAccessibilityLabel()
} }
//-------------------------------------------------- //--------------------------------------------------
@ -54,6 +56,7 @@ import Foundation
headline.set(with: model.headline, delegateObject, additionalData) headline.set(with: model.headline, delegateObject, additionalData)
body.set(with: model.body, delegateObject, additionalData) body.set(with: model.body, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
@ -65,4 +68,23 @@ import Foundation
headline.styleBoldTitleMedium(true) headline.styleBoldTitleMedium(true)
body.styleRegularBodySmall(true) body.styleRegularBodySmall(true)
} }
//----------------------------------------------------
// MARK: - Accessibility
//----------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let headlineLabel = headline.text, !headlineLabel.isEmpty {
message += headlineLabel + ", "
}
if let bodyLabel = body.text, !bodyLabel.isEmpty {
message += bodyLabel
}
accessibilityLabel = message
}
} }

View File

@ -40,6 +40,8 @@ import Foundation
super.setupView() super.setupView()
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
isAccessibilityElement = true
updateAccessibilityLabel()
} }
//-------------------------------------------------- //--------------------------------------------------
@ -53,6 +55,7 @@ import Foundation
headline.set(with: model.headline, delegateObject, additionalData) headline.set(with: model.headline, delegateObject, additionalData)
body.set(with: model.body, delegateObject, additionalData) body.set(with: model.body, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
@ -64,4 +67,23 @@ import Foundation
headline.styleBoldTitleMedium(true) headline.styleBoldTitleMedium(true)
body.styleRegularBodySmall(true) body.styleRegularBodySmall(true)
} }
//----------------------------------------------------
// MARK: - Accessibility
//----------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let headlineLabel = headline.text, !headlineLabel.isEmpty {
message += headlineLabel + ", "
}
if let bodyLabel = body.text, !bodyLabel.isEmpty {
message += bodyLabel
}
accessibilityLabel = message
}
} }

View File

@ -43,6 +43,8 @@ import Foundation
super.setupView() super.setupView()
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
isAccessibilityElement = true
updateAccessibilityLabel()
} }
//----------------------------------------------------- //-----------------------------------------------------
@ -57,6 +59,7 @@ import Foundation
leftLabel.set(with: model.leftLabel, delegateObject, additionalData) leftLabel.set(with: model.leftLabel, delegateObject, additionalData)
centerLabel.set(with: model.centerLabel, delegateObject, additionalData) centerLabel.set(with: model.centerLabel, delegateObject, additionalData)
rightLabel.set(with: model.rightLabel, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
@ -69,4 +72,27 @@ import Foundation
centerLabel.styleBoldBodySmall(true) centerLabel.styleBoldBodySmall(true)
rightLabel.styleBoldBodySmall(true) rightLabel.styleBoldBodySmall(true)
} }
//----------------------------------------------------
// MARK: - Accessibility
//----------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let leftLabeltext = leftLabel.text, !leftLabeltext.isEmpty {
message += leftLabeltext + ", "
}
if let centerLabeltext = centerLabel.text, !centerLabeltext.isEmpty {
message += centerLabeltext + ", "
}
if let rightLabeltext = rightLabel.text, !rightLabeltext.isEmpty {
message += rightLabeltext
}
accessibilityLabel = message
}
} }

View File

@ -43,6 +43,8 @@ import Foundation
super.setupView() super.setupView()
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
isAccessibilityElement = true
updateAccessibilityLabel()
} }
//----------------------------------------------------- //-----------------------------------------------------
@ -57,6 +59,7 @@ import Foundation
leftLabel.set(with: model.leftLabel, delegateObject, additionalData) leftLabel.set(with: model.leftLabel, delegateObject, additionalData)
centerLabel.set(with: model.centerLabel, delegateObject, additionalData) centerLabel.set(with: model.centerLabel, delegateObject, additionalData)
rightLabel.set(with: model.rightLabel, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
@ -69,4 +72,27 @@ import Foundation
centerLabel.styleBoldBodySmall(true) centerLabel.styleBoldBodySmall(true)
rightLabel.styleBoldBodySmall(true) rightLabel.styleBoldBodySmall(true)
} }
//----------------------------------------------------
// MARK: - Accessibility
//----------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let leftLabeltext = leftLabel.text, !leftLabeltext.isEmpty {
message += leftLabeltext + ", "
}
if let centerLabeltext = centerLabel.text, !centerLabeltext.isEmpty {
message += centerLabeltext + ", "
}
if let rightLabeltext = rightLabel.text, !rightLabeltext.isEmpty {
message += rightLabeltext
}
accessibilityLabel = message
}
} }

View File

@ -43,6 +43,8 @@ import Foundation
super.setupView() super.setupView()
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
isAccessibilityElement = true
updateAccessibilityLabel()
} }
//----------------------------------------------------- //-----------------------------------------------------
@ -56,6 +58,7 @@ import Foundation
leftLabel.set(with: model.leftLabel, delegateObject, additionalData) leftLabel.set(with: model.leftLabel, delegateObject, additionalData)
centerLabel.set(with: model.centerLabel, delegateObject, additionalData) centerLabel.set(with: model.centerLabel, delegateObject, additionalData)
rightLabel.set(with: model.rightLabel, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
@ -68,4 +71,27 @@ import Foundation
centerLabel.styleBoldBodySmall(true) centerLabel.styleBoldBodySmall(true)
rightLabel.styleBoldBodySmall(true) rightLabel.styleBoldBodySmall(true)
} }
//----------------------------------------------------
// MARK: - Accessibility
//----------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let leftLabeltext = leftLabel.text, !leftLabeltext.isEmpty {
message += leftLabeltext + ", "
}
if let centerLabeltext = centerLabel.text, !centerLabeltext.isEmpty {
message += centerLabeltext + ", "
}
if let rightLabeltext = rightLabel.text, !rightLabeltext.isEmpty {
message += rightLabeltext
}
accessibilityLabel = message
}
} }

View File

@ -43,6 +43,8 @@ import Foundation
super.setupView() super.setupView()
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
isAccessibilityElement = true
updateAccessibilityLabel()
} }
//----------------------------------------------------- //-----------------------------------------------------
@ -57,9 +59,45 @@ import Foundation
leftHeadlineBody.set(with: model.leftHeadlineBody, delegateObject, additionalData) leftHeadlineBody.set(with: model.leftHeadlineBody, delegateObject, additionalData)
centerHeadLineBody.set(with: model.centerHeadlineBody, delegateObject, additionalData) centerHeadLineBody.set(with: model.centerHeadlineBody, delegateObject, additionalData)
rightHeadLineBody.set(with: model.rightHeadlineBody, delegateObject, additionalData) rightHeadLineBody.set(with: model.rightHeadlineBody, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
return 121 return 121
} }
//----------------------------------------------------
// MARK: - Accessibility
//----------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let headlineLabel = leftHeadlineBody.headlineLabel.text {
message += headlineLabel + ", "
}
if let messageLabel = leftHeadlineBody.messageLabel.text {
message += messageLabel + ", "
}
if let headlineLabel = centerHeadLineBody.headlineLabel.text {
message += headlineLabel + ", "
}
if let messageLabel = centerHeadLineBody.messageLabel.text {
message += messageLabel + ", "
}
if let headlineLabel = rightHeadLineBody.headlineLabel.text {
message += headlineLabel + ", "
}
if let messageLabel = rightHeadLineBody.messageLabel.text {
message += messageLabel
}
accessibilityLabel = message
}
} }

View File

@ -24,7 +24,10 @@ import Foundation
//------------------------------------------------------- //-------------------------------------------------------
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
stack = Stack<StackModel>.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 37, horizontalAlignment: .leading)), (view: centerLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)), (view: rightLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading))], axis: .horizontal) stack = Stack<StackModel>.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 37, horizontalAlignment: .leading)),
(view: centerLabel, model: StackItemModel(percent: 33, horizontalAlignment: .leading)),
(view: rightLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading))],
axis: .horizontal)
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)
} }
@ -40,6 +43,8 @@ import Foundation
super.setupView() super.setupView()
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
isAccessibilityElement = true
updateAccessibilityLabel()
} }
//------------------------------------------------------ //------------------------------------------------------
@ -48,10 +53,13 @@ import Foundation
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? ListThreeColumnSpeedTestDividerModel else { return } guard let model = model as? ListThreeColumnSpeedTestDividerModel else { return }
leftLabel.set(with: model.leftLabel, delegateObject, additionalData) leftLabel.set(with: model.leftLabel, delegateObject, additionalData)
centerLabel.set(with: model.centerLabel, delegateObject, additionalData) centerLabel.set(with: model.centerLabel, delegateObject, additionalData)
rightLabel.set(with: model.rightLabel, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
@ -64,4 +72,27 @@ import Foundation
centerLabel.styleBoldBodySmall(true) centerLabel.styleBoldBodySmall(true)
rightLabel.styleBoldBodySmall(true) rightLabel.styleBoldBodySmall(true)
} }
//----------------------------------------------------
// MARK: - Accessibility
//----------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let leftLabeltext = leftLabel.text, !leftLabeltext.isEmpty {
message += leftLabeltext + ", "
}
if let centerLabeltext = centerLabel.text, !centerLabeltext.isEmpty {
message += centerLabeltext + ", "
}
if let rightLabeltext = rightLabel.text, !rightLabeltext.isEmpty {
message += rightLabeltext
}
accessibilityLabel = message
}
} }

View File

@ -41,6 +41,8 @@ import Foundation
super.setupView() super.setupView()
addMolecule(stack) addMolecule(stack)
stack.restack() stack.restack()
isAccessibilityElement = true
updateAccessibilityLabel()
} }
//-------------------------------------------------- //--------------------------------------------------
@ -54,6 +56,7 @@ import Foundation
leftLabel.set(with: model.leftLabel, delegateObject, additionalData) leftLabel.set(with: model.leftLabel, delegateObject, additionalData)
rightLabel.set(with: model.rightLabel, delegateObject, additionalData) rightLabel.set(with: model.rightLabel, delegateObject, additionalData)
updateAccessibilityLabel()
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
@ -65,4 +68,23 @@ import Foundation
leftLabel.styleBoldBodySmall(true) leftLabel.styleBoldBodySmall(true)
rightLabel.styleBoldBodySmall(true) rightLabel.styleBoldBodySmall(true)
} }
//----------------------------------------------------
// MARK: - Accessibility
//----------------------------------------------------
func updateAccessibilityLabel() {
var message = ""
if let leftLabeltext = leftLabel.text, !leftLabeltext.isEmpty {
message += leftLabeltext + ", "
}
if let rightLabeltext = rightLabel.text, !rightLabeltext.isEmpty {
message += rightLabeltext
}
accessibilityLabel = message
}
} }

View File

@ -8,11 +8,20 @@
import Foundation import Foundation
@objcMembers open class TwoLinkView: View, MVMCoreUIViewConstrainingProtocol { @objcMembers open class TwoLinkView: View, MVMCoreUIViewConstrainingProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
open var leftLink = Link() open var leftLink = Link()
open var rightLink = Link() open var rightLink = Link()
private var stack = UIStackView() private var stack = UIStackView()
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
public init() { public init() {
super.init(frame: .zero) super.init(frame: .zero)
} }
@ -25,7 +34,10 @@ import Foundation
super.init(frame: frame) super.init(frame: frame)
} }
//--------------------------------------------------
// MARK: - MVMCoreViewProtocol // MARK: - MVMCoreViewProtocol
//--------------------------------------------------
open override func updateView(_ size: CGFloat) { open override func updateView(_ size: CGFloat) {
super.updateView(size) super.updateView(size)
stack.updateView(size) stack.updateView(size)
@ -43,7 +55,10 @@ import Foundation
stack.spacing = 8 stack.spacing = 8
} }
//--------------------------------------------------
// MARK: - Stack Manipulation // MARK: - Stack Manipulation
//--------------------------------------------------
public func showRightLink() { public func showRightLink() {
if !stack.arrangedSubviews.contains(rightLink) { if !stack.arrangedSubviews.contains(rightLink) {
stack.addArrangedSubview(rightLink) stack.addArrangedSubview(rightLink)
@ -72,18 +87,27 @@ import Foundation
} }
} }
//--------------------------------------------------
// MARK: - MoleculeViewProtocol // MARK: - MoleculeViewProtocol
//--------------------------------------------------
open override func reset() { open override func reset() {
super.reset() super.reset()
stack.reset() stack.reset()
} }
//--------------------------------------------------
// MARK: - MVMCoreUIViewConstrainingProtocol // MARK: - MVMCoreUIViewConstrainingProtocol
//--------------------------------------------------
open func horizontalAlignment() -> UIStackView.Alignment { open func horizontalAlignment() -> UIStackView.Alignment {
return .center return .center
} }
//--------------------------------------------------
// MARK: - MoleculeViewProtocol // MARK: - MoleculeViewProtocol
//--------------------------------------------------
public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 16 return 16
} }
@ -99,6 +123,7 @@ import Foundation
} else { } else {
hideLeftLink() hideLeftLink()
} }
if let model = model.rightLink { if let model = model.rightLink {
showRightLink() showRightLink()
rightLink.set(with: model, delegateObject, additionalData) rightLink.set(with: model, delegateObject, additionalData)