added swipe right and tap background events for dismissing self
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
6123f9cc1f
commit
1ca4fdf794
@ -12,6 +12,9 @@ import VDSColorTokens
|
||||
|
||||
open class TooltipAlertViewController: UIViewController, Surfaceable {
|
||||
|
||||
/// Set of Subscribers for any Publishers for this Control
|
||||
public var subscribers = Set<AnyCancellable>()
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Private Properties
|
||||
//--------------------------------------------------
|
||||
@ -60,10 +63,6 @@ open class TooltipAlertViewController: UIViewController, Surfaceable {
|
||||
button.setTitle("Close", for: .normal)
|
||||
button.titleLabel?.font = TextStyle.bodyLarge.font
|
||||
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
|
||||
}()
|
||||
|
||||
@ -90,6 +89,28 @@ open class TooltipAlertViewController: UIViewController, Surfaceable {
|
||||
}
|
||||
|
||||
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(contentLabel)
|
||||
scrollView.addSubview(containerView)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user