Merge branch 'feature/accessibilityUpdate' into 'develop'

added some accessibilty updates

See merge request BPHV_MIPS/vds_ios!45
This commit is contained in:
Bruce, Matt R 2023-03-03 22:32:52 +00:00
commit 9fde93d798
11 changed files with 78 additions and 65 deletions

View File

@ -118,6 +118,9 @@ open class Button: ButtonBase, Useable {
open override func setup() { open override func setup() {
super.setup() super.setup()
isAccessibilityElement = true
accessibilityTraits = .button
//only 1 of the 2 widths can be on at the same time //only 1 of the 2 widths can be on at the same time
widthConstraint = widthAnchor.constraint(equalToConstant: 0) widthConstraint = widthAnchor.constraint(equalToConstant: 0)
minWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: size.minimumWidth) minWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: size.minimumWidth)

View File

@ -109,7 +109,6 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
backgroundColor = .clear backgroundColor = .clear
translatesAutoresizingMaskIntoConstraints = false translatesAutoresizingMaskIntoConstraints = false
accessibilityCustomActions = [] accessibilityCustomActions = []
accessibilityTraits = .staticText
setup() setup()
setupDidChangeEvent() setupDidChangeEvent()
updateView() updateView()
@ -130,7 +129,6 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
disabled = false disabled = false
text = nil text = nil
accessibilityCustomActions = [] accessibilityCustomActions = []
accessibilityTraits = .button
} }
//-------------------------------------------------- //--------------------------------------------------

View File

@ -133,8 +133,6 @@ open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelega
//-------------------------------------------------- //--------------------------------------------------
open override func setup() { open override func setup() {
super.setup() super.setup()
isAccessibilityElement = true
accessibilityTraits = .button
addSubview(collectionView) addSubview(collectionView)
collectionView.pinToSuperView() collectionView.pinToSuperView()
} }

View File

