prevent pulling down the notification tray from messing up story viewer dismissal
This commit is contained in:
parent
678f8cb332
commit
9a65f52ae8
@ -45,13 +45,17 @@ class StoryInteractiveTransitionCoordinator: UIPercentDrivenInteractiveTransitio
|
||||
func handlePan(_ gestureRecognizer: UIPanGestureRecognizer) {
|
||||
switch gestureRecognizer.state {
|
||||
case .began:
|
||||
interactiveEdge = interactiveEdgeForCurrentGesture()
|
||||
|
||||
gestureRecognizer.setTranslation(.zero, in: pageViewController.view)
|
||||
|
||||
pageViewController.currentContextViewController.pause(hideChrome: true)
|
||||
|
||||
switch interactiveEdge {
|
||||
case .none:
|
||||
owsFailDebug("began gesture from unexpected state")
|
||||
pageViewController.currentContextViewController.play()
|
||||
cancel()
|
||||
return
|
||||
case .leading, .top, .bottom:
|
||||
pageViewController.dismiss(animated: true)
|
||||
case .trailing:
|
||||
@ -127,25 +131,8 @@ class StoryInteractiveTransitionCoordinator: UIPercentDrivenInteractiveTransitio
|
||||
|
||||
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||
guard gestureRecognizer == panGestureRecognizer else { return false }
|
||||
let translation = panGestureRecognizer.translation(in: pageViewController.view)
|
||||
let normalizedTranslationX = (CurrentAppContext().isRTL ? -1 : 1) * translation.x
|
||||
|
||||
if normalizedTranslationX > 0 {
|
||||
interactiveEdge = .leading
|
||||
return true
|
||||
} else if normalizedTranslationX < 0, pageViewController.currentContextViewController.allowsReplies {
|
||||
interactiveEdge = .trailing
|
||||
return true
|
||||
} else if pageViewController.previousStoryContext == nil, translation.y > 0 {
|
||||
interactiveEdge = .top
|
||||
return true
|
||||
} else if pageViewController.nextStoryContext == nil, translation.y < 0 {
|
||||
interactiveEdge = .bottom
|
||||
return true
|
||||
} else {
|
||||
interactiveEdge = .none
|
||||
return false
|
||||
}
|
||||
return interactiveEdgeForCurrentGesture() != .none
|
||||
}
|
||||
|
||||
func gestureRecognizer(
|
||||
@ -154,4 +141,21 @@ class StoryInteractiveTransitionCoordinator: UIPercentDrivenInteractiveTransitio
|
||||
) -> Bool {
|
||||
gestureRecognizer == panGestureRecognizer
|
||||
}
|
||||
|
||||
private func interactiveEdgeForCurrentGesture() -> Edge {
|
||||
let translation = panGestureRecognizer.translation(in: pageViewController.view)
|
||||
let normalizedTranslationX = (CurrentAppContext().isRTL ? -1 : 1) * translation.x
|
||||
|
||||
if normalizedTranslationX > 0 {
|
||||
return .leading
|
||||
} else if normalizedTranslationX < 0, pageViewController.currentContextViewController.allowsReplies {
|
||||
return .trailing
|
||||
} else if pageViewController.previousStoryContext == nil, translation.y > 0 {
|
||||
return .top
|
||||
} else if pageViewController.nextStoryContext == nil, translation.y < 0 {
|
||||
return .bottom
|
||||
} else {
|
||||
return .none
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user