Skip to content

Commit

Permalink
- AccountControllerCell: add accessibility label and role, fixing iss…
Browse files Browse the repository at this point in the history
…ue 6 in #1341 and improving on previous fix for #1333
  • Loading branch information
felix-schwarz committed May 23, 2024
1 parent 8d6dd8e commit 123edd4
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ class AccountControllerCell: ThemeableCollectionViewListCell {
contentView.addSubview(infoView)

infoView.addSubview(disconnectButton)

titleLabel.isAccessibilityElement = false
detailLabel.isAccessibilityElement = false
statusIconView.isAccessibilityElement = false
isAccessibilityElement = true
accessibilityTraits = .button
}

func configureLayout() {
Expand Down Expand Up @@ -137,11 +143,13 @@ class AccountControllerCell: ThemeableCollectionViewListCell {
var title: String? {
didSet {
titleLabel.text = title
updateAccessibilityLabel()
}
}
var detail: String? {
didSet {
detailLabel.text = detail
updateAccessibilityLabel()
}
}

Expand Down Expand Up @@ -222,6 +230,8 @@ class AccountControllerCell: ThemeableCollectionViewListCell {
}

self.updateStatus(iconFor: accountController?.connection?.status)

updateAccessibilityLabel()
}
}

Expand Down Expand Up @@ -266,8 +276,9 @@ class AccountControllerCell: ThemeableCollectionViewListCell {
statusIconView.image = nil
}

statusIconView.isAccessibilityElement = statusDescription != nil
statusIconView.accessibilityLabel = statusDescription

updateAccessibilityLabel()
}

func updateStatus(from richStatus: AccountConnectionRichStatus?) {
Expand All @@ -286,6 +297,10 @@ class AccountControllerCell: ThemeableCollectionViewListCell {
}
}

func updateAccessibilityLabel() {
accessibilityLabel = "\("Account".localized) \(title ?? "") \(detail ?? "") \(statusIconView.accessibilityLabel != nil ? "Status".localized + " " + statusIconView.accessibilityLabel! : "")"
}

// MARK: - Message Badge
private var badgeLabel : RoundedLabel?

Expand Down

0 comments on commit 123edd4

Please sign in to comment.