From 796151416043f04dd799ce1a7a9d248935abde2b Mon Sep 17 00:00:00 2001 From: shannon Date: Tue, 17 Dec 2024 15:10:29 -0500 Subject: [PATCH] Make taps on the author view either activate the buttons or show the author, never open the post in thread view. Fixes IOS-143 --- .../View/Content/StatusAuthorView.swift | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/StatusAuthorView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/StatusAuthorView.swift index 18c74d19d8..51c08ff204 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/StatusAuthorView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/StatusAuthorView.swift @@ -111,6 +111,23 @@ public class StatusAuthorView: UIStackView { } } +extension StatusAuthorView { + public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { + let superHit = super.hitTest(point, with: event) + if superHit == avatarButton { + return avatarButton + } else { + if menuButton.point(inside: convert(point, to: menuButton), with: event) { + return menuButton + } + if contentSensitiveeToggleButton.point(inside: convert(point, to: contentSensitiveeToggleButton), with: event) { + return contentSensitiveeToggleButton + } + return self + } + } +} + extension StatusAuthorView { func _init() { axis = .horizontal @@ -134,7 +151,7 @@ extension StatusAuthorView { // dateLabel dateLabel.isUserInteractionEnabled = false - self.addTapGestureToAuthorName() + self.addTapGestureToSelf() } } @@ -214,9 +231,9 @@ extension StatusAuthorView { return (menu, accessibilityActions) } - private func addTapGestureToAuthorName() { + private func addTapGestureToSelf() { let tapGesture = UITapGestureRecognizer(target: self, action: #selector(StatusAuthorView.authorNameDidPressed(_:))) - authorNameLabel.addGestureRecognizer(tapGesture) + addGestureRecognizer(tapGesture) } }