VoiceOver: Include attachment descriptions in timeline statuses
Closes #291
This commit is contained in:
parent
60767c6a7e
commit
9a35f96c75
|
@ -369,7 +369,13 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
|
|||
guard let status = mastodonController.persistentContainer.status(for: statusID) else {
|
||||
return nil
|
||||
}
|
||||
var str = AttributedString("\(status.account.displayOrUserName), ")
|
||||
var str: AttributedString = ""
|
||||
if let rebloggerID,
|
||||
let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) {
|
||||
str += AttributedString("Reblogged by \(reblogger.displayOrUserName): ")
|
||||
}
|
||||
str += AttributedString(status.account.displayOrUserName)
|
||||
str += ", "
|
||||
if statusState.collapsed ?? false {
|
||||
if !status.spoilerText.isEmpty {
|
||||
str += AttributedString(status.spoilerText)
|
||||
|
@ -378,15 +384,24 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
|
|||
str += "collapsed"
|
||||
} else {
|
||||
str += AttributedString(contentTextView.attributedText)
|
||||
|
||||
if status.attachments.count > 0 {
|
||||
if status.attachments.count == 1 {
|
||||
let attachment = status.attachments[0]
|
||||
let desc = attachment.description?.isEmpty == false ? attachment.description! : "no description"
|
||||
str += AttributedString(", attachment: \(desc)")
|
||||
} else {
|
||||
for (index, attachment) in status.attachments.enumerated() {
|
||||
let desc = attachment.description?.isEmpty == false ? attachment.description! : "no description"
|
||||
str += AttributedString(", attachment \(index + 1): \(desc)")
|
||||
}
|
||||
}
|
||||
}
|
||||
if status.poll != nil {
|
||||
str += ", poll"
|
||||
}
|
||||
}
|
||||
|
||||
if status.attachments.count > 0 {
|
||||
// TODO: localize me
|
||||
str += AttributedString(", \(status.attachments.count) attachment\(status.attachments.count > 1 ? "s" : "")")
|
||||
}
|
||||
if status.poll != nil {
|
||||
str += ", poll"
|
||||
}
|
||||
str += AttributedString(", \(status.createdAt.formatted(.relative(presentation: .numeric)))")
|
||||
if status.visibility < .unlisted {
|
||||
str += AttributedString(", \(status.visibility.displayName)")
|
||||
|
@ -394,10 +409,6 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
|
|||
if status.localOnly {
|
||||
str += ", local"
|
||||
}
|
||||
if let rebloggerID,
|
||||
let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) {
|
||||
str += AttributedString(", reblogged by \(reblogger.displayOrUserName)")
|
||||
}
|
||||
return NSAttributedString(str)
|
||||
}
|
||||
set {}
|
||||
|
|
|
@ -254,7 +254,13 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
|||
guard let status = mastodonController.persistentContainer.status(for: statusID) else {
|
||||
return nil
|
||||
}
|
||||
var str = AttributedString("\(status.account.displayOrUserName), ")
|
||||
var str: AttributedString = ""
|
||||
if let rebloggerID,
|
||||
let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) {
|
||||
str += AttributedString("Reblogged by \(reblogger.displayOrUserName): ")
|
||||
}
|
||||
str += AttributedString(status.account.displayOrUserName)
|
||||
str += ", "
|
||||
if statusState.collapsed ?? false {
|
||||
if !status.spoilerText.isEmpty {
|
||||
str += AttributedString(status.spoilerText)
|
||||
|
@ -263,15 +269,24 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
|||
str += "collapsed"
|
||||
} else {
|
||||
str += AttributedString(contentTextView.attributedText)
|
||||
|
||||
if status.attachments.count > 0 {
|
||||
if status.attachments.count == 1 {
|
||||
let attachment = status.attachments[0]
|
||||
let desc = attachment.description?.isEmpty == false ? attachment.description! : "no description"
|
||||
str += AttributedString(", attachment: \(desc)")
|
||||
} else {
|
||||
for (index, attachment) in status.attachments.enumerated() {
|
||||
let desc = attachment.description?.isEmpty == false ? attachment.description! : "no description"
|
||||
str += AttributedString(", attachment \(index + 1): \(desc)")
|
||||
}
|
||||
}
|
||||
}
|
||||
if status.poll != nil {
|
||||
str += ", poll"
|
||||
}
|
||||
}
|
||||
|
||||
if status.attachments.count > 0 {
|
||||
// TODO: localize me
|
||||
str += AttributedString(", \(status.attachments.count) attachment\(status.attachments.count > 1 ? "s" : "")")
|
||||
}
|
||||
if status.poll != nil {
|
||||
str += ", poll"
|
||||
}
|
||||
str += AttributedString(", \(status.createdAt.formatted(.relative(presentation: .numeric)))")
|
||||
if status.visibility < .unlisted {
|
||||
str += AttributedString(", \(status.visibility.displayName)")
|
||||
|
@ -279,10 +294,6 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
|||
if status.localOnly {
|
||||
str += ", local"
|
||||
}
|
||||
if let rebloggerID,
|
||||
let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) {
|
||||
str += AttributedString(", reblogged by \(reblogger.displayOrUserName)")
|
||||
}
|
||||
return NSAttributedString(str)
|
||||
}
|
||||
set {}
|
||||
|
|
Loading…
Reference in New Issue