@ -73,7 +73,9 @@ open class TextLink: ButtonBase {
//-------------------------------------------------- //--------------------------------------------------
open override func setup() { open override func setup() {
super.setup() super.setup()
isAccessibilityElement = true
accessibilityTraits = .link
if let titleLabel { if let titleLabel {
addSubview(line) addSubview(line)
line.pinLeading(titleLabel.leadingAnchor) line.pinLeading(titleLabel.leadingAnchor)
@ -88,7 +90,8 @@ open class TextLink: ButtonBase {
super.reset() super.reset()
size = .large size = .large
accessibilityCustomActions = [] accessibilityCustomActions = []
accessibilityTraits = .staticText isAccessibilityElement = true
accessibilityTraits = .link
} }
//-------------------------------------------------- //--------------------------------------------------

View File

@ -231,6 +231,9 @@ internal class CaretView: View {
override open func setup() { override open func setup() {
super.setup() super.setup()
defaultState() defaultState()
isAccessibilityElement = true
accessibilityTraits = .link
} }
//------------------------------------------------------ //------------------------------------------------------

View File

@ -75,8 +75,6 @@ public class CheckboxGroupBase<HandlerType: CheckboxBase>: SelectorGroupHandlerB
open override func setup() { open override func setup() {
super.setup() super.setup()
isAccessibilityElement = true
accessibilityTraits = .button
addSubview(mainStackView) addSubview(mainStackView)
mainStackView.pinToSuperView() mainStackView.pinToSuperView()

View File

@ -49,6 +49,9 @@ public class Icon: View {
widthConstraint?.isActive = true widthConstraint?.isActive = true
backgroundColor = .clear backgroundColor = .clear
isAccessibilityElement = true
accessibilityTraits = .image
} }
open override func reset() { open override func reset() {

View File

@ -109,8 +109,6 @@ public class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable
textPosition = .left textPosition = .left
text = nil text = nil
attributedText = nil attributedText = nil
accessibilityCustomActions = []
accessibilityTraits = .staticText
numberOfLines = 0 numberOfLines = 0
backgroundColor = .clear backgroundColor = .clear
} }
@ -125,9 +123,9 @@ public class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable
font = textStyle.font font = textStyle.font
if let text = text, let font = font, let textColor = textColor { if let text = text, let font = font, let textColor = textColor {
//clear the arrays holding actions
accessibilityCustomActions = [] accessibilityCustomActions = []
//clear the arrays holding actions
//create the primary string //create the primary string
let startingAttributes = [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: textColor] let startingAttributes = [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: textColor]
let mutableText = NSMutableAttributedString(string: text, attributes: startingAttributes) let mutableText = NSMutableAttributedString(string: text, attributes: startingAttributes)
@ -139,10 +137,11 @@ public class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable
//set the attributed text //set the attributed text
attributedText = mutableText attributedText = mutableText
accessibilityLabel = text
} }
} }
} }
// MARK: - Private Attributes // MARK: - Private Attributes
private func applyAttributes(_ mutableAttributedString: NSMutableAttributedString) { private func applyAttributes(_ mutableAttributedString: NSMutableAttributedString) {
actions = [] actions = []

View File

@ -82,8 +82,6 @@ public class RadioSwatchGroupBase<HandlerType: RadioSwatchBase>: SelectorGroupSe
open override func setup() { open override func setup() {
super.setup() super.setup()
isAccessibilityElement = true
accessibilityTraits = .button
addSubview(label) addSubview(label)
addSubview(collectionView) addSubview(collectionView)

View File

@ -48,75 +48,75 @@ open class Tilelet: TileContainer {
private var titleLockupContainerView = UIView().with { private var titleLockupContainerView = UIView().with {
$0.translatesAutoresizingMaskIntoConstraints = false $0.translatesAutoresizingMaskIntoConstraints = false
} }
private var badgeContainerView = UIView().with { private var badgeContainerView = UIView().with {
$0.translatesAutoresizingMaskIntoConstraints = false $0.translatesAutoresizingMaskIntoConstraints = false
} }
private let iconContainerView = UIView().with { private let iconContainerView = UIView().with {
$0.translatesAutoresizingMaskIntoConstraints = false $0.translatesAutoresizingMaskIntoConstraints = false
$0.backgroundColor = .clear $0.backgroundColor = .clear
} }
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Public Properties // MARK: - Public Properties
//-------------------------------------------------- //--------------------------------------------------
open var titleLockup = TitleLockup().with { open var titleLockup = TitleLockup().with {
let configs = [ let configs = [
TextStyle.DeviceSpacingConfig([.titleSmall, .boldTitleSmall], TextStyle.DeviceSpacingConfig([.titleSmall, .boldTitleSmall],
neighboring: [ neighboring: [
.bodySmall, .boldBodySmall, .bodySmall, .boldBodySmall,
.bodyMedium, .boldBodyMedium .bodyMedium, .boldBodyMedium
], ],
spacing: 8.0, spacing: 8.0,
deviceType: .iPhone), deviceType: .iPhone),
TextStyle.DeviceSpacingConfig([.titleMedium, .boldTitleMedium, TextStyle.DeviceSpacingConfig([.titleMedium, .boldTitleMedium,
.titleLarge, .boldTitleLarge], .titleLarge, .boldTitleLarge],
neighboring: [ neighboring: [
.bodySmall, .boldBodySmall, .bodySmall, .boldBodySmall,
.bodyMedium, .boldBodyMedium, .bodyMedium, .boldBodyMedium,
.bodyLarge, .boldBodyLarge], .bodyLarge, .boldBodyLarge],
spacing: 8.0, spacing: 8.0,
deviceType: .iPhone), deviceType: .iPhone),
TextStyle.DeviceSpacingConfig([.titleXLarge, .boldTitleXLarge], TextStyle.DeviceSpacingConfig([.titleXLarge, .boldTitleXLarge],
neighboring: [ neighboring: [
.bodySmall, .boldBodySmall, .bodySmall, .boldBodySmall,
.bodyMedium, .boldBodyMedium, .bodyMedium, .boldBodyMedium,
.bodyLarge, .boldBodyLarge, .bodyLarge, .boldBodyLarge,
.titleMedium, .boldTitleMedium .titleMedium, .boldTitleMedium
], ],
spacing: 12.0, spacing: 12.0,
deviceType: .iPhone), deviceType: .iPhone),
TextStyle.DeviceSpacingConfig([.titleSmall, .boldTitleSmall, TextStyle.DeviceSpacingConfig([.titleSmall, .boldTitleSmall,
.titleMedium, .boldTitleMedium], .titleMedium, .boldTitleMedium],
neighboring: [ neighboring: [
.bodySmall, .boldBodySmall, .bodySmall, .boldBodySmall,
.bodyMedium, .boldBodyMedium, .bodyMedium, .boldBodyMedium,
.bodyLarge, .boldBodyLarge .bodyLarge, .boldBodyLarge
], ],
spacing: 8.0, spacing: 8.0,
deviceType: .iPad), deviceType: .iPad),
TextStyle.DeviceSpacingConfig([.titleLarge, .boldTitleLarge], TextStyle.DeviceSpacingConfig([.titleLarge, .boldTitleLarge],
neighboring: [ neighboring: [
.bodySmall, .boldBodySmall, .bodySmall, .boldBodySmall,
.bodyMedium, .boldBodyMedium, .bodyMedium, .boldBodyMedium,
.bodyLarge, .boldBodyLarge, .bodyLarge, .boldBodyLarge,
.titleSmall, .boldTitleSmall .titleSmall, .boldTitleSmall
], ],
spacing: 12.0, spacing: 12.0,
deviceType: .iPad), deviceType: .iPad),
TextStyle.DeviceSpacingConfig([.titleXLarge, .boldTitleXLarge], TextStyle.DeviceSpacingConfig([.titleXLarge, .boldTitleXLarge],
neighboring: [ neighboring: [
.bodyLarge, .boldBodyLarge, .bodyLarge, .boldBodyLarge,
.titleMedium, .boldTitleMedium .titleMedium, .boldTitleMedium
], ],
spacing: 16.0, spacing: 16.0,
deviceType: .iPad) deviceType: .iPad)
] ]
@ -213,6 +213,9 @@ open class Tilelet: TileContainer {
color = .black color = .black
addContentView(stackView) addContentView(stackView)
isAccessibilityElement = true
accessibilityTraits = .staticText
//badge //badge
badgeContainerView.addSubview(badge) badgeContainerView.addSubview(badge)
badge badge
@ -286,7 +289,7 @@ open class Tilelet: TileContainer {
if let subTitleModel, !subTitleModel.text.isEmpty { if let subTitleModel, !subTitleModel.text.isEmpty {
showTitleLockup = true showTitleLockup = true
} }
if showTitleLockup { if showTitleLockup {
//flip the surface for the titleLockup //flip the surface for the titleLockup
titleLockup.surface = color == .black ? Surface.dark : Surface.light titleLockup.surface = color == .black ? Surface.dark : Surface.light
@ -330,6 +333,9 @@ open class Tilelet: TileContainer {
} else { } else {
removeFromSuperview(titleLockupContainerView) removeFromSuperview(titleLockupContainerView)
} }
accessibilityTraits = enabledHighlight ? .link : .staticText
accessibilityLabel = [titleModel?.text, subTitleModel?.text].compactMap({$0}).joined(separator: ", ")
} }
fileprivate func updateIcons() { fileprivate func updateIcons() {
@ -351,7 +357,7 @@ open class Tilelet: TileContainer {
//iconContainer //iconContainer
descriptiveIcon.isHidden = descriptiveIconModel == nil descriptiveIcon.isHidden = descriptiveIconModel == nil
directionalIcon.isHidden = directionalIconModel == nil directionalIcon.isHidden = directionalIconModel == nil
if showIconContainerView { if showIconContainerView {
//spacing before iconContainerView //spacing before iconContainerView
var view: UIView? var view: UIView?

View File

@ -203,7 +203,7 @@ open class TitleLockup: View {
super.setup() super.setup()
isAccessibilityElement = true isAccessibilityElement = true
accessibilityTraits = .button accessibilityTraits = .staticText
addSubview(stackView) addSubview(stackView)
stackView.spacing = 0.0 stackView.spacing = 0.0
@ -214,6 +214,7 @@ open class TitleLockup: View {
//pin stackview to edges //pin stackview to edges
stackView.pinToSuperView() stackView.pinToSuperView()
} }
open override func reset() { open override func reset() {
@ -236,7 +237,7 @@ open class TitleLockup: View {
//-------------------------------------------------- //--------------------------------------------------
open override func updateView() { open override func updateView() {
super.updateView() super.updateView()
let allLabelsTextPosition = textPosition.value let allLabelsTextPosition = textPosition.value
var eyebrowTextIsEmpty = true var eyebrowTextIsEmpty = true
var titleTextIsEmpty = true var titleTextIsEmpty = true
@ -298,5 +299,8 @@ open class TitleLockup: View {
eyebrowLabel.isHidden = eyebrowTextIsEmpty eyebrowLabel.isHidden = eyebrowTextIsEmpty
titleLabel.isHidden = titleTextIsEmpty titleLabel.isHidden = titleTextIsEmpty
subTitleLabel.isHidden = subTitleTextIsEmpty subTitleLabel.isHidden = subTitleTextIsEmpty
accessibilityLabel = [eyebrowModel?.text, titleModel?.text, subTitleModel?.text].compactMap({$0}).joined(separator: ", ")
} }
} }