Merge branch 'mkirk/restrict-pan-gesture'

pull/1/head
Michael Kirk 7 years ago
commit fa9ac5aa46

@ -283,7 +283,7 @@ const CGFloat OWSMessageCellCornerRadius = 17;
[self.textBubbleImageView addGestureRecognizer:textLongPress];
PanDirectionGestureRecognizer *panGesture =
[[PanDirectionGestureRecognizer alloc] initWithDirection:PanDirectionHorizontal
[[PanDirectionGestureRecognizer alloc] initWithDirection:(self.isRTL ? PanDirectionLeft : PanDirectionRight)
target:self
action:@selector(handlePanGesture:)];
[self addGestureRecognizer:panGesture];

@ -1,13 +1,12 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
import UIKit.UIGestureRecognizerSubclass
@objc
enum PanDirection: Int {
case vertical
case horizontal
case left, right, up, down, any
}
@objc
@ -17,19 +16,50 @@ class PanDirectionGestureRecognizer: UIPanGestureRecognizer {
init(direction: PanDirection, target: AnyObject, action: Selector) {
self.direction = direction
super.init(target: target, action: action)
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent) {
// Only start gesture if it's initially in the specified direction.
if state == .possible {
guard let touch = touches.first else {
return
}
let previousLocation = touch.previousLocation(in: view)
let location = touch.location(in: view)
let deltaY = previousLocation.y - location.y
let deltaX = previousLocation.x - location.x
switch direction {
case .up where deltaY > 0:
return
case .down where deltaY < 0:
return
case .left where deltaX > 0:
return
case .right where deltaX < 0:
return
default:
break
}
}
// Gesture was already started, or in the correct direction.
super.touchesMoved(touches, with: event)
if state == .began {
let vel = velocity(in: view)
switch direction {
case .horizontal where fabs(vel.y) > fabs(vel.x):
state = .cancelled
case .vertical where fabs(vel.x) > fabs(vel.y):
state = .cancelled
case .left, .right:
if fabs(vel.y) > fabs(vel.x) {
state = .cancelled
}
case .up, .down:
if fabs(vel.x) > fabs(vel.y) {
state = .cancelled
}
default:
break
}

@ -713,7 +713,7 @@
"FINGERPRINT_SCAN_VERIFY_BUTTON" = "Mark as Verified";
/* No comment provided by engineer. */
"FINGERPRINT_SHRED_KEYMATERIAL_BUTTON" = "Reset this session";
"FINGERPRINT_SHRED_KEYMATERIAL_BUTTON" = "Reset Session";
/* Accessibilty label for finishing new group */
"FINISH_GROUP_CREATION_LABEL" = "Finish creating group";

Loading…
Cancel
Save