diff --git a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift index 920bf487..e64e5fd4 100644 --- a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift @@ -194,21 +194,25 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti private(set) lazy var replyButton = UIButton().configure { $0.setImage(UIImage(systemName: "arrowshape.turn.up.left.fill"), for: .normal) $0.addTarget(self, action: #selector(replyPressed), for: .touchUpInside) + $0.addInteraction(UIPointerInteraction(delegate: self)) } private(set) lazy var favoriteButton = UIButton().configure { $0.setImage(UIImage(systemName: "star.fill"), for: .normal) $0.addTarget(self, action: #selector(favoritePressed), for: .touchUpInside) + $0.addInteraction(UIPointerInteraction(delegate: self)) } private(set) lazy var reblogButton = UIButton().configure { $0.setImage(UIImage(systemName: "repeat"), for: .normal) $0.addTarget(self, action: #selector(reblogPressed), for: .touchUpInside) + $0.addInteraction(UIPointerInteraction(delegate: self)) } - let moreButton = UIButton().configure { + private(set) lazy var moreButton = UIButton().configure { $0.setImage(UIImage(systemName: "ellipsis"), for: .normal) $0.showsMenuAsPrimaryAction = true + $0.addInteraction(UIPointerInteraction(delegate: self)) } // MARK: Cell state @@ -612,3 +616,24 @@ extension TimelineStatusCollectionViewCell: UIDragInteractionDelegate { return dragItemsForAccount() } } + +extension TimelineStatusCollectionViewCell: UIPointerInteractionDelegate { + func pointerInteraction(_ interaction: UIPointerInteraction, regionFor request: UIPointerRegionRequest, defaultRegion: UIPointerRegion) -> UIPointerRegion? { + guard let button = interaction.view as? UIButton else { + return nil + } + var rect = button.convert(button.imageView!.bounds, from: button.imageView!) + rect = rect.insetBy(dx: -24, dy: -24) + return UIPointerRegion(rect: rect) + } + + func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? { + guard let button = interaction.view as? UIButton else { + return nil + } + let preview = UITargetedPreview(view: button.imageView!) + var rect = button.convert(button.imageView!.bounds, from: button.imageView!) + rect = rect.insetBy(dx: -8, dy: -8) + return UIPointerStyle(effect: .highlight(preview), shape: .roundedRect(rect)) + } +}