mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Expose more elements to accessibility
This commit is contained in:
@@ -52,7 +52,9 @@ func rightNavigationButtonForChatInterfaceState(_ presentationInterfaceState: Ch
|
||||
if case .standard(true) = presentationInterfaceState.mode {
|
||||
} else if let peer = presentationInterfaceState.renderedPeer?.peer {
|
||||
if presentationInterfaceState.accountPeerId == peer.id {
|
||||
return ChatNavigationButton(action: .search, buttonItem: UIBarButtonItem(image: PresentationResourcesRootController.navigationCompactSearchIcon(presentationInterfaceState.theme), style: .plain, target: target, action: selector))
|
||||
let buttonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationCompactSearchIcon(presentationInterfaceState.theme), style: .plain, target: target, action: selector)
|
||||
buttonItem.accessibilityLabel = "Info"
|
||||
return ChatNavigationButton(action: .search, buttonItem: buttonItem)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -593,7 +593,11 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
|
||||
}
|
||||
|
||||
self.chatListDisplayNode.chatListNode.contentOffsetChanged = { [weak self] offset in
|
||||
if let strongSelf = self, let searchContentNode = strongSelf.searchContentNode {
|
||||
if let strongSelf = self, let searchContentNode = strongSelf.searchContentNode, let validLayout = strongSelf.validLayout {
|
||||
var offset = offset
|
||||
if validLayout.inVoiceOver {
|
||||
offset = .known(0.0)
|
||||
}
|
||||
searchContentNode.updateListVisibleContentOffset(offset)
|
||||
}
|
||||
}
|
||||
@@ -789,8 +793,15 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
|
||||
override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||
super.containerLayoutUpdated(layout, transition: transition)
|
||||
|
||||
let wasInVoiceOver = self.validLayout?.inVoiceOver ?? false
|
||||
|
||||
self.validLayout = layout
|
||||
|
||||
if let searchContentNode = self.searchContentNode, layout.inVoiceOver != wasInVoiceOver {
|
||||
searchContentNode.updateListVisibleContentOffset(.known(0.0))
|
||||
self.chatListDisplayNode.chatListNode.scrollToPosition(.top)
|
||||
}
|
||||
|
||||
self.chatListDisplayNode.containerLayoutUpdated(layout, navigationBarHeight: self.navigationInsetHeight, transition: transition)
|
||||
}
|
||||
|
||||
|
||||
@@ -198,6 +198,7 @@ final class ChatListControllerNode: ASDisplayNode {
|
||||
requestDeactivateSearch()
|
||||
}
|
||||
})
|
||||
self.chatListNode.accessibilityElementsHidden = true
|
||||
|
||||
self.searchDisplayController?.containerLayoutUpdated(containerLayout, navigationBarHeight: navigationBarHeight, transition: .immediate)
|
||||
self.searchDisplayController?.activate(insertSubnode: { [weak self, weak placeholderNode] subnode, isSearchBar in
|
||||
@@ -215,6 +216,7 @@ final class ChatListControllerNode: ASDisplayNode {
|
||||
if let searchDisplayController = self.searchDisplayController {
|
||||
searchDisplayController.deactivate(placeholder: placeholderNode, animated: animated)
|
||||
self.searchDisplayController = nil
|
||||
self.chatListNode.accessibilityElementsHidden = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -335,6 +335,8 @@ class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false, rotated: false, seeThrough: false)
|
||||
|
||||
self.isAccessibilityElement = true
|
||||
|
||||
self.addSubnode(self.backgroundNode)
|
||||
self.addSubnode(self.separatorNode)
|
||||
self.addSubnode(self.avatarNode)
|
||||
@@ -620,6 +622,9 @@ class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
|
||||
if let strongSelf = strongSelf {
|
||||
strongSelf.layoutParams = (item, params, first, last, firstWithHeader)
|
||||
|
||||
strongSelf.accessibilityLabel = titleAttributedString?.string
|
||||
strongSelf.accessibilityValue = statusAttributedString?.string
|
||||
|
||||
switch item.peer {
|
||||
case let .peer(peer, _):
|
||||
if let peer = peer {
|
||||
|
||||
@@ -116,6 +116,8 @@ class ItemListActionItemNode: ListViewItemNode {
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
|
||||
self.isAccessibilityElement = true
|
||||
|
||||
self.addSubnode(self.titleNode)
|
||||
}
|
||||
|
||||
@@ -170,6 +172,16 @@ class ItemListActionItemNode: ListViewItemNode {
|
||||
if let strongSelf = self {
|
||||
strongSelf.item = item
|
||||
|
||||
strongSelf.accessibilityLabel = item.title
|
||||
var accessibilityTraits: UIAccessibilityTraits = UIAccessibilityTraitButton
|
||||
switch item.kind {
|
||||
case .disabled:
|
||||
accessibilityTraits |= UIAccessibilityTraitNotEnabled
|
||||
default:
|
||||
break
|
||||
}
|
||||
strongSelf.accessibilityTraits = accessibilityTraits
|
||||
|
||||
if let _ = updatedTheme {
|
||||
strongSelf.topStripeNode.backgroundColor = itemSeparatorColor
|
||||
strongSelf.bottomStripeNode.backgroundColor = itemSeparatorColor
|
||||
|
||||
@@ -327,6 +327,8 @@ class ItemListAvatarAndNameInfoItemNode: ListViewItemNode, ItemListItemNode, Ite
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
|
||||
self.isAccessibilityElement = true
|
||||
|
||||
self.addSubnode(self.avatarNode)
|
||||
self.addSubnode(self.activityIndicator)
|
||||
|
||||
@@ -524,6 +526,8 @@ class ItemListAvatarAndNameInfoItemNode: ListViewItemNode, ItemListItemNode, Ite
|
||||
if let strongSelf = self {
|
||||
strongSelf.item = item
|
||||
|
||||
strongSelf.accessibilityLabel = displayTitle.composedTitle
|
||||
|
||||
strongSelf.layoutWidthAndNeighbors = (params, neighbors)
|
||||
|
||||
var updatedArrowImage: UIImage?
|
||||
|
||||
@@ -155,6 +155,8 @@ class ItemListDisclosureItemNode: ListViewItemNode {
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
|
||||
self.isAccessibilityElement = true
|
||||
|
||||
self.addSubnode(self.titleNode)
|
||||
self.addSubnode(self.labelNode)
|
||||
self.addSubnode(self.arrowNode)
|
||||
@@ -286,6 +288,10 @@ class ItemListDisclosureItemNode: ListViewItemNode {
|
||||
if let strongSelf = self {
|
||||
strongSelf.item = item
|
||||
|
||||
strongSelf.accessibilityLabel = item.title
|
||||
strongSelf.accessibilityValue = item.label
|
||||
strongSelf.accessibilityTraits = UIAccessibilityTraitButton
|
||||
|
||||
if let icon = item.icon {
|
||||
if strongSelf.iconNode.supernode == nil {
|
||||
strongSelf.addSubnode(strongSelf.iconNode)
|
||||
|
||||
@@ -114,6 +114,8 @@ class ItemListPeerActionItemNode: ListViewItemNode {
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
|
||||
self.isAccessibilityElement = true
|
||||
|
||||
self.addSubnode(self.iconNode)
|
||||
self.addSubnode(self.titleNode)
|
||||
}
|
||||
@@ -147,6 +149,8 @@ class ItemListPeerActionItemNode: ListViewItemNode {
|
||||
if let strongSelf = self {
|
||||
strongSelf.item = item
|
||||
|
||||
strongSelf.accessibilityLabel = item.title
|
||||
|
||||
if let _ = updatedTheme {
|
||||
strongSelf.topStripeNode.backgroundColor = item.theme.list.itemBlocksSeparatorColor
|
||||
strongSelf.bottomStripeNode.backgroundColor = item.theme.list.itemBlocksSeparatorColor
|
||||
|
||||
@@ -246,6 +246,8 @@ class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNode {
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false, rotated: false, seeThrough: false)
|
||||
|
||||
self.isAccessibilityElement = true
|
||||
|
||||
self.addSubnode(self.avatarNode)
|
||||
self.addSubnode(self.titleNode)
|
||||
self.addSubnode(self.statusNode)
|
||||
@@ -497,6 +499,17 @@ class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNode {
|
||||
if let strongSelf = self {
|
||||
strongSelf.layoutParams = (item, params, neighbors)
|
||||
|
||||
strongSelf.accessibilityLabel = titleAttributedString?.string
|
||||
var combinedValueString = ""
|
||||
if let statusString = statusAttributedString?.string, !statusString.isEmpty {
|
||||
combinedValueString.append(statusString)
|
||||
}
|
||||
if let labelString = labelAttributedString?.string, !labelString.isEmpty {
|
||||
combinedValueString.append(labelString)
|
||||
}
|
||||
|
||||
strongSelf.accessibilityValue = combinedValueString
|
||||
|
||||
if let updateArrowImage = updateArrowImage {
|
||||
strongSelf.labelArrowNode?.image = updateArrowImage
|
||||
}
|
||||
|
||||
@@ -132,6 +132,8 @@ class ItemListTextWithLabelItemNode: ListViewItemNode {
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
|
||||
self.isAccessibilityElement = true
|
||||
|
||||
self.addSubnode(self.labelNode)
|
||||
self.addSubnode(self.textNode)
|
||||
}
|
||||
@@ -218,6 +220,9 @@ class ItemListTextWithLabelItemNode: ListViewItemNode {
|
||||
|
||||
strongSelf.item = item
|
||||
|
||||
strongSelf.accessibilityLabel = item.label
|
||||
strongSelf.accessibilityValue = item.text
|
||||
|
||||
if let _ = updatedTheme {
|
||||
strongSelf.topStripeNode.backgroundColor = item.theme.list.itemPlainSeparatorColor
|
||||
strongSelf.bottomStripeNode.backgroundColor = item.theme.list.itemPlainSeparatorColor
|
||||
|
||||
@@ -24,6 +24,10 @@ class NavigationBarSearchContentNode: NavigationBarContentNode {
|
||||
|
||||
super.init()
|
||||
|
||||
self.placeholderNode.isAccessibilityElement = true
|
||||
self.placeholderNode.accessibilityLabel = placeholder
|
||||
self.placeholderNode.accessibilityTraits = UIAccessibilityTraitSearchField
|
||||
|
||||
self.addSubnode(self.placeholderNode)
|
||||
self.placeholderNode.activate = activate
|
||||
}
|
||||
@@ -31,6 +35,7 @@ class NavigationBarSearchContentNode: NavigationBarContentNode {
|
||||
func updateThemeAndPlaceholder(theme: PresentationTheme, placeholder: String) {
|
||||
self.theme = theme
|
||||
self.placeholder = placeholder
|
||||
self.placeholderNode.accessibilityLabel = placeholder
|
||||
if let disabledOverlay = self.disabledOverlay {
|
||||
disabledOverlay.backgroundColor = theme.rootController.navigationBar.backgroundColor.withAlphaComponent(0.5)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user