accessibilty start
This commit is contained in:
parent
18f86575e6
commit
f3ed68beed
@ -158,6 +158,7 @@ import MVMCore
|
|||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
|
|
||||||
accessibilityTraits = .button
|
accessibilityTraits = .button
|
||||||
|
isAccessibilityElement = true
|
||||||
accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "checkbox_action_hint")
|
accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "checkbox_action_hint")
|
||||||
updateAccessibilityLabel()
|
updateAccessibilityLabel()
|
||||||
}
|
}
|
||||||
@ -198,8 +199,6 @@ import MVMCore
|
|||||||
open override func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
|
|
||||||
guard constraints.isEmpty else { return }
|
|
||||||
|
|
||||||
isUserInteractionEnabled = true
|
isUserInteractionEnabled = true
|
||||||
translatesAutoresizingMaskIntoConstraints = false
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
backgroundColor = .clear
|
backgroundColor = .clear
|
||||||
@ -394,8 +393,6 @@ import MVMCore
|
|||||||
widthConstraint?.constant = dimension
|
widthConstraint?.constant = dimension
|
||||||
heightConstraint?.constant = dimension
|
heightConstraint?.constant = dimension
|
||||||
}
|
}
|
||||||
|
|
||||||
//layoutIfNeeded()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import UIKit
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
open var json: [AnyHashable: Any]?
|
open var json: [AnyHashable: Any]?
|
||||||
open var model: MoleculeModelProtocol?
|
open var model: MoleculeModelProtocol?
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ extension Control: AppleGuidelinesProtocol {
|
|||||||
// MARK: - MVMCoreViewProtocol
|
// MARK: - MVMCoreViewProtocol
|
||||||
extension Control: MVMCoreViewProtocol {
|
extension Control: MVMCoreViewProtocol {
|
||||||
|
|
||||||
open func updateView(_ size: CGFloat) {}
|
open func updateView(_ size: CGFloat) { }
|
||||||
|
|
||||||
/// Will be called only once.
|
/// Will be called only once.
|
||||||
open func setupView() {
|
open func setupView() {
|
||||||
@ -89,6 +90,7 @@ extension Control: MVMCoreViewProtocol {
|
|||||||
|
|
||||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||||
extension Control: MVMCoreUIMoleculeViewProtocol {
|
extension Control: MVMCoreUIMoleculeViewProtocol {
|
||||||
|
|
||||||
open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
self.json = json
|
self.json = json
|
||||||
|
|
||||||
|
|||||||
@ -246,7 +246,7 @@ import UIKit
|
|||||||
|
|
||||||
// MARK: - MoleculeListCellProtocol
|
// MARK: - MoleculeListCellProtocol
|
||||||
/// For when the separator between cells shows using json and frequency. Default is type: standard, frequency: allExceptTop.
|
/// For when the separator between cells shows using json and frequency. Default is type: standard, frequency: allExceptTop.
|
||||||
public func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?, indexPath: IndexPath) {
|
public func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, indexPath: IndexPath) {
|
||||||
addSeparatorsIfNeeded()
|
addSeparatorsIfNeeded()
|
||||||
if let model = model {
|
if let model = model {
|
||||||
topSeparatorView?.set(with: model, delegateObject, additionalData)
|
topSeparatorView?.set(with: model, delegateObject, additionalData)
|
||||||
@ -258,7 +258,7 @@ import UIKit
|
|||||||
setSeparatorFrequency(model?.frequency ?? .allExceptTop, indexPath: indexPath)
|
setSeparatorFrequency(model?.frequency ?? .allExceptTop, indexPath: indexPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
//TODO: Use object when handleAction is rewrote to handle action model
|
//TODO: Use object when handleAction is rewrote to handle action model
|
||||||
if let actionMap = self.listItemModel?.action?.toJSON() {
|
if let actionMap = self.listItemModel?.action?.toJSON() {
|
||||||
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
|
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
|
||||||
|
|||||||
@ -9,11 +9,18 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objcMembers open class ListLeftVariableCheckboxAllTextAndLinks: TableViewCell {
|
@objcMembers open class ListLeftVariableCheckboxAllTextAndLinks: TableViewCell {
|
||||||
public let checkbox = Checkbox(frame: .zero)
|
//--------------------------------------------------
|
||||||
|
// MARK: - Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public let checkbox = Checkbox()
|
||||||
public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero)
|
public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero)
|
||||||
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?) {
|
||||||
stack = Stack<StackModel>.createStack(with: [(view: checkbox, model: StackItemModel(horizontalAlignment: .fill)),
|
stack = Stack<StackModel>.createStack(with: [(view: checkbox, model: StackItemModel(horizontalAlignment: .fill)),
|
||||||
(view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading))],
|
(view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading))],
|
||||||
@ -25,17 +32,25 @@ import Foundation
|
|||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - View Lifecycle
|
//--------------------------------------------------
|
||||||
|
// MARK: - Life Cycle
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
override open func setupView() {
|
override open func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
addMolecule(stack)
|
addMolecule(stack)
|
||||||
stack.restack()
|
stack.restack()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK:- MVMCoreUIMoleculeViewProtocol
|
//--------------------------------------------------
|
||||||
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
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? ListLeftVariableCheckboxAllTextAndLinksModel else { return}
|
|
||||||
|
guard let model = model as? ListLeftVariableCheckboxAllTextAndLinksModel else { return }
|
||||||
|
|
||||||
checkbox.set(with: model.checkbox, delegateObject, additionalData)
|
checkbox.set(with: model.checkbox, delegateObject, additionalData)
|
||||||
eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData)
|
eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@objcMembers open class ListLeftVariableRadioButtonAndPaymentMethod: TableViewCell {
|
@objcMembers open class ListLeftVariableRadioButtonAndPaymentMethod: TableViewCell {
|
||||||
|
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
// MARK: - Outlets
|
// MARK: - Outlets
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
|
|
||||||
let radioButton = RadioButton(frame: .zero)
|
let radioButton = RadioButton(frame: .zero)
|
||||||
let leftImage = MFLoadImageView(pinnedEdges: .all)
|
let leftImage = MFLoadImageView(pinnedEdges: .all)
|
||||||
let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink()
|
let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink()
|
||||||
@ -21,6 +21,7 @@ import UIKit
|
|||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
// 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: radioButton, model: StackItemModel(horizontalAlignment: .fill)),
|
stack = Stack<StackModel>.createStack(with: [(view: radioButton, model: StackItemModel(horizontalAlignment: .fill)),
|
||||||
(view: leftImage, model: StackItemModel(horizontalAlignment: .fill)),
|
(view: leftImage, model: StackItemModel(horizontalAlignment: .fill)),
|
||||||
@ -36,6 +37,7 @@ import UIKit
|
|||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
// MARK: - View Lifecycle
|
// MARK: - View Lifecycle
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
|
|
||||||
override open func setupView() {
|
override open func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
addMolecule(stack)
|
addMolecule(stack)
|
||||||
@ -53,6 +55,7 @@ import UIKit
|
|||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
// 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? ListLeftVariableRadioButtonAndPaymentMethodModel else { return}
|
guard let model = model as? ListLeftVariableRadioButtonAndPaymentMethodModel else { return}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import UIKit
|
|||||||
public let body = Label.commonLabelB2(true)
|
public let body = Label.commonLabelB2(true)
|
||||||
public let link = Link()
|
public let link = Link()
|
||||||
|
|
||||||
var casteModel: EyebrowHeadlineBodyLinkModel? {
|
var castModel: EyebrowHeadlineBodyLinkModel? {
|
||||||
get { return model as? EyebrowHeadlineBodyLinkModel }
|
get { return model as? EyebrowHeadlineBodyLinkModel }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +52,19 @@ import UIKit
|
|||||||
body.styleB2(true)
|
body.styleB2(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func eyebrow(isHidden: Bool) {
|
||||||
|
|
||||||
|
stack.stackModel?.molecules[0].gone = isHidden
|
||||||
|
|
||||||
|
if isHidden {
|
||||||
|
accessibilityElements = [headline, body, link]
|
||||||
|
} else {
|
||||||
|
accessibilityElements = [eyebrow, headline, body, link]
|
||||||
|
}
|
||||||
|
|
||||||
|
stack.restack()
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - ModelMoleculeViewProtocol
|
// MARK: - ModelMoleculeViewProtocol
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -59,10 +72,10 @@ import UIKit
|
|||||||
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)
|
||||||
|
|
||||||
eyebrow.setOptional(with: casteModel?.eyebrow, delegateObject, additionalData)
|
eyebrow.setOptional(with: castModel?.eyebrow, delegateObject, additionalData)
|
||||||
headline.setOptional(with: casteModel?.headline, delegateObject, additionalData)
|
headline.setOptional(with: castModel?.headline, delegateObject, additionalData)
|
||||||
body.setOptional(with: casteModel?.body, delegateObject, additionalData)
|
body.setOptional(with: castModel?.body, delegateObject, additionalData)
|
||||||
link.setOptional(with: casteModel?.link, delegateObject, additionalData)
|
link.setOptional(with: castModel?.link, delegateObject, additionalData)
|
||||||
|
|
||||||
// Hide labels if neeeded.
|
// Hide labels if neeeded.
|
||||||
stack.stackModel?.molecules[0].gone = !eyebrow.hasText
|
stack.stackModel?.molecules[0].gone = !eyebrow.hasText
|
||||||
|
|||||||
@ -9,9 +9,12 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
open class HeadlineBody: View {
|
open class HeadlineBody: View {
|
||||||
|
|
||||||
let headlineLabel = Label.commonLabelH2(true)
|
let headlineLabel = Label.commonLabelH2(true)
|
||||||
let messageLabel = Label.commonLabelB2(true)
|
let messageLabel = Label.commonLabelB2(true)
|
||||||
|
|
||||||
var spaceBetweenLabelsConstant = PaddingTwo
|
var spaceBetweenLabelsConstant = PaddingTwo
|
||||||
|
|
||||||
var spaceBetweenLabels: NSLayoutConstraint?
|
var spaceBetweenLabels: NSLayoutConstraint?
|
||||||
var leftConstraintTitle: NSLayoutConstraint?
|
var leftConstraintTitle: NSLayoutConstraint?
|
||||||
var rightConstraintTitle: NSLayoutConstraint?
|
var rightConstraintTitle: NSLayoutConstraint?
|
||||||
@ -71,8 +74,6 @@ open class HeadlineBody: View {
|
|||||||
|
|
||||||
open override func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
|
|
||||||
guard subviews.isEmpty else { return }
|
|
||||||
|
|
||||||
backgroundColor = .clear
|
backgroundColor = .clear
|
||||||
clipsToBounds = true
|
clipsToBounds = true
|
||||||
@ -81,6 +82,10 @@ open class HeadlineBody: View {
|
|||||||
addSubview(view)
|
addSubview(view)
|
||||||
NSLayoutConstraint.constraintPinSubview(toSuperview: view)
|
NSLayoutConstraint.constraintPinSubview(toSuperview: view)
|
||||||
|
|
||||||
|
view.isAccessibilityElement = false
|
||||||
|
view.shouldGroupAccessibilityChildren = true
|
||||||
|
view.accessibilityElements = [headlineLabel, messageLabel]
|
||||||
|
|
||||||
view.addSubview(headlineLabel)
|
view.addSubview(headlineLabel)
|
||||||
view.addSubview(messageLabel)
|
view.addSubview(messageLabel)
|
||||||
|
|
||||||
|
|||||||
@ -46,6 +46,9 @@ open class Stack<T>: Container where T: (StackModelProtocol & MoleculeModelProto
|
|||||||
for (index, view) in stackItems.enumerated() {
|
for (index, view) in stackItems.enumerated() {
|
||||||
addView(view, stackModel.molecules[index], totalSpacing: totalSpace, lastItem: lastItemIndex == index)
|
addView(view, stackModel.molecules[index], totalSpacing: totalSpace, lastItem: lastItemIndex == index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isAccessibilityElement = false
|
||||||
|
accessibilityElements = stackItems
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes all stack items views from the view.
|
/// Removes all stack items views from the view.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user