Merge branch 'feature/accessible_radio_state' into 'develop'
Accessible radio state See merge request BPHV_MIPS/mvm_core_ui!408
This commit is contained in:
commit
d03c20f1ee
@ -19,13 +19,14 @@ import UIKit
|
|||||||
widthConstraint?.constant = diameter
|
widthConstraint?.constant = diameter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override var isSelected: Bool {
|
public override var isSelected: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
radioModel?.state = isSelected
|
radioModel?.state = isSelected
|
||||||
|
updateAccessibilityLabel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public var enabledColor: UIColor = .mvmBlack
|
public var enabledColor: UIColor = .mvmBlack
|
||||||
public var disabledColor: UIColor = .mvmCoolGray3
|
public var disabledColor: UIColor = .mvmCoolGray3
|
||||||
public var delegateObject: MVMCoreUIDelegateObject?
|
public var delegateObject: MVMCoreUIDelegateObject?
|
||||||
@ -39,12 +40,12 @@ import UIKit
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
lazy public var radioButtonSelectionHelper: RadioButtonSelectionHelper? = {
|
lazy public var radioButtonSelectionHelper: RadioButtonSelectionHelper? = {
|
||||||
if let radioGroupName = radioGroupName,
|
|
||||||
let radioButtonModel = delegateObject?.formHolderDelegate?.formValidator?.radioButtonsModelByGroup[radioGroupName] {
|
guard let radioGroupName = radioGroupName,
|
||||||
return radioButtonModel
|
let radioButtonModel = delegateObject?.formHolderDelegate?.formValidator?.radioButtonsModelByGroup[radioGroupName]
|
||||||
} else {
|
else { return nil }
|
||||||
return nil
|
|
||||||
}
|
return radioButtonModel
|
||||||
}()
|
}()
|
||||||
|
|
||||||
public override var isEnabled: Bool {
|
public override var isEnabled: Bool {
|
||||||
@ -118,6 +119,18 @@ import UIKit
|
|||||||
return radioModel?.fieldValue
|
return radioModel?.fieldValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Methods
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
/// Adjust accessibility label based on state of RadioButton.
|
||||||
|
func updateAccessibilityLabel() {
|
||||||
|
|
||||||
|
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 +149,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