浏览代码

Merge pull request #663 from deltachat/voice_over_info_button

set voiceover text on chat avatar
cyBerta 5 年之前
父节点
当前提交
7403ddb6b9
共有 2 个文件被更改,包括 8 次插入8 次删除
  1. 2 2
      deltachat-ios/Controller/ChatViewController.swift
  2. 6 6
      deltachat-ios/View/InitialsBadge.swift

+ 2 - 2
deltachat-ios/Controller/ChatViewController.swift

@@ -274,9 +274,9 @@ class ChatViewController: MessagesViewController {
 
         let badge: InitialsBadge
         if let image = chat.profileImage {
-            badge =  InitialsBadge(image: image, size: 28)
+            badge =  InitialsBadge(image: image, size: 28, accessibilityLabel: String.localized("menu_view_profile"))
         } else {
-            badge =  InitialsBadge(name: chat.name, color: chat.color, size: 28)
+            badge =  InitialsBadge(name: chat.name, color: chat.color, size: 28, accessibilityLabel: String.localized("menu_view_profile"))
             badge.setLabelFont(UIFont.systemFont(ofSize: 14))
         }
         badge.setVerified(chat.isVerified)

+ 6 - 6
deltachat-ios/View/InitialsBadge.swift

@@ -31,20 +31,21 @@ class InitialsBadge: UIView {
         return imageViewContainer
     }()
 
-    convenience init(name: String, color: UIColor, size: CGFloat) {
-        self.init(size: size)
+    convenience init(name: String, color: UIColor, size: CGFloat, accessibilityLabel: String? = nil) {
+        self.init(size: size, accessibilityLabel: accessibilityLabel)
         setName(name)
         setColor(color)
     }
 
-    convenience init (image: UIImage, size: CGFloat) {
-        self.init(size: size)
+    convenience init (image: UIImage, size: CGFloat, accessibilityLabel: String? = nil) {
+        self.init(size: size, accessibilityLabel: accessibilityLabel)
         setImage(image)
     }
 
-    init(size: CGFloat) {
+    init(size: CGFloat, accessibilityLabel: String? = nil) {
         self.size = size
         super.init(frame: CGRect(x: 0, y: 0, width: size, height: size))
+        self.accessibilityLabel = accessibilityLabel
         let radius = size / 2
         layer.cornerRadius = radius
         translatesAutoresizingMaskIntoConstraints = false
@@ -83,7 +84,6 @@ class InitialsBadge: UIView {
         label.text = Utils.getInitials(inputName: name)
         label.isHidden = name.isEmpty
         imageView.isHidden = !name.isEmpty
-        accessibilityLabel = "avatar \(name)"
     }
 
     func setLabelFont(_ font: UIFont) {