mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-22 00:01:00 +00:00
VoiceOver wip
This commit is contained in:
parent
783b88b54a
commit
ef80b743da
7 changed files with 61 additions and 15 deletions
|
@ -30,6 +30,19 @@ extension Date {
|
|||
return Self.abbreviatedDateComponentsFormatter.string(from: self, to: now)
|
||||
}
|
||||
|
||||
var accessibilityTimeAgo: String? {
|
||||
let calendar = Calendar.autoupdatingCurrent
|
||||
let now = Date()
|
||||
|
||||
if
|
||||
let oneWeekAgo = calendar.date(byAdding: DateComponents(weekOfMonth: -1), to: now),
|
||||
oneWeekAgo < self {
|
||||
return Self.realtiveTimeFormatter.localizedString(for: self, relativeTo: Date())
|
||||
}
|
||||
|
||||
return Self.accessibilityFullDateComponentsFormatter.string(from: self)
|
||||
}
|
||||
|
||||
var fullUnitTimeUntil: String? {
|
||||
let calendar = Calendar.autoupdatingCurrent
|
||||
let now = Date()
|
||||
|
@ -78,4 +91,20 @@ private extension Date {
|
|||
|
||||
return dateFormatter
|
||||
}()
|
||||
|
||||
private static let realtiveTimeFormatter: RelativeDateTimeFormatter = {
|
||||
let dateFormatter = RelativeDateTimeFormatter()
|
||||
|
||||
dateFormatter.unitsStyle = .full
|
||||
|
||||
return dateFormatter
|
||||
}()
|
||||
|
||||
private static let accessibilityFullDateComponentsFormatter: DateFormatter = {
|
||||
let dateFormatter = DateFormatter()
|
||||
|
||||
dateFormatter.dateStyle = .long
|
||||
|
||||
return dateFormatter
|
||||
}()
|
||||
}
|
||||
|
|
|
@ -41,6 +41,10 @@ public extension NotificationViewModel {
|
|||
|
||||
var time: String? { notificationService.notification.createdAt.timeAgo }
|
||||
|
||||
var accessibilityTime: String? {
|
||||
notificationService.notification.createdAt.accessibilityTimeAgo
|
||||
}
|
||||
|
||||
func accountSelected() {
|
||||
eventsSubject.send(
|
||||
Just(.navigation(
|
||||
|
|
|
@ -89,11 +89,7 @@ public extension StatusViewModel {
|
|||
|
||||
var time: String? { statusService.status.displayStatus.createdAt.timeAgo }
|
||||
|
||||
var accessibilityTime: String {
|
||||
Self.accessiblityTimeFormatter.localizedString(
|
||||
for: statusService.status.displayStatus.createdAt,
|
||||
relativeTo: Date())
|
||||
}
|
||||
var accessibilityTime: String? { statusService.status.displayStatus.createdAt.accessibilityTimeAgo }
|
||||
|
||||
var contextParentTime: String {
|
||||
Self.contextParentDateFormatter.string(from: statusService.status.displayStatus.createdAt)
|
||||
|
@ -345,14 +341,6 @@ public extension StatusViewModel {
|
|||
}
|
||||
|
||||
private extension StatusViewModel {
|
||||
private static let accessiblityTimeFormatter: RelativeDateTimeFormatter = {
|
||||
let dateFormatter = RelativeDateTimeFormatter()
|
||||
|
||||
dateFormatter.unitsStyle = .full
|
||||
|
||||
return dateFormatter
|
||||
}()
|
||||
|
||||
private static let contextParentDateFormatter: DateFormatter = {
|
||||
let dateFormatter = DateFormatter()
|
||||
|
||||
|
|
|
@ -159,6 +159,8 @@ private extension NotificationView {
|
|||
avatarButton.bottomAnchor.constraint(equalTo: avatarImageView.bottomAnchor),
|
||||
avatarButton.trailingAnchor.constraint(equalTo: avatarImageView.trailingAnchor)
|
||||
])
|
||||
|
||||
isAccessibilityElement = true
|
||||
}
|
||||
|
||||
func applyNotificationConfiguration() {
|
||||
|
@ -218,10 +220,30 @@ private extension NotificationView {
|
|||
}
|
||||
|
||||
timeLabel.text = viewModel.time
|
||||
timeLabel.accessibilityLabel = viewModel.accessibilityTime
|
||||
|
||||
iconImageView.image = UIImage(
|
||||
systemName: viewModel.type.systemImageName,
|
||||
withConfiguration: UIImage.SymbolConfiguration(scale: .medium))
|
||||
|
||||
let accessibilityAttributedLabel = NSMutableAttributedString(string: "")
|
||||
|
||||
if let typeText = typeLabel.attributedText {
|
||||
accessibilityAttributedLabel.appendWithSeparator(typeText)
|
||||
}
|
||||
|
||||
if !statusBodyView.isHidden,
|
||||
let statusBodyAccessibilityAttributedLabel = statusBodyView.accessibilityAttributedLabel {
|
||||
accessibilityAttributedLabel.appendWithSeparator(statusBodyAccessibilityAttributedLabel)
|
||||
} else if !accountLabel.isHidden, let accountText = accountLabel.text {
|
||||
accessibilityAttributedLabel.appendWithSeparator(accountText)
|
||||
}
|
||||
|
||||
if let accessibilityTime = viewModel.accessibilityTime {
|
||||
accessibilityAttributedLabel.appendWithSeparator(accessibilityTime)
|
||||
}
|
||||
|
||||
self.accessibilityAttributedLabel = accessibilityAttributedLabel
|
||||
}
|
||||
// swiftlint:enable function_body_length
|
||||
}
|
||||
|
|
|
@ -504,7 +504,9 @@ private extension StatusView {
|
|||
accessibilityAttributedLabel.appendWithSeparator(bodyAccessibilityAttributedLabel)
|
||||
}
|
||||
|
||||
accessibilityAttributedLabel.appendWithSeparator(viewModel.accessibilityTime)
|
||||
if let accessibilityTime = viewModel.accessibilityTime {
|
||||
accessibilityAttributedLabel.appendWithSeparator(accessibilityTime)
|
||||
}
|
||||
|
||||
self.accessibilityAttributedLabel = accessibilityAttributedLabel
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ final class StatusBodyView: UIView {
|
|||
accessibilityAttributedLabel.appendWithSeparator(viewAccessibilityLabel)
|
||||
}
|
||||
|
||||
self.accessibilityLabel = accessibilityAttributedLabel.string
|
||||
self.accessibilityAttributedLabel = accessibilityAttributedLabel
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ final class NotificationTableViewCell: UITableViewCell {
|
|||
guard let viewModel = viewModel else { return }
|
||||
|
||||
contentConfiguration = NotificationContentConfiguration(viewModel: viewModel).updated(for: state)
|
||||
accessibilityElements = [contentView]
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
|
|
Loading…
Reference in a new issue