From 614c166e8e4063059acd7ec97a0bac02762adef6 Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Wed, 13 May 2020 18:04:34 +0530 Subject: [PATCH 1/3] 18931(iOS - List - Left Variable - Radio Button - All Text & Links) initial commit --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++ MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + ...ftVariableRadioButtonAllTextAndLinks.swift | 90 +++++++++++++++++++ ...iableRadioButtonAllTextAndLinksModel.swift | 55 ++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAllTextAndLinks.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAllTextAndLinksModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 1b66b097..a7d24dff 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -195,6 +195,8 @@ AA617AB22453012400910B8F /* ListDeviceComplexLinkSmallModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA617AB12453012400910B8F /* ListDeviceComplexLinkSmallModel.swift */; }; AA69AAF62445BF5700AF3D3B /* ListLeftVariableCheckboxBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA69AAF52445BF5700AF3D3B /* ListLeftVariableCheckboxBodyText.swift */; }; AA69AAF82445BF6800AF3D3B /* ListLeftVariableCheckboxBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA69AAF72445BF6800AF3D3B /* ListLeftVariableCheckboxBodyTextModel.swift */; }; + AA7F32AB246C0F7900C965BA /* ListLeftVariableRadioButtonAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA7F32AA246C0F7900C965BA /* ListLeftVariableRadioButtonAllTextAndLinksModel.swift */; }; + AA7F32AD246C0F8C00C965BA /* ListLeftVariableRadioButtonAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA7F32AC246C0F8C00C965BA /* ListLeftVariableRadioButtonAllTextAndLinks.swift */; }; AA85236C244435A20059CC1E /* RadioSwatchCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA85236B244435A20059CC1E /* RadioSwatchCollectionViewCell.swift */; }; AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */; }; AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */; }; @@ -608,6 +610,8 @@ AA617AB12453012400910B8F /* ListDeviceComplexLinkSmallModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexLinkSmallModel.swift; sourceTree = ""; }; AA69AAF52445BF5700AF3D3B /* ListLeftVariableCheckboxBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxBodyText.swift; sourceTree = ""; }; AA69AAF72445BF6800AF3D3B /* ListLeftVariableCheckboxBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxBodyTextModel.swift; sourceTree = ""; }; + AA7F32AA246C0F7900C965BA /* ListLeftVariableRadioButtonAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableRadioButtonAllTextAndLinksModel.swift; sourceTree = ""; }; + AA7F32AC246C0F8C00C965BA /* ListLeftVariableRadioButtonAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableRadioButtonAllTextAndLinks.swift; sourceTree = ""; }; AA85236B244435A20059CC1E /* RadioSwatchCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioSwatchCollectionViewCell.swift; sourceTree = ""; }; AAA74A162410C04600080241 /* HeadersH2NoButtonsBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyText.swift; sourceTree = ""; }; AAA74A182410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2NoButtonsBodyTextModel.swift; sourceTree = ""; }; @@ -1263,6 +1267,8 @@ 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */, 0A6682A32434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift */, 0A6682A12434DB4F00AD3CA1 /* ListLeftVariableRadioButtonBodyText.swift */, + AA7F32AA246C0F7900C965BA /* ListLeftVariableRadioButtonAllTextAndLinksModel.swift */, + AA7F32AC246C0F8C00C965BA /* ListLeftVariableRadioButtonAllTextAndLinks.swift */, ); path = LeftVariable; sourceTree = ""; @@ -1952,6 +1958,7 @@ D21B7F602437C5BC00051ABF /* MoleculeStackView.swift in Sources */, 0A6682A42434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift in Sources */, AA2AD116244EE46800BBFFE3 /* ListDeviceComplexLinkMedium.swift in Sources */, + AA7F32AD246C0F8C00C965BA /* ListLeftVariableRadioButtonAllTextAndLinks.swift in Sources */, 0A9D09202433796500D2E6C0 /* BarsIndicatorView.swift in Sources */, D2E2A99423D8CCBC000B42E6 /* HeadlineBodyLinkModel.swift in Sources */, 01004F3022721C3800991ECC /* RadioButton.swift in Sources */, @@ -2158,6 +2165,7 @@ D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, AAA74A172410C04600080241 /* HeadersH2NoButtonsBodyText.swift in Sources */, 522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */, + AA7F32AB246C0F7900C965BA /* ListLeftVariableRadioButtonAllTextAndLinksModel.swift in Sources */, 8D084AD02410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift in Sources */, D253BB9E2458751F002DE544 /* BGImageMoleculeModel.swift in Sources */, 0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 7f120e1d..21454336 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -162,6 +162,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnInternationalData.self, viewModelClass: ListThreeColumnInternationalDataModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnDataUsage.self, viewModelClass: ListThreeColumnDataUsageModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageListItem.self, viewModelClass: ListFourColumnDataUsageListItemModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonAllTextAndLinks.self, viewModelClass: ListLeftVariableRadioButtonAllTextAndLinksModel.self) // Designed Section Dividers MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAllTextAndLinks.swift new file mode 100644 index 00000000..bdaba9c2 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAllTextAndLinks.swift @@ -0,0 +1,90 @@ +// +// ListLeftVariableRadioButtonAllTextAndLinks.swift +// MVMCoreUI +// +// Created by Lekshmi S on 13/05/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +@objcMembers open class ListLeftVariableRadioButtonAllTextAndLinks: TableViewCell { + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + let radioButton = RadioButton() + let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink() + var stack: Stack + + private var observation: NSKeyValueObservation? = nil + + //----------------------------------------------------- + // MARK: - Initializers + //----------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: radioButton, model: StackItemModel(horizontalAlignment: .fill)), + (view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading))], + axis: .horizontal) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //----------------------------------------------------- + // MARK: - View Lifecycle + //----------------------------------------------------- + override open func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + radioButton.isAccessibilityElement = false + isAccessibilityElement = true + updateAccessibilityLabel() + accessibilityTraits = .button + accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "radio_action_hint") + updateAccessibilityLabel() + + observation = observe(\.radioButton.isSelected, options: [.new]) { [weak self] _, _ in + self?.updateAccessibilityLabel() + } + } + + //---------------------------------------------------- + // MARK: - Molecule + //---------------------------------------------------- + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListLeftVariableRadioButtonAllTextAndLinksModel else { return} + radioButton.set(with: model.radioButton, delegateObject, additionalData) + eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) + updateAccessibilityLabel() + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } + + public override func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + radioButton.tapAction() + } + + func updateAccessibilityLabel() { + + var message = MVMCoreUIUtility.hardcodedString(withKey: "radio_button") ?? "" + radioButton.updateAccessibilityLabel() + if let radioButtonLabel = radioButton.accessibilityLabel { + message += radioButtonLabel + ", " + } + if let eyebrowLabel = eyebrowHeadlineBodyLink.eyebrow.text { + message += eyebrowLabel + ", " + } + if let headlineLabel = eyebrowHeadlineBodyLink.headline.text { + message += headlineLabel + ", " + } + if let bodyLabel = eyebrowHeadlineBodyLink.body.text { + message += bodyLabel + } + accessibilityLabel = message + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAllTextAndLinksModel.swift new file mode 100644 index 00000000..1ac8e80d --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAllTextAndLinksModel.swift @@ -0,0 +1,55 @@ +// +// ListLeftVariableRadioButtonAllTextAndLinksModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 13/05/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation +open class ListLeftVariableRadioButtonAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + open class var identifier: String { + return "listLVRBAll" + } + public var radioButton: RadioButtonModel + public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(radioButton: RadioButtonModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) { + self.radioButton = radioButton + self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink + super.init() + } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { + case moleculeName + case eyebrowHeadlineBodyLink + case radioButton + } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + radioButton = try typeContainer.decode(RadioButtonModel.self, forKey: .radioButton) + eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink) + try super.init(from: decoder) + } + + open override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) + try container.encode(radioButton, forKey: .radioButton) + } +} From 24d0390e2544738789c83d16f5527941243d67df Mon Sep 17 00:00:00 2001 From: Lekshmi S Date: Thu, 21 May 2020 13:03:36 +0530 Subject: [PATCH 2/3] Code clean as per review comment. --- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index dc0ddbcd..5518aca6 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -145,6 +145,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonAndPaymentMethod.self, viewModelClass: ListLeftVariableRadioButtonAndPaymentMethodModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonBodyText.self, viewModelClass: ListLeftVariableRadioButtonBodyTextModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonAllTextAndLinks.self, viewModelClass: ListLeftVariableRadioButtonAllTextAndLinksModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableCheckboxBodyText.self, viewModelClass: ListLeftVariableCheckboxBodyTextModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableIconAllTextLinks.self, viewModelClass: ListLeftVariableIconAllTextLinksModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) @@ -164,7 +165,6 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnDataUsage.self, viewModelClass: ListThreeColumnDataUsageModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageListItem.self, viewModelClass: ListFourColumnDataUsageListItemModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListProgressBarThin.self, viewModelClass: ListProgressBarThinModel.self) - MoleculeObjectMapping.shared()?.register(viewClass: ListLeftVariableRadioButtonAllTextAndLinks.self, viewModelClass: ListLeftVariableRadioButtonAllTextAndLinksModel.self) // Designed Section Dividers MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) From 6068d5b1c524e5bf8b283aa6070a30000b6c6a4f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 28 May 2020 20:42:02 -0400 Subject: [PATCH 3/3] changes after discuss with Ryan --- .../Atomic/Atoms/Selectors/RadioButton.swift | 6 +-- ...ftVariableRadioButtonAllTextAndLinks.swift | 40 ++++++++++++++----- ...tVariableRadioButtonAndPaymentMethod.swift | 40 ++++++++++++------- .../ListLeftVariableRadioButtonBodyText.swift | 9 +++-- 4 files changed, 64 insertions(+), 31 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift index 1ac28ded..43750513 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift @@ -125,9 +125,9 @@ import UIKit /// Adjust accessibility label based on state of RadioButton. func updateAccessibilityLabel() { - - if let state = MVMCoreUIUtility.hardcodedString(withKey: isSelected ? "radio_selected_state" : "radio_not_selected_state") { - accessibilityLabel = state + if let message = MVMCoreUIUtility.hardcodedString(withKey: "radio_button"), + let selectedState = MVMCoreUIUtility.hardcodedString(withKey: isSelected ? "radio_selected_state" : "radio_not_selected_state") { + accessibilityLabel = message + selectedState } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAllTextAndLinks.swift index bdaba9c2..fd71bd6d 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAllTextAndLinks.swift @@ -22,8 +22,8 @@ import Foundation //----------------------------------------------------- public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: radioButton, model: StackItemModel(horizontalAlignment: .fill)), - (view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading))], - axis: .horizontal) + (view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading))], + axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -38,13 +38,11 @@ import Foundation super.setupView() addMolecule(stack) stack.restack() - radioButton.isAccessibilityElement = false - isAccessibilityElement = true - updateAccessibilityLabel() - accessibilityTraits = .button - accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "radio_action_hint") - updateAccessibilityLabel() + accessibilityTraits = radioButton.accessibilityTraits + accessibilityHint = radioButton.accessibilityHint + + // Update accessibility label on radio button state change. observation = observe(\.radioButton.isSelected, options: [.new]) { [weak self] _, _ in self?.updateAccessibilityLabel() } @@ -70,8 +68,7 @@ import Foundation } func updateAccessibilityLabel() { - - var message = MVMCoreUIUtility.hardcodedString(withKey: "radio_button") ?? "" + var message = "" radioButton.updateAccessibilityLabel() if let radioButtonLabel = radioButton.accessibilityLabel { message += radioButtonLabel + ", " @@ -85,6 +82,27 @@ import Foundation if let bodyLabel = eyebrowHeadlineBodyLink.body.text { message += bodyLabel } - accessibilityLabel = message + + let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0 + isAccessibilityElement = !linkShowing + radioButton.isAccessibilityElement = linkShowing + eyebrowHeadlineBodyLink.link.isAccessibilityElement = linkShowing + + if !linkShowing { + // Make whole cell focusable if no link. + accessibilityLabel = message + } else { + // Allow only radio button and link to be focused on. + radioButton.accessibilityLabel = message + + var elements: [UIView] = [] + if message.count > 0 { + elements.append(radioButton) + } + if eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0 { + elements.append(eyebrowHeadlineBodyLink.link) + } + accessibilityElements = elements + } } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift index 688f457c..7ee0b619 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift @@ -48,13 +48,11 @@ import UIKit stack.restack() eyebrowHeadlineBodyLink.body.textColor = .mvmOrangeAA eyebrowHeadlineBodyLink.headline.styleBoldBodySmall(true) - radioButton.isAccessibilityElement = false - isAccessibilityElement = true - updateAccessibilityLabel() - accessibilityTraits = .button - accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "radio_action_hint") - updateAccessibilityLabel() + + accessibilityTraits = radioButton.accessibilityTraits + accessibilityHint = radioButton.accessibilityHint + // Update accessibility label on radio button state change. observation = observe(\.radioButton.isSelected, options: [.new]) { [weak self] _, _ in self?.updateAccessibilityLabel() } @@ -88,30 +86,44 @@ import UIKit } func updateAccessibilityLabel() { - - var message = MVMCoreUIUtility.hardcodedString(withKey: "radio_button") ?? "" - + var message = "" radioButton.updateAccessibilityLabel() if let radioButtonLabel = radioButton.accessibilityLabel { message += radioButtonLabel + ", " } - if let leftImageLabel = leftImage.accessibilityLabel { message += leftImageLabel + ", " } - if let eyebrowLabel = eyebrowHeadlineBodyLink.eyebrow.text { message += eyebrowLabel + ", " } - if let headlineLabel = eyebrowHeadlineBodyLink.headline.text { message += headlineLabel + ", " } - if let bodyLabel = eyebrowHeadlineBodyLink.body.text { message += bodyLabel } - accessibilityLabel = message + let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0 + isAccessibilityElement = !linkShowing + radioButton.isAccessibilityElement = linkShowing + eyebrowHeadlineBodyLink.link.isAccessibilityElement = linkShowing + + if !linkShowing { + // Make whole cell focusable if no link. + accessibilityLabel = message + } else { + // Allow only radio button and link to be focused on. + radioButton.accessibilityLabel = message + + var elements: [UIView] = [] + if message.count > 0 { + elements.append(radioButton) + } + if eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0 { + elements.append(eyebrowHeadlineBodyLink.link) + } + accessibilityElements = elements + } } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyText.swift index d89604f9..189c08d0 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyText.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonBodyText.swift @@ -44,12 +44,15 @@ open class ListLeftVariableRadioButtonBodyText: TableViewCell { addMolecule(stack) stack.restack() + + // Make the whole cell focusable. isAccessibilityElement = true radioButton.isAccessibilityElement = false - accessibilityTraits = .button - accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "radio_action_hint") + accessibilityTraits = radioButton.accessibilityTraits + accessibilityHint = radioButton.accessibilityHint updateAccessibilityLabel() + // Update accessibility label on radio button state change. observation = observe(\.radioButton.isSelected, options: [.new]) { [weak self] _, _ in self?.updateAccessibilityLabel() } @@ -79,7 +82,7 @@ open class ListLeftVariableRadioButtonBodyText: TableViewCell { func updateAccessibilityLabel() { - var message = MVMCoreUIUtility.hardcodedString(withKey: "radio_button") ?? "" + var message = "" radioButton.updateAccessibilityLabel() if let radioButtonLabel = radioButton.accessibilityLabel {