Accessibility improvements

This commit is contained in:
Ilya Laktyushin
2023-02-06 19:58:06 +04:00
parent 78b02192cf
commit 7b746eb9b2
9 changed files with 55 additions and 6 deletions

View File

@@ -106,6 +106,7 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
public var title: String? {
didSet {
self.updateAccessibilityLabels()
if let width = self.validLayout {
_ = self.updateLayout(width: width, transition: .immediate)
}
@@ -114,6 +115,7 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
public var subtitle: String? {
didSet {
self.updateAccessibilityLabels()
if let width = self.validLayout {
_ = self.updateLayout(width: width, previousSubtitle: oldValue, transition: .immediate)
}
@@ -126,6 +128,10 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
}
}
private func updateAccessibilityLabels() {
self.accessibilityLabel = (self.title ?? "") + " " + (self.subtitle ?? "")
}
private var animationTimer: SwiftSignalKit.Timer?
public var animation: String? {
didSet {
@@ -759,6 +765,7 @@ public final class SolidRoundedButtonView: UIView {
public var title: String? {
didSet {
self.updateAccessibilityLabels()
if let width = self.validLayout {
_ = self.updateLayout(width: width, transition: .immediate)
}
@@ -767,6 +774,7 @@ public final class SolidRoundedButtonView: UIView {
public var label: String? {
didSet {
self.updateAccessibilityLabels()
if let width = self.validLayout {
_ = self.updateLayout(width: width, transition: .immediate)
}
@@ -775,12 +783,18 @@ public final class SolidRoundedButtonView: UIView {
public var subtitle: String? {
didSet {
self.updateAccessibilityLabels()
if let width = self.validLayout {
_ = self.updateLayout(width: width, previousSubtitle: oldValue, transition: .immediate)
}
}
}
private func updateAccessibilityLabels() {
self.accessibilityLabel = (self.title ?? "") + " " + (self.subtitle ?? "")
self.accessibilityValue = self.label
}
public var icon: UIImage? {
didSet {
self.iconNode.image = generateTintedImage(image: self.icon, color: self.theme.foregroundColor)