parent
d2f1d78aa2
commit
4e105e0fbc
|
@ -12,6 +12,7 @@ class ToastView: UIView {
|
|||
|
||||
let configuration: ToastConfiguration
|
||||
|
||||
private var panRecognizer: UIPanGestureRecognizer!
|
||||
private var shrinkAnimator: UIViewPropertyAnimator?
|
||||
private var recognizedGesture = false
|
||||
private var handledLongPress = false
|
||||
|
@ -101,9 +102,10 @@ class ToastView: UIView {
|
|||
stack.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -4),
|
||||
])
|
||||
|
||||
let pan = UIPanGestureRecognizer(target: self, action: #selector(panRecognized))
|
||||
addGestureRecognizer(pan)
|
||||
panRecognizer = UIPanGestureRecognizer(target: self, action: #selector(panRecognized))
|
||||
addGestureRecognizer(panRecognizer)
|
||||
let longPress = UILongPressGestureRecognizer(target: self, action: #selector(longPressRecognized))
|
||||
longPress.delegate = self
|
||||
addGestureRecognizer(longPress)
|
||||
}
|
||||
|
||||
|
@ -266,3 +268,11 @@ class ToastView: UIView {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
extension ToastView: UIGestureRecognizerDelegate {
|
||||
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||
// if another recognizer can recognize simulatenously (e.g., table view cell drag initiation) it should require the toast one to fail
|
||||
// otherwise long-pressing on a toast results in the drag beginning instead
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue