|
|
|
|
@ -167,78 +167,6 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
|
|
|
|
|
return bottomToolView
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
// - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
|
|
|
|
// {
|
|
|
|
|
// UIView *hitView = [super hitTest:point withEvent:event];
|
|
|
|
|
//
|
|
|
|
|
// // If the hitView is THIS view, return the view that you want to receive the touch instead:
|
|
|
|
|
// if (hitView == self) {
|
|
|
|
|
// return otherView;
|
|
|
|
|
// }
|
|
|
|
|
// // Else return the hitView (as it could be one of this view's buttons):
|
|
|
|
|
// return hitView;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
// protocol TouchInterceptorViewDelegate: class {
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
class TouchInterceptorView: UIView {
|
|
|
|
|
// weak var delegate: TouchInterceptorViewDelegate?
|
|
|
|
|
|
|
|
|
|
override init(frame: CGRect) {
|
|
|
|
|
super.init(frame: frame)
|
|
|
|
|
|
|
|
|
|
// let touchInterceptorView = TouchInterceptorView()
|
|
|
|
|
// touchInterceptorView.backgroundColor = UIColor.yellow.withAlphaComponent(0.6)
|
|
|
|
|
// let tapGesture = UITapGestureRecognizer(target: self, action: #selector(didTap(gesture:)))
|
|
|
|
|
// touchInterceptorView.addGestureRecognizer(tapGesture)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: -
|
|
|
|
|
|
|
|
|
|
var deadZoneView: UIView?
|
|
|
|
|
|
|
|
|
|
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
|
|
|
|
guard let deadZoneView = self.deadZoneView else {
|
|
|
|
|
return super.hitTest(point, with: event)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
guard !self.isHidden else {
|
|
|
|
|
return super.hitTest(point, with: event)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let convertedPoint = deadZoneView.convert(point, from: self)
|
|
|
|
|
if deadZoneView.point(inside: convertedPoint, with: event) {
|
|
|
|
|
return deadZoneView
|
|
|
|
|
} else {
|
|
|
|
|
return super.hitTest(point, with: event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lazy var touchInterceptorView: TouchInterceptorView = {
|
|
|
|
|
let touchInterceptorView = TouchInterceptorView()
|
|
|
|
|
touchInterceptorView.backgroundColor = UIColor.yellow.withAlphaComponent(0.6)
|
|
|
|
|
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(didTapTouchInterceptorView(gesture:)))
|
|
|
|
|
touchInterceptorView.addGestureRecognizer(tapGesture)
|
|
|
|
|
|
|
|
|
|
return touchInterceptorView
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
@objc
|
|
|
|
|
func didTapTouchInterceptorView(gesture: UITapGestureRecognizer) {
|
|
|
|
|
let point = gesture.location(in: currentPageController.captionView)
|
|
|
|
|
guard point
|
|
|
|
|
Logger.info("")
|
|
|
|
|
self.becomeFirstResponder()
|
|
|
|
|
touchInterceptorView.isHidden = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: - View Lifecycle
|
|
|
|
|
|
|
|
|
|
override public func viewDidLoad() {
|
|
|
|
|
@ -274,11 +202,6 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
|
|
|
|
|
selector: #selector(keyboardWillChangeFrame(notification:)),
|
|
|
|
|
name: .UIKeyboardWillChangeFrame,
|
|
|
|
|
object: nil)
|
|
|
|
|
|
|
|
|
|
view.addSubview(touchInterceptorView)
|
|
|
|
|
touchInterceptorView.autoPinEdgesToSuperviewEdges()
|
|
|
|
|
touchInterceptorView.isHidden = true
|
|
|
|
|
touchInterceptorView.deadZoneView = currentPageController.captionView
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override public func viewWillAppear(_ animated: Bool) {
|
|
|
|
|
@ -629,16 +552,32 @@ extension AttachmentApprovalViewController: AttachmentPrepViewControllerDelegate
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func prepViewController(_ prepViewController: AttachmentPrepViewController, didBeginEditingCaptionView captionView: CaptionView) {
|
|
|
|
|
self.touchInterceptorView.isHidden = false
|
|
|
|
|
// Disable paging while captions are being edited to avoid a clunky animation.
|
|
|
|
|
//
|
|
|
|
|
// Loading the next page causes the CaptionView to resign first responder, which in turn
|
|
|
|
|
// dismisses the keyboard, which in turn affects the vertical offset of both the CaptionView
|
|
|
|
|
// from the page we're leaving as well as the page we're entering. Instead we require the
|
|
|
|
|
// user to dismiss *then* swipe.
|
|
|
|
|
disablePaging()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func prepViewController(_ prepViewController: AttachmentPrepViewController, didEndEditingCaptionView captionView: CaptionView) {
|
|
|
|
|
self.touchInterceptorView.isHidden = true
|
|
|
|
|
enablePaging()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var bottomToolbarInset: CGFloat {
|
|
|
|
|
return lastKnownBottomToolbarInset
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: Helpers
|
|
|
|
|
|
|
|
|
|
func disablePaging() {
|
|
|
|
|
pagerScrollView?.panGestureRecognizer.isEnabled = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func enablePaging() {
|
|
|
|
|
self.pagerScrollView?.panGestureRecognizer.isEnabled = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: GalleryRail
|
|
|
|
|
@ -734,14 +673,13 @@ public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarD
|
|
|
|
|
return CaptionView(attachmentItem: attachmentItem)
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
// lazy var touchInterceptorView: UIView = {
|
|
|
|
|
// let touchInterceptorView = UIView()
|
|
|
|
|
// touchInterceptorView.backgroundColor = UIColor.yellow.withAlphaComponent(0.6)
|
|
|
|
|
// let tapGesture = UITapGestureRecognizer(target: self, action: #selector(didTapTouchInterceptorView(gesture:)))
|
|
|
|
|
// touchInterceptorView.addGestureRecognizer(tapGesture)
|
|
|
|
|
//
|
|
|
|
|
// return touchInterceptorView
|
|
|
|
|
// }()
|
|
|
|
|
lazy var touchInterceptorView: UIView = {
|
|
|
|
|
let touchInterceptorView = UIView()
|
|
|
|
|
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(didTapTouchInterceptorView(gesture:)))
|
|
|
|
|
touchInterceptorView.addGestureRecognizer(tapGesture)
|
|
|
|
|
|
|
|
|
|
return touchInterceptorView
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
override public func loadView() {
|
|
|
|
|
self.view = UIView()
|
|
|
|
|
@ -846,9 +784,9 @@ public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarD
|
|
|
|
|
|
|
|
|
|
// Caption
|
|
|
|
|
|
|
|
|
|
// view.addSubview(touchInterceptorView)
|
|
|
|
|
// touchInterceptorView.autoPinEdgesToSuperviewEdges()
|
|
|
|
|
// touchInterceptorView.isHidden = true
|
|
|
|
|
view.addSubview(touchInterceptorView)
|
|
|
|
|
touchInterceptorView.autoPinEdgesToSuperviewEdges()
|
|
|
|
|
touchInterceptorView.isHidden = true
|
|
|
|
|
|
|
|
|
|
view.addSubview(captionView)
|
|
|
|
|
captionView.delegate = self
|
|
|
|
|
@ -889,12 +827,12 @@ public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarD
|
|
|
|
|
|
|
|
|
|
// MARK: - Event Handlers
|
|
|
|
|
|
|
|
|
|
// @objc
|
|
|
|
|
// func didTapTouchInterceptorView(gesture: UITapGestureRecognizer) {
|
|
|
|
|
// Logger.info("")
|
|
|
|
|
// captionView.endEditing()
|
|
|
|
|
// touchInterceptorView.isHidden = true
|
|
|
|
|
// }
|
|
|
|
|
@objc
|
|
|
|
|
func didTapTouchInterceptorView(gesture: UITapGestureRecognizer) {
|
|
|
|
|
Logger.info("")
|
|
|
|
|
captionView.endEditing()
|
|
|
|
|
touchInterceptorView.isHidden = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc
|
|
|
|
|
public func didTapPlayerView(_ gestureRecognizer: UIGestureRecognizer) {
|
|
|
|
|
@ -1058,13 +996,12 @@ extension AttachmentPrepViewController: CaptionViewDelegate {
|
|
|
|
|
// This avoids a really ugly animation from simultaneously dismissing the keyboard
|
|
|
|
|
// while loading a new PrepViewController, and it's CaptionView, whose layout depends
|
|
|
|
|
// on the keyboard's position.
|
|
|
|
|
// self.touchInterceptorView.isHidden = false
|
|
|
|
|
self.touchInterceptorView.isHidden = false
|
|
|
|
|
self.prepDelegate?.prepViewController(self, didBeginEditingCaptionView: captionView)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func captionViewDidEndEditing(_ captionView: CaptionView) {
|
|
|
|
|
// self.touchInterceptorView.isHidden = true
|
|
|
|
|
|
|
|
|
|
self.touchInterceptorView.isHidden = true
|
|
|
|
|
self.prepDelegate?.prepViewController(self, didEndEditingCaptionView: captionView)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|