Skip to content

Commit

Permalink
Make taps on the author view either activate the buttons or show the …
Browse files Browse the repository at this point in the history
…author, never open the post in thread view.

Fixes IOS-143
  • Loading branch information
whattherestimefor committed Dec 17, 2024
1 parent f287518 commit 7961514
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions MastodonSDK/Sources/MastodonUI/View/Content/StatusAuthorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -134,7 +151,7 @@ extension StatusAuthorView {

// dateLabel
dateLabel.isUserInteractionEnabled = false
self.addTapGestureToAuthorName()
self.addTapGestureToSelf()
}
}

Expand Down Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 7961514

Please sign in to comment.