diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 54eb1514..4d1107f5 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -18,14 +18,12 @@ EA33617D288B19210071C351 /* VDS.h in Headers */ = {isa = PBXBuildFile; fileRef = EA33616F288B19200071C351 /* VDS.h */; settings = {ATTRIBUTES = (Public, ); }; }; EA3361A8288B23300071C351 /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361A7288B23300071C351 /* UIColor.swift */; }; EA3361AA288B25E40071C351 /* Disabling.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361A9288B25E40071C351 /* Disabling.swift */; }; - EA3361AD288B26190071C351 /* DataTrackable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361AC288B26190071C351 /* DataTrackable.swift */; }; EA3361AF288B26310071C351 /* FormFieldable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361AE288B26310071C351 /* FormFieldable.swift */; }; EA3361B6288B2A410071C351 /* Control.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361B5288B2A410071C351 /* Control.swift */; }; EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361B7288B2AAA0071C351 /* ViewProtocol.swift */; }; EA3361BD288B2C760071C351 /* TypeAlias.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361BC288B2C760071C351 /* TypeAlias.swift */; }; EA3361BF288B2EA60071C351 /* Handlerable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361BE288B2EA60071C351 /* Handlerable.swift */; }; EA3361C328902D960071C351 /* Toggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C228902D960071C351 /* Toggle.swift */; }; - EA3361C5289030FC0071C351 /* Accessable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C4289030FC0071C351 /* Accessable.swift */; }; EA3361C9289054C50071C351 /* Surfaceable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C8289054C50071C351 /* Surfaceable.swift */; }; EA3362042891E14D0071C351 /* VerizonNHGeTX-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = EA3362002891E14C0071C351 /* VerizonNHGeTX-Bold.otf */; }; EA3362052891E14D0071C351 /* VerizonNHGeDS-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = EA3362012891E14D0071C351 /* VerizonNHGeDS-Bold.otf */; }; @@ -134,14 +132,12 @@ EA33617B288B19210071C351 /* VDSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSTests.swift; sourceTree = ""; }; EA3361A7288B23300071C351 /* UIColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColor.swift; sourceTree = ""; }; EA3361A9288B25E40071C351 /* Disabling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Disabling.swift; sourceTree = ""; }; - EA3361AC288B26190071C351 /* DataTrackable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataTrackable.swift; sourceTree = ""; }; EA3361AE288B26310071C351 /* FormFieldable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormFieldable.swift; sourceTree = ""; }; EA3361B5288B2A410071C351 /* Control.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Control.swift; sourceTree = ""; }; EA3361B7288B2AAA0071C351 /* ViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewProtocol.swift; sourceTree = ""; }; EA3361BC288B2C760071C351 /* TypeAlias.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TypeAlias.swift; sourceTree = ""; }; EA3361BE288B2EA60071C351 /* Handlerable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Handlerable.swift; sourceTree = ""; }; EA3361C228902D960071C351 /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = ""; }; - EA3361C4289030FC0071C351 /* Accessable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Accessable.swift; sourceTree = ""; }; EA3361C8289054C50071C351 /* Surfaceable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Surfaceable.swift; sourceTree = ""; }; EA3362002891E14C0071C351 /* VerizonNHGeTX-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeTX-Bold.otf"; sourceTree = ""; }; EA3362012891E14D0071C351 /* VerizonNHGeDS-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeDS-Bold.otf"; sourceTree = ""; }; @@ -392,10 +388,8 @@ EA3361AB288B25EC0071C351 /* Protocols */ = { isa = PBXGroup; children = ( - EA3361C4289030FC0071C351 /* Accessable.swift */, EA4DB2FC28D3D0CA00103EE3 /* AnyEquatable.swift */, EAA5EEDF28F49DB3003B3210 /* Colorable.swift */, - EA3361AC288B26190071C351 /* DataTrackable.swift */, EA3361A9288B25E40071C351 /* Disabling.swift */, EA5E305929510F8B0082B959 /* EnumSubset.swift */, EAF7F0A1289AFB3900B287F5 /* Errorable.swift */, @@ -773,7 +767,6 @@ EA985BF7296C665E00F2FF2E /* IconName.swift in Sources */, EAF7F0AF289B144C00B287F5 /* UnderlineLabelAttribute.swift in Sources */, EAC925842911C63100091998 /* Colorable.swift in Sources */, - EA3361C5289030FC0071C351 /* Accessable.swift in Sources */, EAB5FEF5292D371F00998C17 /* ButtonBase.swift in Sources */, EA978EC5291D6AFE00ACC883 /* AnyLabelAttribute.swift in Sources */, EA33622C2891E73B0071C351 /* FontProtocol.swift in Sources */, @@ -829,7 +822,6 @@ EAF7F0B7289C12A600B287F5 /* UITapGestureRecognizer.swift in Sources */, EA985BF9296C710100F2FF2E /* IconColor.swift in Sources */, EAB5FED429267EB300998C17 /* UIView.swift in Sources */, - EA3361AD288B26190071C351 /* DataTrackable.swift in Sources */, EA33623E2892EE950071C351 /* UIDevice.swift in Sources */, EA985C692971B90B00F2FF2E /* IconSize.swift in Sources */, EA985C672970C21600F2FF2E /* VDSLayout.swift in Sources */, diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index 4da338c3..9c8da789 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -17,6 +17,16 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab //-------------------------------------------------- public var subject = PassthroughSubject() public var subscribers = Set() + open var onClickSubscriber: AnyCancellable? { + willSet { + if let onClickSubscriber { + onClickSubscriber.cancel() + } + } + didSet { + enabledHighlight = onClickSubscriber != nil + } + } //-------------------------------------------------- // MARK: - Properties @@ -103,7 +113,13 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- - open func updateView() {} + open func updateView() { + updateAccessibilityLabel() + } + + open func updateAccessibilityLabel() { + + } open func reset() { backgroundColor = .clear diff --git a/VDS/Classes/View.swift b/VDS/Classes/View.swift index c00a5887..c48ff108 100644 --- a/VDS/Classes/View.swift +++ b/VDS/Classes/View.swift @@ -75,7 +75,13 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable { //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- - open func updateView() {} + open func updateView() { + updateAccessibilityLabel() + } + + open func updateAccessibilityLabel() { + + } open func reset() { backgroundColor = .clear diff --git a/VDS/Components/Badge/Badge.swift b/VDS/Components/Badge/Badge.swift index 4d985695..8a0bc7b5 100644 --- a/VDS/Components/Badge/Badge.swift +++ b/VDS/Components/Badge/Badge.swift @@ -13,7 +13,7 @@ import Combine /// Badges are visual labels used to convey status or highlight supplemental information. @objc(VDSBadge) -public class Badge: View, Accessable { +public class Badge: View { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- @@ -39,18 +39,6 @@ public class Badge: View, Accessable { open var maxWidth: CGFloat? { didSet { didChange() }} open var numberOfLines: Int = 1 { didSet { didChange() }} - - open var accessibilityHintEnabled: String? { didSet { didChange() }} - - open var accessibilityHintDisabled: String? { didSet { didChange() }} - - open var accessibilityValueEnabled: String? { didSet { didChange() }} - - open var accessibilityValueDisabled: String? { didSet { didChange() }} - - open var accessibilityLabelEnabled: String? { didSet { didChange() }} - - open var accessibilityLabelDisabled: String? { didSet { didChange() }} //-------------------------------------------------- // MARK: - Constraints @@ -65,8 +53,7 @@ public class Badge: View, Accessable { open override func setup() { super.setup() - isAccessibilityElement = true - accessibilityTraits = .staticText + accessibilityElements = [label] layer.cornerRadius = VDSFormControls.borderradius addSubview(label) @@ -89,14 +76,6 @@ public class Badge: View, Accessable { text = "" maxWidth = nil numberOfLines = 1 - accessibilityHintEnabled = nil - accessibilityHintDisabled = nil - accessibilityValueEnabled = nil - accessibilityValueDisabled = nil - accessibilityLabelEnabled = nil - accessibilityLabelDisabled = nil - - setAccessibilityLabel() } //-------------------------------------------------- @@ -155,9 +134,6 @@ public class Badge: View, Accessable { } else { maxWidthConstraint?.isActive = false } - - setAccessibilityLabel() } - } diff --git a/VDS/Components/Buttons/Button/ButtonBase.swift b/VDS/Components/Buttons/Button/ButtonBase.swift index 4eeec6ee..3ced2661 100644 --- a/VDS/Components/Buttons/Button/ButtonBase.swift +++ b/VDS/Components/Buttons/Button/ButtonBase.swift @@ -143,6 +143,11 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab open func updateView() { updateLabel() + updateAccessibilityLabel() + } + + open func updateAccessibilityLabel() { + } //-------------------------------------------------- diff --git a/VDS/Components/Checkbox/Checkbox.swift b/VDS/Components/Checkbox/Checkbox.swift index a1a6a0fd..fc78cb7f 100644 --- a/VDS/Components/Checkbox/Checkbox.swift +++ b/VDS/Components/Checkbox/Checkbox.swift @@ -19,15 +19,15 @@ public class Checkbox: CheckboxBase{} public class SoloCheckbox: CheckboxBase{ public override func initialSetup() { super.initialSetup() - publisher(for: .touchUpInside) + onClickSubscriber = publisher(for: .touchUpInside) .sink { control in control.toggle() - }.store(in: &subscribers) + } } } @objc(VDSCheckboxBase) -open class CheckboxBase: Control, Accessable, DataTrackable, Errorable { +open class CheckboxBase: Control, Errorable { //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- @@ -153,24 +153,6 @@ open class CheckboxBase: Control, Accessable, DataTrackable, Errorable { open var value: AnyHashable? { didSet { didChange() }} - open var dataAnalyticsTrack: String? { didSet { didChange() }} - - open var dataClickStream: String? { didSet { didChange() }} - - open var dataTrack: String? { didSet { didChange() }} - - open var accessibilityHintEnabled: String? { didSet { didChange() }} - - open var accessibilityHintDisabled: String? { didSet { didChange() }} - - open var accessibilityValueEnabled: String? { didSet { didChange() }} - - open var accessibilityValueDisabled: String? { didSet { didChange() }} - - open var accessibilityLabelEnabled: String? { didSet { didChange() }} - - open var accessibilityLabelDisabled: String? { didSet { didChange() }} - //-------------------------------------------------- // MARK: - Constraints //-------------------------------------------------- @@ -286,19 +268,9 @@ open class CheckboxBase: Control, Accessable, DataTrackable, Errorable { errorText = nil inputId = nil value = nil - dataAnalyticsTrack = nil - dataClickStream = nil - dataTrack = nil - accessibilityHintEnabled = nil - accessibilityHintDisabled = nil - accessibilityValueEnabled = nil - accessibilityValueDisabled = nil - accessibilityLabelEnabled = nil - accessibilityLabelDisabled = nil isSelected = false updateSelector() - setAccessibilityLabel() } /// This will checkbox the state of the Selector and execute the actionBlock if provided. @@ -317,11 +289,12 @@ open class CheckboxBase: Control, Accessable, DataTrackable, Errorable { open override func updateView() { updateLabels() updateSelector() - setAccessibilityHint() - setAccessibilityValue(isSelected) - setAccessibilityLabel(isSelected) + updateAccessibilityLabel() } + open override func updateAccessibilityLabel() { + setAccessibilityLabel(for: [label, childLabel, errorLabel]) + } //-------------------------------------------------- // MARK: - Configuration Properties diff --git a/VDS/Components/Icon/Icon.swift b/VDS/Components/Icon/Icon.swift index e988d27a..04ba9875 100644 --- a/VDS/Components/Icon/Icon.swift +++ b/VDS/Components/Icon/Icon.swift @@ -89,6 +89,10 @@ public class Icon: View { } } + public override func updateAccessibilityLabel() { + + } + private func getImage(for imageName: String) -> UIImage? { return BundleManager.shared.image(for: imageName) diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index 07680837..5f347634 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -137,11 +137,15 @@ public class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable //set the attributed text attributedText = mutableText - accessibilityLabel = text + updateAccessibilityLabel() } } } + open func updateAccessibilityLabel() { + accessibilityLabel = text + } + // MARK: - Private Attributes private func applyAttributes(_ mutableAttributedString: NSMutableAttributedString) { actions = [] diff --git a/VDS/Components/RadioBox/RadioBox.swift b/VDS/Components/RadioBox/RadioBox.swift index 51b98e8d..b655b03b 100644 --- a/VDS/Components/RadioBox/RadioBox.swift +++ b/VDS/Components/RadioBox/RadioBox.swift @@ -19,15 +19,15 @@ public class SoloRadioBox: RadioBoxBase{ public override func initialSetup() { super.initialSetup() - publisher(for: .touchUpInside) + onClickSubscriber = publisher(for: .touchUpInside) .sink { control in control.toggle() - }.store(in: &subscribers) + } } } @objc(VDSRadioBoxBase) -open class RadioBoxBase: Control, Accessable, DataTrackable{ +open class RadioBoxBase: Control{ //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- @@ -133,24 +133,6 @@ open class RadioBoxBase: Control, Accessable, DataTrackable{ open var inputId: String? { didSet { didChange() }} open var value: AnyHashable? { didSet { didChange() }} - - open var dataAnalyticsTrack: String? { didSet { didChange() }} - - open var dataClickStream: String? { didSet { didChange() }} - - open var dataTrack: String? { didSet { didChange() }} - - open var accessibilityHintEnabled: String? { didSet { didChange() }} - - open var accessibilityHintDisabled: String? { didSet { didChange() }} - - open var accessibilityValueEnabled: String? { didSet { didChange() }} - - open var accessibilityValueDisabled: String? { didSet { didChange() }} - - open var accessibilityLabelEnabled: String? { didSet { didChange() }} - - open var accessibilityLabelDisabled: String? { didSet { didChange() }} //functions //-------------------------------------------------- @@ -242,20 +224,10 @@ open class RadioBoxBase: Control, Accessable, DataTrackable{ strikethrough = false inputId = nil value = nil - dataAnalyticsTrack = nil - dataClickStream = nil - dataTrack = nil - accessibilityHintEnabled = nil - accessibilityHintDisabled = nil - accessibilityValueEnabled = nil - accessibilityValueDisabled = nil - accessibilityLabelEnabled = nil - accessibilityLabelDisabled = nil isSelected = false updateSelector() - setAccessibilityLabel() } /// This will radioBox the state of the Selector and execute the actionBlock if provided. @@ -271,12 +243,13 @@ open class RadioBoxBase: Control, Accessable, DataTrackable{ open override func updateView() { updateLabels() updateSelector() - setAccessibilityHint() - setAccessibilityValue(isSelected) - setAccessibilityLabel(isSelected) + updateAccessibilityLabel() setNeedsDisplay() } + open override func updateAccessibilityLabel() { + setAccessibilityLabel(for: [textLabel, subTextLabel, subTextRightLabel]) + } //-------------------------------------------------- // MARK: - Configuration Properties diff --git a/VDS/Components/RadioButton/RadioButton.swift b/VDS/Components/RadioButton/RadioButton.swift index 884a8fd0..a8938ad6 100644 --- a/VDS/Components/RadioButton/RadioButton.swift +++ b/VDS/Components/RadioButton/RadioButton.swift @@ -26,15 +26,15 @@ public class RadioButton: RadioButtonBase { public class SoloRadioButton: RadioButtonBase { public override func initialSetup() { super.initialSetup() - publisher(for: .touchUpInside) + onClickSubscriber = publisher(for: .touchUpInside) .sink { control in control.toggle() - }.store(in: &subscribers) + } } } @objc(VDSRadioButtonBase) -open class RadioButtonBase: Control, Accessable, DataTrackable, Errorable { +open class RadioButtonBase: Control, Errorable { //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- @@ -147,24 +147,6 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, Errorable { open var value: AnyHashable? { didSet { didChange() }} - open var dataAnalyticsTrack: String? { didSet { didChange() }} - - open var dataClickStream: String? { didSet { didChange() }} - - open var dataTrack: String? { didSet { didChange() }} - - open var accessibilityHintEnabled: String? { didSet { didChange() }} - - open var accessibilityHintDisabled: String? { didSet { didChange() }} - - open var accessibilityValueEnabled: String? { didSet { didChange() }} - - open var accessibilityValueDisabled: String? { didSet { didChange() }} - - open var accessibilityLabelEnabled: String? { didSet { didChange() }} - - open var accessibilityLabelDisabled: String? { didSet { didChange() }} - //-------------------------------------------------- // MARK: - Constraints //-------------------------------------------------- @@ -283,20 +265,10 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, Errorable { errorText = nil inputId = nil value = nil - dataAnalyticsTrack = nil - dataClickStream = nil - dataTrack = nil - accessibilityHintEnabled = nil - accessibilityHintDisabled = nil - accessibilityValueEnabled = nil - accessibilityValueDisabled = nil - accessibilityLabelEnabled = nil - accessibilityLabelDisabled = nil isSelected = false updateSelector() - setAccessibilityLabel() } /// This will checkbox the state of the Selector and execute the actionBlock if provided. @@ -317,9 +289,11 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, Errorable { open override func updateView() { updateLabels() updateSelector() - setAccessibilityHint() - setAccessibilityValue(isSelected) - setAccessibilityLabel(isSelected) + updateAccessibilityLabel() + } + + open override func updateAccessibilityLabel() { + setAccessibilityLabel(for: [label, childLabel]) } //-------------------------------------------------- diff --git a/VDS/Components/RadioSwatch/RadioSwatch.swift b/VDS/Components/RadioSwatch/RadioSwatch.swift index d0569c01..105e0dea 100644 --- a/VDS/Components/RadioSwatch/RadioSwatch.swift +++ b/VDS/Components/RadioSwatch/RadioSwatch.swift @@ -23,15 +23,15 @@ public class RadioSwatch: RadioSwatchBase{ public class SolorRadioSwatch: RadioSwatchBase{ public override func initialSetup() { super.initialSetup() - publisher(for: .touchUpInside) + onClickSubscriber = publisher(for: .touchUpInside) .sink { control in control.toggle() - }.store(in: &subscribers) + } } } @objc(VDSRadioSwatchBase) -open class RadioSwatchBase: Control, Accessable, DataTrackable { +open class RadioSwatchBase: Control { //-------------------------------------------------- // MARK: - Initializers @@ -74,24 +74,6 @@ open class RadioSwatchBase: Control, Accessable, DataTrackable { open var value: AnyHashable? { didSet { didChange() }} - open var dataAnalyticsTrack: String? { didSet { didChange() }} - - open var dataClickStream: String? { didSet { didChange() }} - - open var dataTrack: String? { didSet { didChange() }} - - open var accessibilityHintEnabled: String? { didSet { didChange() }} - - open var accessibilityHintDisabled: String? { didSet { didChange() }} - - open var accessibilityValueEnabled: String? { didSet { didChange() }} - - open var accessibilityValueDisabled: String? { didSet { didChange() }} - - open var accessibilityLabelEnabled: String? { didSet { didChange() }} - - open var accessibilityLabelDisabled: String? { didSet { didChange() }} - //functions //-------------------------------------------------- // MARK: - Lifecycle @@ -130,18 +112,8 @@ open class RadioSwatchBase: Control, Accessable, DataTrackable { strikethrough = false inputId = nil value = nil - dataAnalyticsTrack = nil - dataClickStream = nil - dataTrack = nil - accessibilityHintEnabled = nil - accessibilityHintDisabled = nil - accessibilityValueEnabled = nil - accessibilityValueDisabled = nil - accessibilityLabelEnabled = nil - accessibilityLabelDisabled = nil setNeedsDisplay() - setAccessibilityLabel() } open func toggle() { @@ -153,12 +125,13 @@ open class RadioSwatchBase: Control, Accessable, DataTrackable { // MARK: - State //-------------------------------------------------- open override func updateView() { - setAccessibilityHint() - setAccessibilityValue(isSelected) - setAccessibilityLabel(isSelected) layer.setNeedsDisplay() } + public override func updateAccessibilityLabel() { + accessibilityLabel = text + } + //-------------------------------------------------- // MARK: - Configuration Properties //-------------------------------------------------- diff --git a/VDS/Components/TextFields/EntryField/EntryField.swift b/VDS/Components/TextFields/EntryField/EntryField.swift index 35b2d460..321aa074 100644 --- a/VDS/Components/TextFields/EntryField/EntryField.swift +++ b/VDS/Components/TextFields/EntryField/EntryField.swift @@ -12,7 +12,7 @@ import VDSFormControlsTokens import Combine @objc(VDSEntryField) -open class EntryField: Control, Accessable { +open class EntryField: Control { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- @@ -160,18 +160,6 @@ open class EntryField: Control, Accessable { open var readOnly: Bool = false { didSet { didChange() }} - open var accessibilityHintEnabled: String? { didSet { didChange() }} - - open var accessibilityHintDisabled: String? { didSet { didChange() }} - - open var accessibilityValueEnabled: String? { didSet { didChange() }} - - open var accessibilityValueDisabled: String? { didSet { didChange() }} - - open var accessibilityLabelEnabled: String? { didSet { didChange() }} - - open var accessibilityLabelDisabled: String? { didSet { didChange() }} - //-------------------------------------------------- // MARK: - Constraints //-------------------------------------------------- @@ -302,14 +290,6 @@ open class EntryField: Control, Accessable { defaultValue = nil required = false readOnly = false - accessibilityHintEnabled = nil - accessibilityHintDisabled = nil - accessibilityValueEnabled = nil - accessibilityValueDisabled = nil - accessibilityLabelEnabled = nil - accessibilityLabelDisabled = nil - - setAccessibilityLabel() } //-------------------------------------------------- @@ -326,7 +306,6 @@ open class EntryField: Control, Accessable { updateErrorLabel() updateHelperLabel() - setAccessibilityHint() backgroundColor = surface.color } diff --git a/VDS/Components/TextFields/InputField/InputField.swift b/VDS/Components/TextFields/InputField/InputField.swift index ea2f3d87..80c765ab 100644 --- a/VDS/Components/TextFields/InputField/InputField.swift +++ b/VDS/Components/TextFields/InputField/InputField.swift @@ -197,6 +197,10 @@ public class InputField: EntryField, UITextFieldDelegate { } } + public override func updateAccessibilityLabel() { + + } + open override func updateHelperLabel(){ //remove first helperLabel.removeFromSuperview() diff --git a/VDS/Components/Tilelet/Tilelet.swift b/VDS/Components/Tilelet/Tilelet.swift index 2c64e2a0..f6daedc8 100644 --- a/VDS/Components/Tilelet/Tilelet.swift +++ b/VDS/Components/Tilelet/Tilelet.swift @@ -9,6 +9,7 @@ import Foundation import Foundation import VDSColorTokens import UIKit +import Combine @objc(VDSTilelet) open class Tilelet: TileContainer { @@ -61,6 +62,13 @@ open class Tilelet: TileContainer { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- + open override var onClickSubscriber: AnyCancellable? { + didSet { + isAccessibilityElement = onClickSubscriber != nil + //updateAccessibilityLabel() + } + } + open var titleLockup = TitleLockup().with { let configs = [ TextStyle.DeviceSpacingConfig([.titleSmall, .boldTitleSmall], @@ -213,8 +221,8 @@ open class Tilelet: TileContainer { color = .black addContentView(stackView) - isAccessibilityElement = true - accessibilityTraits = .staticText + accessibilityTraits = .link + accessibilityElements = [badge, titleLockup, descriptiveIcon, directionalIcon] //badge badgeContainerView.addSubview(badge) @@ -333,9 +341,6 @@ open class Tilelet: TileContainer { } else { removeFromSuperview(titleLockupContainerView) } - - accessibilityTraits = enabledHighlight ? .link : .staticText - accessibilityLabel = [titleModel?.text, subTitleModel?.text].compactMap({$0}).joined(separator: ", ") } fileprivate func updateIcons() { @@ -387,6 +392,11 @@ open class Tilelet: TileContainer { updateIcons() layoutIfNeeded() + updateAccessibilityLabel() + } + + open override func updateAccessibilityLabel() { + setAccessibilityLabel(for: [badge.label, titleLockup.eyebrowLabel, titleLockup.titleLabel, titleLockup.subTitleLabel]) } } diff --git a/VDS/Components/TitleLockup/TitleLockup.swift b/VDS/Components/TitleLockup/TitleLockup.swift index d0dc9562..ff48c217 100644 --- a/VDS/Components/TitleLockup/TitleLockup.swift +++ b/VDS/Components/TitleLockup/TitleLockup.swift @@ -202,8 +202,7 @@ open class TitleLockup: View { open override func setup() { super.setup() - isAccessibilityElement = true - accessibilityTraits = .staticText + accessibilityElements = [eyebrowLabel, titleLabel, subTitleLabel] addSubview(stackView) stackView.spacing = 0.0 @@ -299,8 +298,6 @@ open class TitleLockup: View { eyebrowLabel.isHidden = eyebrowTextIsEmpty titleLabel.isHidden = titleTextIsEmpty subTitleLabel.isHidden = subTitleTextIsEmpty - - accessibilityLabel = [eyebrowModel?.text, titleModel?.text, subTitleModel?.text].compactMap({$0}).joined(separator: ", ") } } diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index 5be09876..499d394d 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -29,7 +29,7 @@ public class Toggle: ToggleBase{ } @objc(VDSToggleBase) -open class ToggleBase: Control, Accessable, DataTrackable { +open class ToggleBase: Control { //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- @@ -148,25 +148,7 @@ open class ToggleBase: Control, Accessable, DataTrackable { open var inputId: String? { didSet { didChange() }} open var value: AnyHashable? { didSet { didChange() }} - - open var dataAnalyticsTrack: String? { didSet { didChange() }} - - open var dataClickStream: String? { didSet { didChange() }} - - open var dataTrack: String? { didSet { didChange() }} - - open var accessibilityHintEnabled: String? { didSet { didChange() }} - - open var accessibilityHintDisabled: String? { didSet { didChange() }} - - open var accessibilityValueEnabled: String? { didSet { didChange() }} - - open var accessibilityValueDisabled: String? { didSet { didChange() }} - - open var accessibilityLabelEnabled: String? { didSet { didChange() }} - - open var accessibilityLabelDisabled: String? { didSet { didChange() }} - + //-------------------------------------------------- // MARK: - Constraints //-------------------------------------------------- @@ -305,7 +287,6 @@ open class ToggleBase: Control, Accessable, DataTrackable { toggleView.backgroundColor = toggleColorConfiguration.getColor(self) knobView.backgroundColor = knobColorConfiguration.getColor(self) - setAccessibilityLabel() } /// This will toggle the state of the Toggle and execute the actionBlock if provided. @@ -320,8 +301,10 @@ open class ToggleBase: Control, Accessable, DataTrackable { open override func updateView() { updateLabel() updateToggle() - setAccessibilityHint() - setAccessibilityValue(isOn) - setAccessibilityLabel(isOn) + updateAccessibilityLabel() + } + + open override func updateAccessibilityLabel() { + setAccessibilityLabel(for: [label]) } } diff --git a/VDS/Protocols/Accessable.swift b/VDS/Protocols/Accessable.swift deleted file mode 100644 index 75d44fca..00000000 --- a/VDS/Protocols/Accessable.swift +++ /dev/null @@ -1,49 +0,0 @@ -// -// Accessable.swift -// VDS -// -// Created by Matt Bruce on 7/26/22. -// - -import Foundation -import UIKit - -public protocol Accessable { - var accessibilityHintEnabled: String? { get set } - var accessibilityHintDisabled: String? { get set } - var accessibilityValueEnabled: String? { get set } - var accessibilityValueDisabled: String? { get set } - var accessibilityLabelEnabled: String? { get set } - var accessibilityLabelDisabled: String? { get set } -} - -//Configurations to set within the UIControl -extension Handlerable where Self: UIView, Self: Accessable { - - public func setAccessibilityHint(_ override: Bool? = nil) { - let check = override ?? !disabled - if let value = accessibilityHintEnabled, check { - accessibilityHint = value - } else if let value = accessibilityHintDisabled, !check { - accessibilityHint = value - } - } - - public func setAccessibilityValue(_ override: Bool? = nil) { - let check = override ?? !disabled - if let value = accessibilityValueEnabled, check { - accessibilityValue = value - } else if let value = accessibilityValueDisabled, !check { - accessibilityValue = value - } - } - - public func setAccessibilityLabel(_ override: Bool? = nil) { - let check = override ?? !disabled - if let value = accessibilityLabelEnabled, check { - accessibilityLabel = value - } else if let value = accessibilityLabelDisabled, !check { - accessibilityLabel = value - } - } -} diff --git a/VDS/Protocols/DataTrackable.swift b/VDS/Protocols/DataTrackable.swift deleted file mode 100644 index 5fb8f810..00000000 --- a/VDS/Protocols/DataTrackable.swift +++ /dev/null @@ -1,14 +0,0 @@ -// -// DataTrackable.swift -// VDS -// -// Created by Matt Bruce on 7/22/22. -// - -import Foundation - -public protocol DataTrackable { - var dataAnalyticsTrack: String? { get set } - var dataClickStream: String? { get set } - var dataTrack: String? { get set } -} diff --git a/VDS/Protocols/Handlerable.swift b/VDS/Protocols/Handlerable.swift index 0c644b8a..f9ad8770 100644 --- a/VDS/Protocols/Handlerable.swift +++ b/VDS/Protocols/Handlerable.swift @@ -25,7 +25,6 @@ extension Handlerable { public func handlerPublisher() -> AnyPublisher { subject - .debounce(for: .seconds(Constants.StateDebounce), scheduler: RunLoop.main) .eraseToAnyPublisher() } } diff --git a/VDS/Protocols/ViewProtocol.swift b/VDS/Protocols/ViewProtocol.swift index d8acfb57..a73b83c5 100644 --- a/VDS/Protocols/ViewProtocol.swift +++ b/VDS/Protocols/ViewProtocol.swift @@ -12,6 +12,7 @@ public protocol ViewProtocol { // Can setup ui here. Should be called in the initialization functions. func setup() + func updateAccessibilityLabel() } extension ViewProtocol where Self: UIView { @@ -21,4 +22,13 @@ extension ViewProtocol where Self: UIView { setNeedsDisplay() } } + + public func combineAccessibilityLabel(for views: [UIView]) -> String? { + let labels = views.map({($0.accessibilityLabel?.isEmpty ?? true) ? nil : $0.accessibilityLabel}).compactMap({$0}) + return labels.joined(separator: ", ") + } + + public func setAccessibilityLabel(for views: [UIView]) { + accessibilityLabel = combineAccessibilityLabel(for: views) + } }