accessibilty start

This commit is contained in:
Kevin G Christiano 2020-03-24 15:21:21 -04:00
parent 18f86575e6
commit f3ed68beed
8 changed files with 58 additions and 20 deletions

View File

@ -158,6 +158,7 @@ import MVMCore
super.init(frame: frame)
accessibilityTraits = .button
isAccessibilityElement = true
accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "checkbox_action_hint")
updateAccessibilityLabel()
}
@ -198,8 +199,6 @@ import MVMCore
open override func setupView() {
super.setupView()
guard constraints.isEmpty else { return }
isUserInteractionEnabled = true
translatesAutoresizingMaskIntoConstraints = false
backgroundColor = .clear
@ -394,8 +393,6 @@ import MVMCore
widthConstraint?.constant = dimension
heightConstraint?.constant = dimension
}
//layoutIfNeeded()
}
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {

View File

@ -12,6 +12,7 @@ import UIKit
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
open var json: [AnyHashable: Any]?
open var model: MoleculeModelProtocol?
@ -78,7 +79,7 @@ extension Control: AppleGuidelinesProtocol {
// MARK: - MVMCoreViewProtocol
extension Control: MVMCoreViewProtocol {
open func updateView(_ size: CGFloat) {}
open func updateView(_ size: CGFloat) { }
/// Will be called only once.
open func setupView() {
@ -89,6 +90,7 @@ extension Control: MVMCoreViewProtocol {
// MARK: - MVMCoreUIMoleculeViewProtocol
extension Control: MVMCoreUIMoleculeViewProtocol {
open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
self.json = json

View File

@ -246,7 +246,7 @@ import UIKit
// MARK: - MoleculeListCellProtocol
/// 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()
if let model = model {
topSeparatorView?.set(with: model, delegateObject, additionalData)
@ -258,7 +258,7 @@ import UIKit
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
if let actionMap = self.listItemModel?.action?.toJSON() {
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)

View File

@ -9,11 +9,18 @@
import Foundation
@objcMembers open class ListLeftVariableCheckboxAllTextAndLinks: TableViewCell {
public let checkbox = Checkbox(frame: .zero)
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public let checkbox = Checkbox()
public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero)
public var stack: Stack<StackModel>
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
stack = Stack<StackModel>.createStack(with: [(view: checkbox, model: StackItemModel(horizontalAlignment: .fill)),
(view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading))],
@ -25,17 +32,25 @@ import Foundation
fatalError("init(coder:) has not been implemented")
}
// MARK: - View Lifecycle
//--------------------------------------------------
// MARK: - Life Cycle
//--------------------------------------------------
override open func setupView() {
super.setupView()
addMolecule(stack)
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)
guard let model = model as? ListLeftVariableCheckboxAllTextAndLinksModel else { return}
guard let model = model as? ListLeftVariableCheckboxAllTextAndLinksModel else { return }
checkbox.set(with: model.checkbox, delegateObject, additionalData)
eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData)
}

View File

@ -9,10 +9,10 @@
import UIKit
@objcMembers open class ListLeftVariableRadioButtonAndPaymentMethod: TableViewCell {
//-----------------------------------------------------
// MARK: - Outlets
//-----------------------------------------------------
let radioButton = RadioButton(frame: .zero)
let leftImage = MFLoadImageView(pinnedEdges: .all)
let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink()
@ -21,6 +21,7 @@ import UIKit
//-----------------------------------------------------
// MARK: - Initializers
//-----------------------------------------------------
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
stack = Stack<StackModel>.createStack(with: [(view: radioButton, model: StackItemModel(horizontalAlignment: .fill)),
(view: leftImage, model: StackItemModel(horizontalAlignment: .fill)),
@ -36,6 +37,7 @@ import UIKit
//-----------------------------------------------------
// MARK: - View Lifecycle
//-----------------------------------------------------
override open func setupView() {
super.setupView()
addMolecule(stack)
@ -53,6 +55,7 @@ import UIKit
//----------------------------------------------------
// 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? ListLeftVariableRadioButtonAndPaymentMethodModel else { return}

View File

@ -19,7 +19,7 @@ import UIKit
public let body = Label.commonLabelB2(true)
public let link = Link()
var casteModel: EyebrowHeadlineBodyLinkModel? {
var castModel: EyebrowHeadlineBodyLinkModel? {
get { return model as? EyebrowHeadlineBodyLinkModel }
}
@ -52,6 +52,19 @@ import UIKit
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
//--------------------------------------------------
@ -59,10 +72,10 @@ import UIKit
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData)
eyebrow.setOptional(with: casteModel?.eyebrow, delegateObject, additionalData)
headline.setOptional(with: casteModel?.headline, delegateObject, additionalData)
body.setOptional(with: casteModel?.body, delegateObject, additionalData)
link.setOptional(with: casteModel?.link, delegateObject, additionalData)
eyebrow.setOptional(with: castModel?.eyebrow, delegateObject, additionalData)
headline.setOptional(with: castModel?.headline, delegateObject, additionalData)
body.setOptional(with: castModel?.body, delegateObject, additionalData)
link.setOptional(with: castModel?.link, delegateObject, additionalData)
// Hide labels if neeeded.
stack.stackModel?.molecules[0].gone = !eyebrow.hasText

View File

@ -9,9 +9,12 @@
import UIKit
open class HeadlineBody: View {
let headlineLabel = Label.commonLabelH2(true)
let messageLabel = Label.commonLabelB2(true)
var spaceBetweenLabelsConstant = PaddingTwo
var spaceBetweenLabels: NSLayoutConstraint?
var leftConstraintTitle: NSLayoutConstraint?
var rightConstraintTitle: NSLayoutConstraint?
@ -71,8 +74,6 @@ open class HeadlineBody: View {
open override func setupView() {
super.setupView()
guard subviews.isEmpty else { return }
backgroundColor = .clear
clipsToBounds = true
@ -81,6 +82,10 @@ open class HeadlineBody: View {
addSubview(view)
NSLayoutConstraint.constraintPinSubview(toSuperview: view)
view.isAccessibilityElement = false
view.shouldGroupAccessibilityChildren = true
view.accessibilityElements = [headlineLabel, messageLabel]
view.addSubview(headlineLabel)
view.addSubview(messageLabel)

View File

@ -46,6 +46,9 @@ open class Stack<T>: Container where T: (StackModelProtocol & MoleculeModelProto
for (index, view) in stackItems.enumerated() {
addView(view, stackModel.molecules[index], totalSpacing: totalSpace, lastItem: lastItemIndex == index)
}
isAccessibilityElement = false
accessibilityElements = stackItems
}
/// Removes all stack items views from the view.