Skip to content

Commit

Permalink
♻️ Add target interaction gesture delegate
Browse files Browse the repository at this point in the history
Ensures `AppcuesTargetInteractionTrait` works with Capacitor
  • Loading branch information
mmaatttt committed Oct 21, 2024
1 parent afaa309 commit 94aa227
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,21 @@ internal class AppcuesTargetInteractionTrait: AppcuesBackdropDecoratingTrait {

@available(iOS 13.0, *)
extension AppcuesTargetInteractionTrait {
class TargetView: UIView {
class TargetView: UIView, UIGestureRecognizerDelegate {
private weak var appWindow: UIWindow?
private weak var trait: AppcuesTargetInteractionTrait?

private lazy var tapRecognizer: UITapGestureRecognizer = {
let recognizer = UITapGestureRecognizer(target: self, action: #selector(didTapInApp(recognizer:)))
recognizer.cancelsTouchesInView = false
recognizer.delegate = self
return recognizer
}()

private lazy var longPressRecognizer: UILongPressGestureRecognizer = {
let recognizer = UILongPressGestureRecognizer(target: self, action: #selector(didLongPressInApp(recognizer:)))
recognizer.cancelsTouchesInView = false
recognizer.delegate = self
return recognizer
}()

Expand Down Expand Up @@ -200,6 +202,10 @@ extension AppcuesTargetInteractionTrait {
}
}

func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
true
}

@objc
private func didTapInApp(recognizer: UITapGestureRecognizer) {
if recognizer.view != self {
Expand Down

0 comments on commit 94aa227

Please sign in to comment.