VoiceOver wip

This commit is contained in:
Justin Mazzocchi 2021-02-02 13:49:29 -08:00
parent 5bfe75c778
commit 45517c0df6
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
3 changed files with 49 additions and 8 deletions

View file

@ -3,6 +3,7 @@
"about" = "About";
"about.acknowledgments" = "Acknowledgments";
"account.%@-followers" = "%@'s Followers";
"account.accept-follow-request-button.accessibility-label" = "Accept follow request";
"account.avatar.accessibility-label-%@" = "Avatar: %@";
"account.block" = "Block";
"account.block.confirm-%@" = "Block %@?";
@ -19,6 +20,7 @@
"account.header.accessibility-label-%@" = "Header image: %@";
"account.hide-reblogs" = "Hide boosts";
"account.mute" = "Mute";
"account.reject-follow-request-button.accessibility-label" = "Reject follow request";
"account.request" = "Request";
"account.statuses.post" = "Posts";
"account.statuses.toot" = "Toots";

View file

@ -147,22 +147,23 @@ private extension AccountView {
stackView.bottomAnchor.constraint(equalTo: readableContentGuide.bottomAnchor),
stackView.trailingAnchor.constraint(equalTo: readableContentGuide.trailingAnchor)
])
isAccessibilityElement = true
}
// swiftlint:disable:next function_body_length
func applyAccountConfiguration() {
let viewModel = accountConfiguration.viewModel
avatarImageView.kf.setImage(with: viewModel.avatarURL(profile: false))
if viewModel.displayName.isEmpty {
displayNameLabel.isHidden = true
} else {
let mutableDisplayName = NSMutableAttributedString(string: viewModel.displayName)
let mutableDisplayName = NSMutableAttributedString(string: viewModel.displayName)
mutableDisplayName.insert(emojis: viewModel.emojis, view: displayNameLabel)
mutableDisplayName.resizeAttachments(toLineHeight: displayNameLabel.font.lineHeight)
displayNameLabel.attributedText = mutableDisplayName
}
mutableDisplayName.insert(emojis: viewModel.emojis, view: displayNameLabel)
mutableDisplayName.resizeAttachments(toLineHeight: displayNameLabel.font.lineHeight)
displayNameLabel.attributedText = mutableDisplayName
displayNameLabel.isHidden = viewModel.displayName.isEmpty
accountLabel.text = viewModel.accountName
@ -189,5 +190,42 @@ private extension AccountView {
acceptFollowRequestButton.isHidden = !isFollowRequest
rejectFollowRequestButton.isHidden = !isFollowRequest
let accessibilityAttributedLabel = NSMutableAttributedString(string: "")
if !displayNameLabel.isHidden, let displayName = displayNameLabel.attributedText {
accessibilityAttributedLabel.append(displayName)
accessibilityAttributedLabel.appendWithSeparator(viewModel.accountName)
} else {
accessibilityAttributedLabel.appendWithSeparator(viewModel.accountName)
}
if !noteTextView.isHidden, let note = noteTextView.attributedText {
accessibilityAttributedLabel.appendWithSeparator(note)
}
self.accessibilityAttributedLabel = accessibilityAttributedLabel
if isFollowRequest {
accessibilityCustomActions = [
UIAccessibilityCustomAction(
name: NSLocalizedString(
"account.accept-follow-request-button.accessibility-label",
comment: "")) { [weak self] _ in
self?.accountConfiguration.viewModel.acceptFollowRequest()
return true
},
UIAccessibilityCustomAction(
name: NSLocalizedString(
"account.reject-follow-request-button.accessibility-label",
comment: "")) { [weak self] _ in
self?.accountConfiguration.viewModel.rejectFollowRequest()
return true
}]
} else {
accessibilityCustomActions = []
}
}
}

View file

@ -10,6 +10,7 @@ final class AccountTableViewCell: UITableViewCell {
guard let viewModel = viewModel else { return }
contentConfiguration = AccountContentConfiguration(viewModel: viewModel).updated(for: state)
accessibilityElements = [contentView]
}
override func layoutSubviews() {