Digital ACT-191 ONEAPP-9311 story: added accessibility changes

This commit is contained in:
Vasavi Kanamarlapudi 2024-07-29 16:17:52 +05:30
parent 90eb01cb24
commit 3ea4b74af2

View File

@ -104,6 +104,11 @@ open class InputStepper: EntryFieldBase {
/// Accepts any text or character to appear next to input stepper value.
open var trailingText: String? { didSet { setNeedsUpdate() } }
/// Value for the textField
open override var value: String? {
return nil
}
//--------------------------------------------------
// MARK: - Private Properties
//--------------------------------------------------
@ -111,6 +116,7 @@ open class InputStepper: EntryFieldBase {
/// The only subview of this view is the stepperStackView.
internal var stepperContainerView = View().with {
$0.isAccessibilityElement = true
$0.accessibilityLabel = "Input Stepper"
}
internal var stepperStackView = UIStackView().with {
@ -145,7 +151,7 @@ open class InputStepper: EntryFieldBase {
$0.lineBreakMode = .byTruncatingTail
$0.textAlignment = .center
}
//--------------------------------------------------
// MARK: - Constraints
//--------------------------------------------------
@ -175,11 +181,7 @@ open class InputStepper: EntryFieldBase {
/// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations.
open override func setup() {
super.setup()
// accessibility
isAccessibilityElement = false
accessibilityLabel = "Input Stepper"
// Set initial states
containerView.isEnabled = false
statusIcon.isHidden = true
@ -238,6 +240,30 @@ open class InputStepper: EntryFieldBase {
setNeedsLayout()
}
open override var accessibilityElements: [Any]? {
get {
var elements = [Any]()
if !isReadOnly || isEnabled {
elements.append(contentsOf: [titleLabel, containerView, decrementButton, textLabel, incrementButton])
} else {
elements.append(contentsOf: [titleLabel, containerView, textLabel])
}
if showError {
if let errorText, !errorText.isEmpty {
elements.append(errorLabel)
}
}
if let helperText, !helperText.isEmpty {
elements.append(helperLabel)
}
return elements
}
set { super.accessibilityElements = newValue }
}
/// Resets to default settings.
open override func reset() {
super.reset()