Fix profile moved header not being VO accessible

Closes #479
This commit is contained in:
Shadowfacts 2024-07-21 14:03:18 -07:00
parent f25031afd4
commit fccd4e427c
2 changed files with 51 additions and 3 deletions

View File

@ -14,6 +14,7 @@ class ProfileHeaderMovedOverlayView: UIView {
weak var delegate: TuskerNavigationDelegate?
var collapse: (() -> Void)?
var hide: (() -> Void)?
private var avatarImageView: CachedImageView!
private var displayNameLabel: EmojiLabel!
@ -145,6 +146,45 @@ class ProfileHeaderMovedOverlayView: UIView {
delegate?.selected(account: movedToID)
}
// MARK: Accessibility
override var isAccessibilityElement: Bool {
get { true }
set {}
}
override var accessibilityLabel: String? {
get {
guard let movedToID,
let account = delegate?.apiController?.persistentContainer.account(for: movedToID) else {
return "This account has moved"
}
return "This account has moved to @\(account.acct)"
}
set {}
}
override func accessibilityActivate() -> Bool {
guard let movedToID,
let delegate else {
return false
}
delegate.selected(account: movedToID)
return true
}
override var accessibilityCustomActions: [UIAccessibilityCustomAction]? {
get {
[
UIAccessibilityCustomAction(name: "Hide banner", actionHandler: { [unowned self] _ in
self.hide?()
return true
})
]
}
set {}
}
}
extension ProfileHeaderMovedOverlayView: UIPointerInteractionDelegate {

View File

@ -41,6 +41,7 @@ class ProfileHeaderView: UIView {
@IBOutlet weak var followersCountButton: UIButton!
private(set) var pagesSegmentedControl: ScrollingSegmentedControl<ProfileViewController.Page>!
private var movedOverlayView: ProfileHeaderMovedOverlayView?
private var hideMovedOverlayView = false
var accountID: String!
@ -178,7 +179,8 @@ class ProfileHeaderView: UIView {
followersCountButton.setAttributedTitle(followersCountTitle, for: .normal)
followersCountButton.accessibilityLabel = "\(followersSpelledOut) followers"
if let movedTo = account.movedTo {
if let movedTo = account.movedTo,
!hideMovedOverlayView {
if let movedOverlayView {
movedOverlayView.updateUI(movedTo: movedTo)
} else {
@ -235,6 +237,12 @@ class ProfileHeaderView: UIView {
}
animator.startAnimation()
}
overlay.hide = { [weak self] in
guard let self else { return }
self.hideMovedOverlayView = true
self.updateUI(for: self.accountID)
UIAccessibility.post(notification: .layoutChanged, argument: self)
}
return overlay
}