Add accessibility labels to notifications, only have 1 element per notification
This commit is contained in:
parent
081c900069
commit
b3bc6dc273
|
@ -100,21 +100,20 @@ extension NotificationView.ViewModel {
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
// timestamp
|
// timestamp
|
||||||
Publishers.CombineLatest(
|
let formattedTimestamp = Publishers.CombineLatest(
|
||||||
$timestamp,
|
$timestamp,
|
||||||
timestampUpdatePublisher.prepend(Date()).eraseToAnyPublisher()
|
timestampUpdatePublisher.prepend(Date()).eraseToAnyPublisher()
|
||||||
)
|
)
|
||||||
.sink { [weak self] timestamp, _ in
|
.map { timestamp, _ in
|
||||||
guard let self = self else { return }
|
timestamp?.localizedTimeAgoSinceNow ?? ""
|
||||||
guard let timestamp = timestamp else {
|
|
||||||
notificationView.dateLabel.configure(content: PlaintextMetaContent(string: ""))
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let text = timestamp.localizedTimeAgoSinceNow
|
formattedTimestamp
|
||||||
notificationView.dateLabel.configure(content: PlaintextMetaContent(string: text))
|
.sink { timestamp in
|
||||||
|
notificationView.dateLabel.configure(content: PlaintextMetaContent(string: timestamp))
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
|
|
||||||
// notification type indicator
|
// notification type indicator
|
||||||
$notificationIndicatorText
|
$notificationIndicatorText
|
||||||
.sink { text in
|
.sink { text in
|
||||||
|
@ -125,6 +124,27 @@ extension NotificationView.ViewModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
|
|
||||||
|
Publishers.CombineLatest4(
|
||||||
|
$authorName,
|
||||||
|
$authorUsername,
|
||||||
|
$notificationIndicatorText,
|
||||||
|
formattedTimestamp
|
||||||
|
)
|
||||||
|
.sink { name, username, type, timestamp in
|
||||||
|
notificationView.accessibilityLabel = [
|
||||||
|
"\(name?.string ?? "") \(type?.string ?? "")",
|
||||||
|
username.map { "@\($0)" } ?? "",
|
||||||
|
timestamp
|
||||||
|
].joined(separator: ", ")
|
||||||
|
if !notificationView.statusView.isHidden {
|
||||||
|
notificationView.accessibilityLabel! += ", " + (notificationView.statusView.accessibilityLabel ?? "")
|
||||||
|
}
|
||||||
|
if !notificationView.quoteStatusViewContainerView.isHidden {
|
||||||
|
notificationView.accessibilityLabel! += ", " + (notificationView.quoteStatusView.accessibilityLabel ?? "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.store(in: &disposeBag)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func bindAuthorMenu(notificationView: NotificationView) {
|
private func bindAuthorMenu(notificationView: NotificationView) {
|
||||||
|
|
|
@ -382,6 +382,15 @@ extension NotificationView {
|
||||||
|
|
||||||
statusView.delegate = self
|
statusView.delegate = self
|
||||||
quoteStatusView.delegate = self
|
quoteStatusView.delegate = self
|
||||||
|
|
||||||
|
isAccessibilityElement = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension NotificationView {
|
||||||
|
public override var accessibilityElements: [Any]? {
|
||||||
|
get { [] }
|
||||||
|
set {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -709,13 +709,13 @@ extension StatusView.ViewModel {
|
||||||
meidaAccessibilityLabel
|
meidaAccessibilityLabel
|
||||||
)
|
)
|
||||||
.map { author, content, media in
|
.map { author, content, media in
|
||||||
let group = [
|
var labels: [String?] = [content, media]
|
||||||
author,
|
|
||||||
content,
|
|
||||||
media
|
|
||||||
]
|
|
||||||
|
|
||||||
return group
|
if statusView.style != .notification {
|
||||||
|
labels.insert(author, at: 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
return labels
|
||||||
.compactMap { $0 }
|
.compactMap { $0 }
|
||||||
.joined(separator: ", ")
|
.joined(separator: ", ")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue