Add accessibility description/action to status edit history entry
This commit is contained in:
parent
380f878d81
commit
ca7fe74a90
|
@ -91,8 +91,76 @@ class StatusEditCollectionViewCell: UICollectionViewListCell {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: accessibility
|
// MARK: Accessibility
|
||||||
|
|
||||||
|
override var isAccessibilityElement: Bool {
|
||||||
|
get { true }
|
||||||
|
set {}
|
||||||
|
}
|
||||||
|
|
||||||
|
override var accessibilityAttributedLabel: NSAttributedString? {
|
||||||
|
get {
|
||||||
|
var str: AttributedString = ""
|
||||||
|
if statusState.collapsed ?? false {
|
||||||
|
if !edit.spoilerText.isEmpty {
|
||||||
|
str += AttributedString(edit.spoilerText)
|
||||||
|
str += ", "
|
||||||
|
}
|
||||||
|
str += "collapsed"
|
||||||
|
} else {
|
||||||
|
str += AttributedString(contentContainer.contentTextView.attributedText)
|
||||||
|
|
||||||
|
if edit.attachments.count > 0 {
|
||||||
|
let includeDescriptions: Bool
|
||||||
|
switch Preferences.shared.attachmentBlurMode {
|
||||||
|
case .useStatusSetting:
|
||||||
|
includeDescriptions = !Preferences.shared.blurMediaBehindContentWarning || edit.spoilerText.isEmpty
|
||||||
|
case .always:
|
||||||
|
includeDescriptions = true
|
||||||
|
case .never:
|
||||||
|
includeDescriptions = false
|
||||||
|
}
|
||||||
|
if includeDescriptions {
|
||||||
|
if edit.attachments.count == 1 {
|
||||||
|
let attachment = edit.attachments[0]
|
||||||
|
let desc = attachment.description?.isEmpty == false ? attachment.description! : "no description"
|
||||||
|
str += AttributedString(", attachment: \(desc)")
|
||||||
|
} else {
|
||||||
|
for (index, attachment) in edit.attachments.enumerated() {
|
||||||
|
let desc = attachment.description?.isEmpty == false ? attachment.description! : "no description"
|
||||||
|
str += AttributedString(", attachment \(index + 1): \(desc)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
str += AttributedString(", \(edit.attachments.count) attachment\(edit.attachments.count == 1 ? "" : "s")")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if edit.poll != nil {
|
||||||
|
str += ", poll"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NSAttributedString(str)
|
||||||
|
}
|
||||||
|
set {}
|
||||||
|
}
|
||||||
|
|
||||||
|
override var accessibilityHint: String? {
|
||||||
|
get {
|
||||||
|
if statusState.collapsed ?? false {
|
||||||
|
return "Double tap to expand the post."
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set {}
|
||||||
|
}
|
||||||
|
|
||||||
|
override func accessibilityActivate() -> Bool {
|
||||||
|
if statusState.collapsed ?? false {
|
||||||
|
collapseButtonPressed()
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Configure UI
|
// MARK: Configure UI
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue