diff --git a/Tusker/Views/Toast/ToastView.swift b/Tusker/Views/Toast/ToastView.swift index a0aae067..4410ecbf 100644 --- a/Tusker/Views/Toast/ToastView.swift +++ b/Tusker/Views/Toast/ToastView.swift @@ -53,6 +53,8 @@ class ToastView: UIView { layer.shadowOpacity = 0.5 layer.masksToBounds = false + addInteraction(UIPointerInteraction(delegate: self)) + let stack = UIStackView() stack.translatesAutoresizingMaskIntoConstraints = false stack.axis = .horizontal @@ -282,3 +284,21 @@ extension ToastView: UIGestureRecognizerDelegate { return true } } + +extension ToastView: UIPointerInteractionDelegate { + func pointerInteraction(_ interaction: UIPointerInteraction, regionFor request: UIPointerRegionRequest, defaultRegion: UIPointerRegion) -> UIPointerRegion? { + return defaultRegion + } + + func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? { + return UIPointerStyle(effect: .highlight(UITargetedPreview(view: self))) + } + + func pointerInteraction(_ interaction: UIPointerInteraction, willEnter region: UIPointerRegion, animator: UIPointerInteractionAnimating) { + shouldDismissAutomatically = false + } + + func pointerInteraction(_ interaction: UIPointerInteraction, willExit region: UIPointerRegion, animator: UIPointerInteractionAnimating) { + shouldDismissAutomatically = true + } +}