forked from shadowfacts/Tusker
parent
f25031afd4
commit
fccd4e427c
|
@ -14,7 +14,8 @@ class ProfileHeaderMovedOverlayView: UIView {
|
||||||
weak var delegate: TuskerNavigationDelegate?
|
weak var delegate: TuskerNavigationDelegate?
|
||||||
|
|
||||||
var collapse: (() -> Void)?
|
var collapse: (() -> Void)?
|
||||||
|
var hide: (() -> Void)?
|
||||||
|
|
||||||
private var avatarImageView: CachedImageView!
|
private var avatarImageView: CachedImageView!
|
||||||
private var displayNameLabel: EmojiLabel!
|
private var displayNameLabel: EmojiLabel!
|
||||||
private var usernameLabel: UILabel!
|
private var usernameLabel: UILabel!
|
||||||
|
@ -144,7 +145,46 @@ class ProfileHeaderMovedOverlayView: UIView {
|
||||||
@objc private func accountTapped() {
|
@objc private func accountTapped() {
|
||||||
delegate?.selected(account: movedToID)
|
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 {
|
extension ProfileHeaderMovedOverlayView: UIPointerInteractionDelegate {
|
||||||
|
|
|
@ -41,6 +41,7 @@ class ProfileHeaderView: UIView {
|
||||||
@IBOutlet weak var followersCountButton: UIButton!
|
@IBOutlet weak var followersCountButton: UIButton!
|
||||||
private(set) var pagesSegmentedControl: ScrollingSegmentedControl<ProfileViewController.Page>!
|
private(set) var pagesSegmentedControl: ScrollingSegmentedControl<ProfileViewController.Page>!
|
||||||
private var movedOverlayView: ProfileHeaderMovedOverlayView?
|
private var movedOverlayView: ProfileHeaderMovedOverlayView?
|
||||||
|
private var hideMovedOverlayView = false
|
||||||
|
|
||||||
var accountID: String!
|
var accountID: String!
|
||||||
|
|
||||||
|
@ -178,7 +179,8 @@ class ProfileHeaderView: UIView {
|
||||||
followersCountButton.setAttributedTitle(followersCountTitle, for: .normal)
|
followersCountButton.setAttributedTitle(followersCountTitle, for: .normal)
|
||||||
followersCountButton.accessibilityLabel = "\(followersSpelledOut) followers"
|
followersCountButton.accessibilityLabel = "\(followersSpelledOut) followers"
|
||||||
|
|
||||||
if let movedTo = account.movedTo {
|
if let movedTo = account.movedTo,
|
||||||
|
!hideMovedOverlayView {
|
||||||
if let movedOverlayView {
|
if let movedOverlayView {
|
||||||
movedOverlayView.updateUI(movedTo: movedTo)
|
movedOverlayView.updateUI(movedTo: movedTo)
|
||||||
} else {
|
} else {
|
||||||
|
@ -235,6 +237,12 @@ class ProfileHeaderView: UIView {
|
||||||
}
|
}
|
||||||
animator.startAnimation()
|
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
|
return overlay
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue