adding accessibility state to radio button
This commit is contained in:
parent
8a907db560
commit
0dc3298942
@ -23,6 +23,7 @@ import UIKit
|
|||||||
public override var isSelected: Bool {
|
public override var isSelected: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
radioModel?.state = isSelected
|
radioModel?.state = isSelected
|
||||||
|
updateAccessibilityLabel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,6 +119,19 @@ import UIKit
|
|||||||
return radioModel?.fieldValue
|
return radioModel?.fieldValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Methods
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
/// Adjust accessibility label based on state of RadioButton.
|
||||||
|
func updateAccessibilityLabel() {
|
||||||
|
// Attention: This needs to be addressed with the accessibility team.
|
||||||
|
// NOTE: Currently emptying description part of MVMCoreUICheckBox accessibility label to avoid crashing!
|
||||||
|
if let state = MVMCoreUIUtility.hardcodedString(withKey: isSelected ? "radio_selected_state" : "radio_not_selected_state") {
|
||||||
|
accessibilityLabel = String(format: MVMCoreUIUtility.hardcodedString(withKey: "radio_desc_state") ?? "%@%@", "", state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - MVMViewProtocol
|
// MARK: - MVMViewProtocol
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -136,14 +150,15 @@ import UIKit
|
|||||||
isAccessibilityElement = true
|
isAccessibilityElement = true
|
||||||
accessibilityTraits = .button
|
accessibilityTraits = .button
|
||||||
accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "radio_action_hint")
|
accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "radio_action_hint")
|
||||||
|
updateAccessibilityLabel()
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
super.set(with: model, delegateObject, additionalData)
|
super.set(with: model, delegateObject, additionalData)
|
||||||
|
self.delegateObject = delegateObject
|
||||||
|
|
||||||
guard let model = model as? RadioButtonModel else { return }
|
guard let model = model as? RadioButtonModel else { return }
|
||||||
|
|
||||||
self.delegateObject = delegateObject
|
|
||||||
isSelected = model.state
|
isSelected = model.state
|
||||||
isEnabled = model.enabled
|
isEnabled = model.enabled
|
||||||
RadioButtonSelectionHelper.setupForRadioButtonGroup(model, self, delegateObject: delegateObject)
|
RadioButtonSelectionHelper.setupForRadioButtonGroup(model, self, delegateObject: delegateObject)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user