Skip to content

Commit

Permalink
added tap gesture recognizer
Browse files Browse the repository at this point in the history
  • Loading branch information
ab1470 committed Nov 8, 2024
1 parent e8ddcbe commit c8e3038
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ public class KlaviyoWebWrapperViewController: UIViewController {
let viewModel: KlaviyoWebViewModeling
let style: KlaviyoWebWrapperStyle

private lazy var dismissGestureRecognizer: UITapGestureRecognizer = {
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleDismissGesture))
tapRecognizer.numberOfTapsRequired = 1
tapRecognizer.numberOfTouchesRequired = 1
return tapRecognizer
}()

// MARK: - Subviews

private lazy var blurEffectView: UIVisualEffectView? = {
Expand All @@ -22,6 +29,8 @@ public class KlaviyoWebWrapperViewController: UIViewController {
let blurEffect = UIBlurEffect(style: effect)
let blurEffectView = UIVisualEffectView(effect: blurEffect)

blurEffectView.addGestureRecognizer(dismissGestureRecognizer)

return blurEffectView
}()

Expand All @@ -32,6 +41,8 @@ public class KlaviyoWebWrapperViewController: UIViewController {
tintView.backgroundColor = color
tintView.layer.opacity = opacity

tintView.addGestureRecognizer(dismissGestureRecognizer)

return tintView
}()

Expand Down Expand Up @@ -110,6 +121,12 @@ public class KlaviyoWebWrapperViewController: UIViewController {
webViewController.didMove(toParent: self)
}
}

// MARK: - user interactions

@objc private func handleDismissGesture() {
viewModel.dismiss()
}
}

// MARK: - Previews
Expand Down

0 comments on commit c8e3038

Please sign in to comment.