From 3ea4b74af2fa1ba35b098e9dce483339bbdc236e Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Mon, 29 Jul 2024 16:17:52 +0530 Subject: [PATCH] Digital ACT-191 ONEAPP-9311 story: added accessibility changes --- .../InputStepper/InputStepper.swift | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/VDS/Components/InputStepper/InputStepper.swift b/VDS/Components/InputStepper/InputStepper.swift index 5abf8724..b9139b5a 100644 --- a/VDS/Components/InputStepper/InputStepper.swift +++ b/VDS/Components/InputStepper/InputStepper.swift @@ -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()