added accessiblityText property to badgeindicator

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-05-06 17:06:38 -05:00
parent 46a1471282
commit 6a07bcdd4c
3 changed files with 10 additions and 2 deletions

View File

@ -210,6 +210,7 @@ open class BadgeIndicator: View {
/// The Container's height. /// The Container's height.
open var height: CGFloat? { didSet { setNeedsUpdate() } } open var height: CGFloat? { didSet { setNeedsUpdate() } }
open var accessibilityText: String? { didSet { setNeedsUpdate() } }
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Private Properties // MARK: - Private Properties
//-------------------------------------------------- //--------------------------------------------------
@ -348,7 +349,9 @@ open class BadgeIndicator: View {
open override func updateAccessibility() { open override func updateAccessibility() {
super.updateAccessibility() super.updateAccessibility()
if kind == .numbered { if let accessibilityText {
accessibilityLabel = accessibilityText
} else if kind == .numbered {
accessibilityLabel = label.text accessibilityLabel = label.text
} else { } else {
accessibilityLabel = "Simple" accessibilityLabel = "Simple"

View File

@ -544,6 +544,7 @@ open class ButtonIcon: Control, Changeable {
badgeIndicator.horizontalPadding = badgeIndicatorModel.horizontalPadding badgeIndicator.horizontalPadding = badgeIndicatorModel.horizontalPadding
badgeIndicator.hideDot = badgeIndicatorModel.hideDot badgeIndicator.hideDot = badgeIndicatorModel.hideDot
badgeIndicator.hideBorder = badgeIndicatorModel.hideBorder badgeIndicator.hideBorder = badgeIndicatorModel.hideBorder
badgeIndicator.accessibilityText = badgeIndicatorModel.accessibilityText
} }
private func updateExpandDirectionalConstraints() { private func updateExpandDirectionalConstraints() {

View File

@ -46,6 +46,9 @@ extension ButtonIcon {
/// Trailing Text height that will be used for the badge indicator. /// Trailing Text height that will be used for the badge indicator.
public var trailingText: String? public var trailingText: String?
/// Accessibliity Text
public var accessibilityText: String?
/// Dot Size that will be used for the badge indicator. /// Dot Size that will be used for the badge indicator.
public var dotSize: CGFloat? public var dotSize: CGFloat?
@ -61,7 +64,7 @@ extension ButtonIcon {
/// Hide Border that will be used for the badge indicator. /// Hide Border that will be used for the badge indicator.
public var hideBorder: Bool = false public var hideBorder: Bool = false
public init(kind: BadgeIndicator.Kind = .simple, fillColor: BadgeIndicator.FillColor = .red, expandDirection: ExpandDirection = .right, size: BadgeIndicator.Size = .xxlarge, maximumDigits: BadgeIndicator.MaximumDigits = .two, width: CGFloat? = nil, height: CGFloat? = nil, number: Int? = nil, leadingCharacter: String? = "", trailingText: String? = "", dotSize: CGFloat? = nil, verticalPadding: CGFloat? = nil, horizontalPadding: CGFloat? = nil, hideDot: Bool = false, hideBorder: Bool = false) { public init(kind: BadgeIndicator.Kind = .simple, fillColor: BadgeIndicator.FillColor = .red, expandDirection: ExpandDirection = .right, size: BadgeIndicator.Size = .xxlarge, maximumDigits: BadgeIndicator.MaximumDigits = .two, width: CGFloat? = nil, height: CGFloat? = nil, number: Int? = nil, leadingCharacter: String? = "", trailingText: String? = "", accessibilityText: String? = nil, dotSize: CGFloat? = nil, verticalPadding: CGFloat? = nil, horizontalPadding: CGFloat? = nil, hideDot: Bool = false, hideBorder: Bool = false) {
self.kind = kind self.kind = kind
self.fillColor = fillColor self.fillColor = fillColor
self.expandDirection = expandDirection self.expandDirection = expandDirection
@ -70,6 +73,7 @@ extension ButtonIcon {
self.width = width self.width = width
self.height = height self.height = height
self.number = number self.number = number
self.accessibilityText = accessibilityText
self.leadingCharacter = leadingCharacter self.leadingCharacter = leadingCharacter
self.trailingText = trailingText self.trailingText = trailingText
self.dotSize = dotSize self.dotSize = dotSize