Merge branch 'feature/dynamicAccessibilityTraits' into 'develop'
Added accessibilityTraits dynamically for buttons, List components ### Summary Driven all the buttons and list components traits dynamically. As per the WCAG Accessibility guidelines, Button role - is used to trigger an action e,g confirm information, submit data, continue multi step task. (Button page #45) Link role - Links should be used only for actions that take the user to other locations and, should not be used for button-like functionality.(Text Link page# 46). Google drive link : ([https://drive.google.com/drive/folders/1l2Is486J2UxaVulHE8N5xOTFecFtRCvW)!\[Links__2\_\](/uploads/002f8ac31c0bb7f02f4d030b8995cb9b/Links__2\_.png](https://drive.google.com/drive/folders/1l2Is486J2UxaVulHE8N5xOTFecFtRCvW)!%5BLinks__2_%5D(/uploads/002f8ac31c0bb7f02f4d030b8995cb9b/Links__2_.png)) ### JIRA Ticket https://onejira.verizon.com/browse/CXTDT-421918 Co-authored-by: Keerthy <keerthy.marakanti@verizon.com> Co-authored-by: Krishna Kishore Bandaru <krishna.kishore.bandaru@verizon.com> See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui/-/merge_requests/996
This commit is contained in:
commit
54519d9820
@ -31,6 +31,8 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat
|
||||
public var size: VDS.Button.Size = .large
|
||||
public var groupName: String = ""
|
||||
public var inverted: Bool = false
|
||||
public var accessibilityTraits: UIAccessibilityTraits?
|
||||
public var disabledAccessibilityTraits: UIAccessibilityTraits?
|
||||
public var backgroundColor: Color?
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -77,6 +79,8 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat
|
||||
case size
|
||||
case groupName
|
||||
case width
|
||||
case accessibilityTraits
|
||||
case disabledAccessibilityTraits
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -118,6 +122,10 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat
|
||||
} else {
|
||||
try setInverted(deprecatedFrom: decoder)
|
||||
}
|
||||
|
||||
accessibilityTraits = try typeContainer.decodeIfPresent(UIAccessibilityTraits.self, forKey: .accessibilityTraits)
|
||||
|
||||
disabledAccessibilityTraits = try typeContainer.decodeIfPresent(UIAccessibilityTraits.self, forKey: .disabledAccessibilityTraits)
|
||||
}
|
||||
|
||||
private enum DeprecatedCodingKeys: String, CodingKey {
|
||||
@ -158,6 +166,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat
|
||||
self.inverted = !backgroundColor.uiColor.isDark()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
open func encode(to encoder: Encoder) throws {
|
||||
@ -174,5 +183,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat
|
||||
try container.encode(size, forKey: .size)
|
||||
try container.encodeIfPresent(groupName, forKey: .groupName)
|
||||
try container.encodeIfPresent(width, forKey: .width)
|
||||
try container.encodeIfPresent(accessibilityTraits, forKey: .accessibilityTraits)
|
||||
try container.encodeIfPresent(disabledAccessibilityTraits, forKey: .disabledAccessibilityTraits)
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,6 @@ import Foundation
|
||||
|
||||
super.set(with: model, delegateObject, additionalData)
|
||||
FormValidator.setupValidation(for: castModel, delegate: delegateObject?.formHolderDelegate)
|
||||
|
||||
}
|
||||
|
||||
public func setState() {
|
||||
@ -47,6 +46,9 @@ import Foundation
|
||||
} else if let disabledTintColor = castModel.disabledTintColor {
|
||||
image.imageView.tintColor = disabledTintColor.uiColor
|
||||
}
|
||||
if let traits = model?.accessibilityTraits {
|
||||
accessibilityTraits = traits
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro
|
||||
public var enabled: Bool = true
|
||||
public var enabledTintColor: Color?
|
||||
public var disabledTintColor: Color?
|
||||
|
||||
public var accessibilityTraits: UIAccessibilityTraits?
|
||||
public var groupName: String = ""
|
||||
|
||||
public var updateUI: ActionBlock?
|
||||
@ -45,6 +45,7 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro
|
||||
case groupName
|
||||
case enabledTintColor
|
||||
case disabledTintColor
|
||||
case accessibilityTraits
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -59,7 +60,7 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro
|
||||
image = try typeContainer.decodeIfPresent(ImageViewModel.self, forKey: .image)
|
||||
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
|
||||
action = try typeContainer.decodeModel(codingKey: .action)
|
||||
|
||||
accessibilityTraits = try typeContainer.decodeIfPresent(UIAccessibilityTraits.self, forKey: .accessibilityTraits) ?? .button
|
||||
if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) {
|
||||
self.enabled = enabled
|
||||
}
|
||||
@ -90,5 +91,6 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro
|
||||
try container.encodeIfPresent(groupName, forKey: .groupName)
|
||||
try container.encodeIfPresent(enabledTintColor, forKey: .enabledTintColor)
|
||||
try container.encodeIfPresent(disabledTintColor, forKey: .disabledTintColor)
|
||||
try container.encodeIfPresent(accessibilityTraits, forKey: .accessibilityTraits)
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +41,9 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MFButtonPr
|
||||
if let accessibilityText = viewModel.accessibilityText {
|
||||
accessibilityLabel = accessibilityText
|
||||
}
|
||||
|
||||
|
||||
accessibilityTraits = isEnabled ? (viewModel?.accessibilityTraits ?? .button) : (viewModel?.disabledAccessibilityTraits ?? .none)
|
||||
|
||||
set(with: viewModel.action, delegateObject: delegateObject, additionalData: additionalData)
|
||||
|
||||
viewModel.updateUI = { [weak self] in
|
||||
@ -58,8 +60,10 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MFButtonPr
|
||||
// MARK: - MVMCoreViewProtocol
|
||||
//--------------------------------------------------
|
||||
|
||||
|
||||
open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||
return (model as? ButtonModel)?.size.height
|
||||
|
||||
}
|
||||
|
||||
open func updateView(_ size: CGFloat) {}
|
||||
|
||||
@ -75,6 +75,7 @@ import Foundation
|
||||
delegateObject, additionalData)
|
||||
rightImageView.set(with: model.image, delegateObject, additionalData)
|
||||
updateAccessibilityLabel()
|
||||
accessibilityTraits.update(with: model.accessibilityTraits ?? button.accessibilityTraits)
|
||||
}
|
||||
|
||||
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||
|
||||
@ -73,6 +73,7 @@
|
||||
delegateObject, additionalData)
|
||||
rightImageView.set(with: model.image, delegateObject, additionalData)
|
||||
updateAccessibilityLabel()
|
||||
accessibilityTraits.update(with: model.accessibilityTraits ?? button.accessibilityTraits)
|
||||
}
|
||||
|
||||
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||
|
||||
@ -79,7 +79,7 @@
|
||||
|
||||
let linkShowing = (model as? ListLeftVariableIconAllTextLinksModel)?.eyebrowHeadlineBodyLink.link?.title != nil
|
||||
isAccessibilityElement = !linkShowing
|
||||
accessibilityTraits = (isAccessibilityElement && accessoryView != nil) ? .button : .none
|
||||
accessibilityTraits = (listItemModel?.accessibilityTraits) ?? ((isAccessibilityElement && accessoryView != nil) ? .button : .none)
|
||||
|
||||
if !linkShowing {
|
||||
// Make whole cell focusable if no link.
|
||||
|
||||
@ -91,6 +91,6 @@
|
||||
}
|
||||
|
||||
accessibilityLabel = message
|
||||
accessibilityTraits = (accessoryView != nil) ? .button : .none
|
||||
accessibilityTraits = (listItemModel?.accessibilityTraits) ?? ((accessoryView != nil) ? .button : .none)
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@
|
||||
func updateAccessibilityLabel() {
|
||||
let linkShowing = (model as? ListLeftVariableIconWithRightCaretAllTextLinksModel)?.eyebrowHeadlineBodyLink.link?.title != nil
|
||||
isAccessibilityElement = !linkShowing
|
||||
accessibilityTraits = (isAccessibilityElement && accessoryView != nil) ? .button : .none
|
||||
accessibilityTraits = (listItemModel?.accessibilityTraits) ?? ((isAccessibilityElement && accessoryView != nil) ? .button : .none)
|
||||
|
||||
if !linkShowing {
|
||||
// Make whole cell focusable if no link.
|
||||
|
||||
@ -109,6 +109,6 @@
|
||||
}
|
||||
|
||||
accessibilityLabel = message
|
||||
accessibilityTraits = (accessoryView != nil) ? .button : .none
|
||||
accessibilityTraits = (listItemModel?.accessibilityTraits) ?? ((accessoryView != nil) ? .button : .none)
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@
|
||||
|
||||
let linkShowing = (model as? ListLeftVariableNumberedListAllTextAndLinksModel)?.eyebrowHeadlineBodyLink.link?.title != nil
|
||||
isAccessibilityElement = !linkShowing
|
||||
accessibilityTraits = (isAccessibilityElement && accessoryView != nil) ? .button : .none
|
||||
accessibilityTraits = (listItemModel?.accessibilityTraits) ?? ((isAccessibilityElement && accessoryView != nil) ? .button : .none)
|
||||
|
||||
if !linkShowing {
|
||||
// Make whole cell focusable if no link.
|
||||
|
||||
@ -89,7 +89,7 @@
|
||||
}
|
||||
|
||||
accessibilityLabel = message
|
||||
accessibilityTraits = (accessoryView != nil) ? .button : .none
|
||||
accessibilityTraits = (listItemModel?.accessibilityTraits) ?? ((accessoryView != nil) ? .button : .none)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -134,6 +134,6 @@ open class ListProgressBarThin: TableViewCell {
|
||||
}
|
||||
|
||||
accessibilityLabel = message
|
||||
accessibilityTraits = (accessoryView != nil) ? .button : .none
|
||||
accessibilityTraits = (listItemModel?.accessibilityTraits) ?? ((accessoryView != nil) ? .button : .none)
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,11 +70,7 @@
|
||||
|
||||
override public var accessibilityTraits: UIAccessibilityTraits {
|
||||
get {
|
||||
if (accessoryView != nil) {
|
||||
return .button
|
||||
} else {
|
||||
return .none
|
||||
}
|
||||
return (listItemModel?.accessibilityTraits) ?? ((accessoryView != nil) ? .button : .none)
|
||||
}
|
||||
set { }
|
||||
}
|
||||
|
||||
@ -97,7 +97,8 @@ import Foundation
|
||||
// Ensures voice over does not read "selected" after user triggers action on cell.
|
||||
override public var accessibilityTraits: UIAccessibilityTraits {
|
||||
get {
|
||||
return (accessoryView != nil) ? .button : .none
|
||||
return (listItemModel?.accessibilityTraits) ?? ((accessoryView != nil) ? .button : .none)
|
||||
|
||||
}
|
||||
set {}
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ import Foundation
|
||||
/// Ensures voice over does not read "selected" after user triggers action on cell.
|
||||
override public var accessibilityTraits: UIAccessibilityTraits {
|
||||
get {
|
||||
return (accessoryView != nil) ? .button : .none
|
||||
return (listItemModel?.accessibilityTraits) ?? ((accessoryView != nil) ? .button : .none)
|
||||
}
|
||||
set {}
|
||||
}
|
||||
|
||||
@ -91,6 +91,6 @@
|
||||
}
|
||||
|
||||
accessibilityLabel = message
|
||||
accessibilityTraits = (accessoryView != nil) ? .button : .none
|
||||
accessibilityTraits = (listItemModel?.accessibilityTraits) ?? ((accessoryView != nil) ? .button : .none)
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
stack.restack()
|
||||
accessibilityValue = button.accessibilityValue
|
||||
accessibilityHint = button.accessibilityHint
|
||||
accessibilityTraits = .button
|
||||
accessibilityTraits = (listItemModel?.accessibilityTraits ?? .button)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
||||
@ -83,6 +83,6 @@
|
||||
}
|
||||
|
||||
accessibilityLabel = message
|
||||
accessibilityTraits = (accessoryView != nil) ? .button : .none
|
||||
accessibilityTraits = (listItemModel?.accessibilityTraits) ?? ((accessoryView != nil) ? .button : .none)
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@
|
||||
|
||||
let linkShowing = (model as? ListRightVariablePriceChangeAllTextAndLinksModel)?.eyebrowHeadlineBodyLink.link?.title != nil
|
||||
isAccessibilityElement = !linkShowing
|
||||
accessibilityTraits = (isAccessibilityElement && accessoryView != nil) ? .button : .none
|
||||
accessibilityTraits = (listItemModel?.accessibilityTraits) ?? ((isAccessibilityElement && accessoryView != nil) ? .button : .none)
|
||||
|
||||
if !linkShowing {
|
||||
// Make whole cell focusable if no link.
|
||||
|
||||
@ -98,6 +98,6 @@
|
||||
}
|
||||
|
||||
accessibilityLabel = message
|
||||
accessibilityTraits = (accessoryView != nil) ? .button : .none
|
||||
accessibilityTraits = (listItemModel?.accessibilityTraits) ?? ((accessoryView != nil) ? .button : .none)
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,8 +99,8 @@
|
||||
|
||||
let linkShowing = (model as? ListRightVariableRightCaretAllTextAndLinksModel)?.eyebrowHeadlineBodyLink.link?.title != nil
|
||||
isAccessibilityElement = !linkShowing
|
||||
accessibilityTraits = (isAccessibilityElement && accessoryView != nil) ? .button : .none
|
||||
|
||||
accessibilityTraits = (listItemModel?.accessibilityTraits) ?? ((isAccessibilityElement && accessoryView != nil) ? .button : .none)
|
||||
|
||||
if !linkShowing {
|
||||
// Make whole cell focusable if no link.
|
||||
accessibilityLabel = getAccessibilityMessage()
|
||||
|
||||
@ -89,7 +89,7 @@
|
||||
func updateAccessibilityLabel() {
|
||||
|
||||
let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0
|
||||
accessibilityTraits = .button
|
||||
accessibilityTraits = listItemModel?.accessibilityTraits ?? .button
|
||||
|
||||
if !linkShowing && accessoryView == nil {
|
||||
// Make whole cell focusable if one action
|
||||
|
||||
@ -103,6 +103,6 @@ open class ListRightVariableTotalData: TableViewCell {
|
||||
}
|
||||
|
||||
accessibilityLabel = message
|
||||
accessibilityTraits = (accessoryView != nil) ? .button : .none
|
||||
accessibilityTraits = (listItemModel?.accessibilityTraits) ?? ((accessoryView != nil) ? .button : .none)
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,8 +18,9 @@
|
||||
public var hideArrow: Bool?
|
||||
public var line: LineModel?
|
||||
public var style: ListItemStyle?
|
||||
public var accessibilityTraits: UIAccessibilityTraits?
|
||||
public var accessibilityValue: String?
|
||||
public var accessibilityText: String?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Keys
|
||||
//--------------------------------------------------
|
||||
@ -30,6 +31,8 @@
|
||||
case hideArrow
|
||||
case line
|
||||
case style
|
||||
case accessibilityTraits
|
||||
case accessibilityValue
|
||||
case accessibilityText
|
||||
}
|
||||
|
||||
@ -104,7 +107,8 @@
|
||||
hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow)
|
||||
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
|
||||
style = try typeContainer.decodeIfPresent(ListItemStyle.self, forKey: .style)
|
||||
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
|
||||
accessibilityTraits = try typeContainer.decodeIfPresent(UIAccessibilityTraits.self, forKey: .accessibilityTraits)
|
||||
accessibilityValue = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityValue)
|
||||
try super.init(from: decoder)
|
||||
}
|
||||
|
||||
@ -116,6 +120,8 @@
|
||||
try container.encodeIfPresent(hideArrow, forKey: .hideArrow)
|
||||
try container.encodeIfPresent(line, forKey: .line)
|
||||
try container.encodeIfPresent(style, forKey: .style)
|
||||
try container.encodeIfPresent(accessibilityTraits, forKey: .accessibilityTraits)
|
||||
try container.encodeIfPresent(accessibilityValue, forKey: .accessibilityValue)
|
||||
try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ public protocol AccessibilityModelProtocol {
|
||||
var accessibilityTraits: UIAccessibilityTraits? { get set }
|
||||
var accessibilityText: String? { get set }
|
||||
var accessibilityValue: String? { get set }
|
||||
var accessibilityHint: String? { get set }
|
||||
}
|
||||
|
||||
public extension AccessibilityModelProtocol {
|
||||
@ -38,4 +39,9 @@ public extension AccessibilityModelProtocol {
|
||||
get { nil }
|
||||
set { }
|
||||
}
|
||||
|
||||
var accessibilityHint: String? {
|
||||
get { nil }
|
||||
set {}
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ public enum ListItemStyle: String, Codable {
|
||||
case none
|
||||
}
|
||||
|
||||
public protocol ListItemModelProtocol: ContainerModelProtocol {
|
||||
public protocol ListItemModelProtocol: ContainerModelProtocol, AccessibilityModelProtocol {
|
||||
var line: LineModel? { get set }
|
||||
var action: ActionModelProtocol? { get set }
|
||||
var hideArrow: Bool? { get set }
|
||||
|
||||
@ -163,6 +163,15 @@ import UIKit
|
||||
|
||||
// align if needed.
|
||||
containerHelper.set(with: model, for: molecule as? MVMCoreUIViewConstrainingProtocol)
|
||||
|
||||
if let traits = model.accessibilityTraits {
|
||||
accessibilityTraits.update(with: traits)
|
||||
}
|
||||
if let accessibilityText = model.accessibilityText {
|
||||
accessibilityLabel = accessibilityText
|
||||
isAccessibilityElement = true
|
||||
}
|
||||
accessibilityValue = model.accessibilityValue
|
||||
}
|
||||
|
||||
open func reset() {
|
||||
|
||||
@ -83,7 +83,6 @@ import Combine
|
||||
}
|
||||
|
||||
extension NavigationController: MVMCoreViewManagerProtocol {
|
||||
|
||||
public func getAccessibilityElements() -> [Any]? {
|
||||
nil
|
||||
}
|
||||
|
||||
@ -249,7 +249,6 @@ public extension MVMCoreUISplitViewController {
|
||||
}
|
||||
|
||||
extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol {
|
||||
|
||||
public func getAccessibilityElements() -> [Any]? {
|
||||
nil
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user