fix(ios): fix tap gesture conflict handling and animation in ItemPressableModule
Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
parent
5bfcbbcb16
commit
102f66e264
|
|
@ -39,22 +39,26 @@ class ItemPressableView: ExpoView {
|
|||
}
|
||||
|
||||
func initizlize() {
|
||||
gestureRecognizers = [UITapGestureRecognizer(target: self, action: #selector(handleTap))]
|
||||
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap))
|
||||
tapGesture.delegate = self
|
||||
gestureRecognizers = [tapGesture]
|
||||
}
|
||||
|
||||
@objc func handleTap() {
|
||||
let bgColor = layer.backgroundColor
|
||||
if touchHighlight {
|
||||
UIView.animate(withDuration: 0.2, delay: 0, options: [.curveEaseIn]) {
|
||||
self.layer.backgroundColor = UIColor.systemFill.cgColor
|
||||
} completion: { done in
|
||||
if done {
|
||||
UIView.animate(withDuration: 0.2, delay: 0.2, options: [.curveEaseOut]) {
|
||||
self.layer.backgroundColor = bgColor
|
||||
}
|
||||
}
|
||||
layer.backgroundColor = UIColor.systemGray5.cgColor
|
||||
|
||||
UIView.animate(withDuration: 0.2, delay: 0.5, options: [.curveEaseOut]) {
|
||||
self.layer.backgroundColor = bgColor
|
||||
}
|
||||
}
|
||||
onItemPress()
|
||||
}
|
||||
}
|
||||
|
||||
extension ItemPressableView: UIGestureRecognizerDelegate {
|
||||
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
|
||||
return touch.view == gestureRecognizer.view
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue