Make UserView accessible
This commit is contained in:
parent
d933f2d0cb
commit
21e4a81ca7
|
@ -54,6 +54,8 @@ extension SearchHistoryUserCollectionViewCell {
|
|||
contentView.trailingAnchor.constraint(equalTo: userView.trailingAnchor, constant: 16),
|
||||
userView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
|
||||
])
|
||||
|
||||
userView.accessibilityTraits.insert(.button)
|
||||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
|
|
|
@ -61,6 +61,8 @@ extension UserTableViewCell {
|
|||
separatorLine.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
|
||||
separatorLine.heightAnchor.constraint(equalToConstant: UIView.separatorLineHeight(of: contentView)).priority(.required - 1),
|
||||
])
|
||||
|
||||
userView.accessibilityTraits.insert(.button)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,15 +52,27 @@ extension UserView.ViewModel {
|
|||
}
|
||||
.store(in: &disposeBag)
|
||||
// username
|
||||
$authorUsername
|
||||
let displayUsername = $authorUsername
|
||||
.map { text -> String in
|
||||
guard let text = text else { return "" }
|
||||
return "@\(text)"
|
||||
}
|
||||
|
||||
displayUsername
|
||||
.sink { username in
|
||||
let metaContent = PlaintextMetaContent(string: username)
|
||||
userView.authorUsernameLabel.configure(content: metaContent)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
|
||||
Publishers.CombineLatest($authorName, displayUsername)
|
||||
.sink { name, username in
|
||||
if let name {
|
||||
userView.accessibilityLabel = "\(name.string), \(username)"
|
||||
} else {
|
||||
userView.accessibilityLabel = username
|
||||
}
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,6 +90,8 @@ extension UserView {
|
|||
avatarButton.isUserInteractionEnabled = false
|
||||
authorNameLabel.isUserInteractionEnabled = false
|
||||
authorUsernameLabel.isUserInteractionEnabled = false
|
||||
|
||||
isAccessibilityElement = true
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue