Sfoglia il codice sorgente

basic accessibility support for avatar

cyberta 5 anni fa
parent
commit
e39bb41f94

+ 1 - 0
deltachat-ios/View/ChatTitleView.swift

@@ -21,6 +21,7 @@ class ChatTitleView: UIView {
     init() {
         super.init(frame: .zero)
         setupSubviews()
+        isAccessibilityElement = true
     }
 
     required init?(coder aDecoder: NSCoder) {

+ 1 - 0
deltachat-ios/View/ContactCell.swift

@@ -15,6 +15,7 @@ class ContactCell: UITableViewCell {
     lazy var avatar: InitialsBadge = {
         let badge = InitialsBadge(size: badgeSize)
         badge.setColor(UIColor.lightGray)
+        badge.isAccessibilityElement = false
         return badge
     }()
 

+ 3 - 0
deltachat-ios/View/InitialsBadge.swift

@@ -11,6 +11,7 @@ class InitialsBadge: UIView {
         label.textAlignment = NSTextAlignment.center
         label.textColor = UIColor.white
         label.translatesAutoresizingMaskIntoConstraints = false
+        label.isAccessibilityElement = false
         return label
     }()
 
@@ -50,6 +51,7 @@ class InitialsBadge: UIView {
         heightAnchor.constraint(equalToConstant: size).isActive = true
         widthAnchor.constraint(equalToConstant: size).isActive = true
         setupSubviews(with: radius)
+        isAccessibilityElement = true
     }
 
     private func setupSubviews(with radius: CGFloat) {
@@ -81,6 +83,7 @@ class InitialsBadge: UIView {
         label.text = Utils.getInitials(inputName: name)
         label.isHidden = name.isEmpty
         imageView.isHidden = !name.isEmpty
+        accessibilityLabel = "avatar \(name)"
     }
 
     func setImage(_ image: UIImage, downscale: CGFloat? = nil) {