Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Mastodon/Scene/Discovery/View/DiscoveryIntroBannerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public final class DiscoveryIntroBannerView: UIView {
let button = HitTestExpandedButton(type: .system)
button.setImage(UIImage(systemName: "xmark.circle.fill"), for: .normal)
button.tintColor = Asset.Colors.Label.secondary.color
button.isPointerInteractionEnabled = true
button.pointerStyleProvider = { _, effect, _ in UIPointerStyle(effect: .lift(effect.preview)) }
return button
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ final class SearchHistorySectionHeaderCollectionReusableView: UICollectionReusab
let button = UIButton(type: .system)
button.setImage(UIImage(systemName: "xmark.circle.fill"), for: .normal)
button.tintColor = Asset.Colors.Label.secondary.color
button.isPointerInteractionEnabled = true
button.pointerStyleProvider = { _, effect, _ in UIPointerStyle(effect: .lift(effect.preview)) }
button.accessibilityLabel = L10n.Scene.Search.Searching.clear

return button
}()

Expand Down
14 changes: 14 additions & 0 deletions MastodonSDK/Sources/MastodonUI/View/Button/AvatarButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ open class AvatarButton: UIControl {
avatarImageView.translatesAutoresizingMaskIntoConstraints = false
addSubview(avatarImageView)
avatarImageView.pinToParent()

addInteraction(UIPointerInteraction(delegate: self))

isAccessibilityElement = true
accessibilityLabel = L10n.Common.Controls.Status.showUserProfile
Expand All @@ -57,6 +59,18 @@ open class AvatarButton: UIControl {

}

extension AvatarButton: UIPointerInteractionDelegate {
public func pointerInteraction(_ interaction: UIPointerInteraction, regionFor request: UIPointerRegionRequest, defaultRegion: UIPointerRegion) -> UIPointerRegion? {
defaultRegion
}
public func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? {
UIPointerStyle(
effect: .automatic(UITargetedPreview(view: self)),
shape: UIPointerShape.roundedRect(avatarImageView.bounds, radius: avatarImageView.layer.cornerRadius)
)
}
}

extension AvatarButton {

public override var intrinsicContentSize: CGSize {
Expand Down
1 change: 1 addition & 0 deletions MastodonSDK/Sources/MastodonUI/View/Button/HUDButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class HUDButton: UIView {
button.translatesAutoresizingMaskIntoConstraints = false
vibrancyView.contentView.addSubview(button)
button.pinToParent()
button.pointerStyleProvider = { _, _, _ in UIPointerStyle(effect: .lift(UITargetedPreview(view: self))) }
NSLayoutConstraint.activate([
heightAnchor.constraint(equalToConstant: HUDButton.height).priority(.defaultHigh),
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ final public class HighlightDimmableButton: UIButton {
extension HighlightDimmableButton {
private func _init() {
adjustsImageWhenHighlighted = false
isPointerInteractionEnabled = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,25 @@ open class RoundedEdgesButton: UIButton {
setNeedsDisplay()
}
}

open override func willMove(toWindow newWindow: UIWindow?) {
super.willMove(toWindow: newWindow)

isPointerInteractionEnabled = true
}

open override func layoutSubviews() {
super.layoutSubviews()

layer.masksToBounds = true
layer.cornerRadius = cornerRadius > .zero ? cornerRadius : bounds.height * 0.5
let radius = cornerRadius > .zero ? cornerRadius : bounds.height * 0.5
layer.cornerRadius = radius
pointerStyleProvider = { _, _, _ in
UIPointerStyle(
effect: .lift(UITargetedPreview(view: self)),
shape: .roundedRect(self.frame, radius: radius)
)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class StatusAuthorView: UIStackView {
let image = UIImage(systemName: "ellipsis", withConfiguration: UIImage.SymbolConfiguration(font: .systemFont(ofSize: 15)))
button.setImage(image, for: .normal)
button.accessibilityLabel = L10n.Common.Controls.Status.Actions.menu
button.isPointerInteractionEnabled = true
return button
}()

Expand All @@ -59,6 +60,7 @@ public class StatusAuthorView: UIStackView {
button.imageView?.clipsToBounds = false
let image = UIImage(systemName: "eye.slash.fill", withConfiguration: UIImage.SymbolConfiguration(font: .systemFont(ofSize: 15)))
button.setImage(image, for: .normal)
button.isPointerInteractionEnabled = true
return button
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public final class StatusCardControl: UIControl {
])

addInteraction(UIContextMenuInteraction(delegate: self))
addInteraction(UIPointerInteraction(delegate: self))
isAccessibilityElement = true
accessibilityTraits.insert(.link)
}
Expand Down Expand Up @@ -317,6 +318,15 @@ extension StatusCardControl {
}
}

extension StatusCardControl: UIPointerInteractionDelegate {
public func pointerInteraction(_ interaction: UIPointerInteraction, regionFor request: UIPointerRegionRequest, defaultRegion: UIPointerRegion) -> UIPointerRegion? {
defaultRegion
}
public func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? {
UIPointerStyle(effect: .highlight(UITargetedPreview(view: self)))
}
}

private extension StatusCardControl {
enum Layout: Equatable {
case compact
Expand Down