mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-03 11:44:46 +00:00
Merge pull request #1406 from rahul-malik/rmalik-button-a11y
[Accessibility] Basic a11y support for ASButtonNode (adopt text node title as a11y label)
This commit is contained in:
@@ -60,6 +60,7 @@
|
||||
_contentHorizontalAlignment = ASAlignmentMiddle;
|
||||
_contentVerticalAlignment = ASAlignmentCenter;
|
||||
_contentEdgeInsets = UIEdgeInsetsZero;
|
||||
self.accessibilityTraits = UIAccessibilityTraitButton;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -102,6 +103,11 @@
|
||||
- (void)setEnabled:(BOOL)enabled
|
||||
{
|
||||
[super setEnabled:enabled];
|
||||
if (enabled) {
|
||||
self.accessibilityTraits = UIAccessibilityTraitButton;
|
||||
} else {
|
||||
self.accessibilityTraits = UIAccessibilityTraitButton | UIAccessibilityTraitNotEnabled;
|
||||
}
|
||||
[self updateButtonContent];
|
||||
}
|
||||
|
||||
@@ -135,7 +141,7 @@
|
||||
- (void)updateImage
|
||||
{
|
||||
ASDN::MutexLocker l(_propertyLock);
|
||||
|
||||
|
||||
UIImage *newImage;
|
||||
if (self.enabled == NO && _disabledImage) {
|
||||
newImage = _disabledImage;
|
||||
@@ -170,9 +176,10 @@
|
||||
} else {
|
||||
newTitle = _normalAttributedTitle;
|
||||
}
|
||||
|
||||
|
||||
if ((_titleNode != nil || newTitle.length > 0) && newTitle != self.titleNode.attributedString) {
|
||||
_titleNode.attributedString = newTitle;
|
||||
self.accessibilityLabel = _titleNode.accessibilityLabel;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
}
|
||||
@@ -331,6 +338,7 @@
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
[self updateTitle];
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ static BOOL _enableHitTestDebug = NO;
|
||||
}
|
||||
|
||||
#pragma mark - Lifecycle
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if (!(self = [super init]))
|
||||
@@ -89,6 +90,13 @@ static BOOL _enableHitTestDebug = NO;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setUserInteractionEnabled:(BOOL)userInteractionEnabled
|
||||
{
|
||||
[super setUserInteractionEnabled:userInteractionEnabled];
|
||||
self.isAccessibilityElement = userInteractionEnabled;
|
||||
}
|
||||
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user