diff --git a/Tusker/Views/Profile Header/ProfileHeaderMovedOverlayView.swift b/Tusker/Views/Profile Header/ProfileHeaderMovedOverlayView.swift index 696b36e226..f061bc0cbd 100644 --- a/Tusker/Views/Profile Header/ProfileHeaderMovedOverlayView.swift +++ b/Tusker/Views/Profile Header/ProfileHeaderMovedOverlayView.swift @@ -14,7 +14,8 @@ class ProfileHeaderMovedOverlayView: UIView { weak var delegate: TuskerNavigationDelegate? var collapse: (() -> Void)? - + var hide: (() -> Void)? + private var avatarImageView: CachedImageView! private var displayNameLabel: EmojiLabel! private var usernameLabel: UILabel! @@ -144,7 +145,46 @@ class ProfileHeaderMovedOverlayView: UIView { @objc private func accountTapped() { 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 { diff --git a/Tusker/Views/Profile Header/ProfileHeaderView.swift b/Tusker/Views/Profile Header/ProfileHeaderView.swift index 2bc13026ec..6e4ee2df72 100644 --- a/Tusker/Views/Profile Header/ProfileHeaderView.swift +++ b/Tusker/Views/Profile Header/ProfileHeaderView.swift @@ -41,6 +41,7 @@ class ProfileHeaderView: UIView { @IBOutlet weak var followersCountButton: UIButton! private(set) var pagesSegmentedControl: ScrollingSegmentedControl! 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 }