ONEAPP-4828 - Accessibility - Toggle (State)

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-10-27 13:15:08 -05:00
parent 196bc52288
commit 2f3759ae90
2 changed files with 5 additions and 8 deletions

View File

@ -60,7 +60,6 @@ open class Toggle: Control, Changeable, FormFieldable {
//--------------------------------------------------
private let toggleContainerSize = CGSize(width: 52, height: 44)
private let spacingBetween = VDSLayout.Spacing.space3X.value
private let labelMaxWidth = 40.0
/// TextStyle used to render the label.
private var textStyle: TextStyle {
@ -187,9 +186,7 @@ open class Toggle: Control, Changeable, FormFieldable {
accessibilityTraits = .button
addSubview(label)
addSubview(toggleView)
label.widthLessThanEqualTo(labelMaxWidth)
// Set up initial constraints for label and switch
toggleView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
@ -247,14 +244,13 @@ open class Toggle: Control, Changeable, FormFieldable {
/// Used to update any Accessibility properties.
open override func updateAccessibility() {
super.updateAccessibility()
if showText {
setAccessibilityLabel(for: [label])
accessibilityValue = isSelected ? onText : offText
} else {
accessibilityLabel = "Toggle"
accessibilityValue = isSelected ? "On" : "Off"
}
}
/// This will change the state of the Selector and execute the actionBlock if provided.
open func toggle() {
isOn.toggle()

View File

@ -1,6 +1,7 @@
1.0.47
=======
- ONEAPP-4684 - Acessibility - Tooltip (Header)
- ONEAPP-4828 - Accessibility - Toggle (State)
1.0.46
=======