added swipe right and tap background events for dismissing self

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-06-30 09:17:23 -05:00
parent 6123f9cc1f
commit 1ca4fdf794

View File

@ -12,6 +12,9 @@ import VDSColorTokens
open class TooltipAlertViewController: UIViewController, Surfaceable { open class TooltipAlertViewController: UIViewController, Surfaceable {
/// Set of Subscribers for any Publishers for this Control
public var subscribers = Set<AnyCancellable>()
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Private Properties // MARK: - Private Properties
//-------------------------------------------------- //--------------------------------------------------
@ -60,10 +63,6 @@ open class TooltipAlertViewController: UIViewController, Surfaceable {
button.setTitle("Close", for: .normal) button.setTitle("Close", for: .normal)
button.titleLabel?.font = TextStyle.bodyLarge.font button.titleLabel?.font = TextStyle.bodyLarge.font
button.translatesAutoresizingMaskIntoConstraints = false button.translatesAutoresizingMaskIntoConstraints = false
onClickSubscriber = button.publisher(for: .touchUpInside).sink {[weak self] button in
guard let self else { return }
self.dismiss(animated: true, completion: nil)
}
return button return button
}() }()
@ -90,6 +89,28 @@ open class TooltipAlertViewController: UIViewController, Surfaceable {
} }
open func setup() { open func setup() {
//left-right swipe
view.publisher(for: UISwipeGestureRecognizer().with{ $0.direction = .right })
.sink { [weak self] swipe in
guard let self else { return }
self.dismiss(animated: true, completion: nil)
}.store(in: &subscribers)
//tapping in background
view.publisher(for: UITapGestureRecognizer().with{ $0.numberOfTapsRequired = 1 })
.sink { [weak self] swipe in
guard let self else { return }
self.dismiss(animated: true, completion: nil)
}.store(in: &subscribers)
//clicking button
onClickSubscriber = closeButton.publisher(for: .touchUpInside)
.sink {[weak self] button in
guard let self else { return }
self.dismiss(animated: true, completion: nil)
}
containerView.addSubview(titleLabel) containerView.addSubview(titleLabel)
containerView.addSubview(contentLabel) containerView.addSubview(contentLabel)
scrollView.addSubview(containerView) scrollView.addSubview(containerView)