forked from shadowfacts/Tusker
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 {
|
guard let status = mastodonController.persistentContainer.status(for: statusID) else {
|
||||||
return nil
|
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 statusState.collapsed ?? false {
|
||||||
if !status.spoilerText.isEmpty {
|
if !status.spoilerText.isEmpty {
|
||||||
str += AttributedString(status.spoilerText)
|
str += AttributedString(status.spoilerText)
|
||||||
|
@ -378,15 +384,24 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
|
||||||
str += "collapsed"
|
str += "collapsed"
|
||||||
} else {
|
} else {
|
||||||
str += AttributedString(contentTextView.attributedText)
|
str += AttributedString(contentTextView.attributedText)
|
||||||
}
|
|
||||||
|
|
||||||
if status.attachments.count > 0 {
|
if status.attachments.count > 0 {
|
||||||
// TODO: localize me
|
if status.attachments.count == 1 {
|
||||||
str += AttributedString(", \(status.attachments.count) attachment\(status.attachments.count > 1 ? "s" : "")")
|
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 {
|
if status.poll != nil {
|
||||||
str += ", poll"
|
str += ", poll"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
str += AttributedString(", \(status.createdAt.formatted(.relative(presentation: .numeric)))")
|
str += AttributedString(", \(status.createdAt.formatted(.relative(presentation: .numeric)))")
|
||||||
if status.visibility < .unlisted {
|
if status.visibility < .unlisted {
|
||||||
str += AttributedString(", \(status.visibility.displayName)")
|
str += AttributedString(", \(status.visibility.displayName)")
|
||||||
|
@ -394,10 +409,6 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
|
||||||
if status.localOnly {
|
if status.localOnly {
|
||||||
str += ", local"
|
str += ", local"
|
||||||
}
|
}
|
||||||
if let rebloggerID,
|
|
||||||
let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) {
|
|
||||||
str += AttributedString(", reblogged by \(reblogger.displayOrUserName)")
|
|
||||||
}
|
|
||||||
return NSAttributedString(str)
|
return NSAttributedString(str)
|
||||||
}
|
}
|
||||||
set {}
|
set {}
|
||||||
|
|
|
@ -254,7 +254,13 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
||||||
guard let status = mastodonController.persistentContainer.status(for: statusID) else {
|
guard let status = mastodonController.persistentContainer.status(for: statusID) else {
|
||||||
return nil
|
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 statusState.collapsed ?? false {
|
||||||
if !status.spoilerText.isEmpty {
|
if !status.spoilerText.isEmpty {
|
||||||
str += AttributedString(status.spoilerText)
|
str += AttributedString(status.spoilerText)
|
||||||
|
@ -263,15 +269,24 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
||||||
str += "collapsed"
|
str += "collapsed"
|
||||||
} else {
|
} else {
|
||||||
str += AttributedString(contentTextView.attributedText)
|
str += AttributedString(contentTextView.attributedText)
|
||||||
}
|
|
||||||
|
|
||||||
if status.attachments.count > 0 {
|
if status.attachments.count > 0 {
|
||||||
// TODO: localize me
|
if status.attachments.count == 1 {
|
||||||
str += AttributedString(", \(status.attachments.count) attachment\(status.attachments.count > 1 ? "s" : "")")
|
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 {
|
if status.poll != nil {
|
||||||
str += ", poll"
|
str += ", poll"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
str += AttributedString(", \(status.createdAt.formatted(.relative(presentation: .numeric)))")
|
str += AttributedString(", \(status.createdAt.formatted(.relative(presentation: .numeric)))")
|
||||||
if status.visibility < .unlisted {
|
if status.visibility < .unlisted {
|
||||||
str += AttributedString(", \(status.visibility.displayName)")
|
str += AttributedString(", \(status.visibility.displayName)")
|
||||||
|
@ -279,10 +294,6 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
||||||
if status.localOnly {
|
if status.localOnly {
|
||||||
str += ", local"
|
str += ", local"
|
||||||
}
|
}
|
||||||
if let rebloggerID,
|
|
||||||
let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) {
|
|
||||||
str += AttributedString(", reblogged by \(reblogger.displayOrUserName)")
|
|
||||||
}
|
|
||||||
return NSAttributedString(str)
|
return NSAttributedString(str)
|
||||||
}
|
}
|
||||||
set {}
|
set {}
|
||||||
|
|
Loading…
Reference in New Issue