diff --git a/Tusker/Views/Status/TimelineStatusTableViewCell.swift b/Tusker/Views/Status/TimelineStatusTableViewCell.swift index 92d826df..407cd84b 100644 --- a/Tusker/Views/Status/TimelineStatusTableViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusTableViewCell.swift @@ -15,7 +15,7 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell { static let relativeDateFormatter: RelativeDateTimeFormatter = { let formatter = RelativeDateTimeFormatter() formatter.dateTimeStyle = .numeric - formatter.unitsStyle = .short + formatter.unitsStyle = .full return formatter }() @@ -44,7 +44,7 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell { reblogLabel.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(reblogLabelPressed))) - accessibilityElements!.insert(reblogLabel!, at: 0) + isAccessibilityElement = true // todo: double check this on RTL layouts replyButton.imageView!.leadingAnchor.constraint(equalTo: contentTextView.leadingAnchor).isActive = true @@ -134,7 +134,6 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell { private func doUpdateTimestamp(status: StatusMO) { timestampLabel.text = status.createdAt.timeAgoString() - timestampLabel.accessibilityLabel = TimelineStatusTableViewCell.relativeDateFormatter.localizedString(for: status.createdAt, relativeTo: Date()) let delay: DispatchTimeInterval? switch status.createdAt.timeAgo().1 { @@ -193,6 +192,33 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell { actions: { self.actionsForStatus(status, sourceView: self) } ) } + + // MARK: - Accessibility + + override var accessibilityLabel: String? { + get { + guard let status = mastodonController.persistentContainer.status(for: statusID) else { + return nil + } + var str = "\(status.account.displayName), \(contentTextView.text ?? "")" + + if status.attachments.count > 0 { + // todo: localize me + str += ", \(status.attachments.count) attachments" + } + if status.poll != nil { + str += ", poll" + } + str += ", \(TimelineStatusTableViewCell.relativeDateFormatter.localizedString(for: status.createdAt, relativeTo: Date()))" + if let rebloggerID = rebloggerID, + let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) { + str += ", reblogged by \(reblogger.displayName)" + } + + return str + } + set {} + } }