VoiceOver: RoomVC: Make VoiceOver focus on the contextual menu when selecting an event

#2721
This commit is contained in:
manuroe
2019-09-18 13:51:45 +02:00
parent a1b47f3436
commit 0c2082ce2f
3 changed files with 22 additions and 7 deletions
@@ -93,20 +93,30 @@ final class ContextualMenuItemView: UIView, NibOwnerLoadable {
}
// MARK: - Public
func fill(title: String, image: UIImage?) {
self.originalImage = image?.withRenderingMode(.alwaysTemplate)
self.titleLabel.text = title
self.updateView()
}
func fill(menuItem: RoomContextualMenuItem) {
self.fill(title: menuItem.title, image: menuItem.image)
self.setupAccessibility(title: menuItem.title, isEnabled: menuItem.isEnabled)
self.action = menuItem.action
self.isEnabled = menuItem.isEnabled
}
// MARK: - Private
private func fill(title: String, image: UIImage?) {
self.originalImage = image?.withRenderingMode(.alwaysTemplate)
self.titleLabel.text = title
self.updateView()
}
private func setupAccessibility(title: String, isEnabled: Bool) {
self.isAccessibilityElement = true
self.accessibilityLabel = title
self.accessibilityTraits = .button
if !isEnabled {
self.accessibilityTraits.insert(.notEnabled)
}
}
private func setupGestureRecognizer() {
let gestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(buttonAction(_:)))