further accessibility updates.

This commit is contained in:
Kevin G Christiano 2020-04-28 09:38:28 -04:00
parent a97e6ae7a1
commit b92358cca9
7 changed files with 62 additions and 6 deletions

View File

@ -82,8 +82,9 @@ import UIKit
func updateAccessibilityLabel() {
var message = "Radio Button, "
var message = MVMCoreUIUtility.hardcodedString(withKey: "radio_button") ?? ""
radioButton.updateAccessibilityLabel()
if let radioButtonLabel = radioButton.accessibilityLabel {
message += radioButtonLabel + ", "
}

View File

@ -14,7 +14,7 @@ open class ListLeftVariableRadioButtonBodyText: TableViewCell {
// MARK: - Outlets
//-----------------------------------------------------
let radioButton = RadioButton(frame: .zero)
let radioButton = RadioButton()
let headlineBody = HeadlineBody()
var stack: Stack<StackModel>
@ -42,6 +42,10 @@ open class ListLeftVariableRadioButtonBodyText: TableViewCell {
addMolecule(stack)
stack.restack()
isAccessibilityElement = true
updateAccessibilityLabel()
accessibilityTraits = .button
accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "radio_action_hint")
}
//----------------------------------------------------
@ -55,6 +59,7 @@ open class ListLeftVariableRadioButtonBodyText: TableViewCell {
radioButton.set(with: model.radioButton, delegateObject, additionalData)
headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
updateAccessibilityLabel()
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
@ -64,4 +69,24 @@ open class ListLeftVariableRadioButtonBodyText: TableViewCell {
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 headlineLabel = headlineBody.headlineLabel.text {
message += headlineLabel + ", "
}
if let messageLabel = headlineBody.messageLabel.text {
message += messageLabel
}
accessibilityLabel = message
}
}

View File

@ -9,21 +9,39 @@
import Foundation
import MVMCore
@objcMembers public class MoleculeListItemModel: ListItemModel, MoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public class var identifier: String {
return "listItem"
}
public var molecule: MoleculeModelProtocol
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case moleculeName
case molecule
}
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(with moleculeModel: MoleculeModelProtocol) {
molecule = moleculeModel
super.init()
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
@ -38,4 +56,3 @@ import MVMCore
try container.encodeModel(molecule, forKey: .molecule)
}
}

View File

@ -10,8 +10,9 @@ import UIKit
@objcMembers open class MoleculeTableViewCell: TableViewCell {
//--------------------------------------------------
// MARK: - MoleculeViewProtocol
//--------------------------------------------------
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {

View File

@ -9,9 +9,16 @@
import UIKit
open class ModalMoleculeListTemplate: MoleculeListTemplate {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var closeButton: MFCustomButton?
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------
override open func handleNewData() {
super.handleNewData()
closeButton = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: { _ in

View File

@ -12,6 +12,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
//--------------------------------------------------
// MARK: - Stored Properties
//--------------------------------------------------
public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: (ListItemModelProtocol & MoleculeModelProtocol))]?
var observer: NSKeyValueObservation?
@ -208,8 +209,11 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
func getMoleculeInfo(with listItem: (ListItemModelProtocol & MoleculeModelProtocol)?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol & MoleculeModelProtocol)? {
guard let listItem = listItem,
let moleculeClass = MoleculeObjectMapping.shared()?.getMoleculeClass(listItem) else { return nil }
let moleculeClass = MoleculeObjectMapping.shared()?.getMoleculeClass(listItem)
else { return nil }
let moleculeName = moleculeClass.nameForReuse(with: listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName
return (moleculeName, moleculeClass, listItem)
}

View File

@ -53,6 +53,7 @@
// MARK: Radio Button
"radio_button" = "Radio Button,";
"radio_action_hint" = "Double tap to select";
"radio_selected_state" = "Selected";
"radio_not_selected_state" = "Not Selected";