WIP: require dismiss before swipe

pull/1/head
Michael Kirk 7 years ago
parent 706dd3d0c1
commit b98b3d1fdd

@ -551,6 +551,14 @@ extension AttachmentApprovalViewController: AttachmentPrepViewControllerDelegate
self.approvalDelegate?.attachmentApproval?(self, changedCaptionOfAttachment: attachmentItem.attachment) self.approvalDelegate?.attachmentApproval?(self, changedCaptionOfAttachment: attachmentItem.attachment)
} }
// func prepViewController(_ prepViewController: AttachmentPrepViewController, didBeginEditingCaptionView captionView: CaptionView) {
// self.touchInterceptorView.isHidden = false
// }
//
// func prepViewController(_ prepViewController: AttachmentPrepViewController, didEndEditingCaptionView captionView: CaptionView) {
// self.touchInterceptorView.isHidden = true
// }
var bottomToolbarInset: CGFloat { var bottomToolbarInset: CGFloat {
return lastKnownBottomToolbarInset return lastKnownBottomToolbarInset
} }
@ -602,6 +610,9 @@ extension AttachmentApprovalViewController: GalleryRailViewDelegate {
protocol AttachmentPrepViewControllerDelegate: class { protocol AttachmentPrepViewControllerDelegate: class {
func prepViewController(_ prepViewController: AttachmentPrepViewController, didUpdateCaptionForAttachmentItem attachmentItem: SignalAttachmentItem) func prepViewController(_ prepViewController: AttachmentPrepViewController, didUpdateCaptionForAttachmentItem attachmentItem: SignalAttachmentItem)
// func prepViewController(_ prepViewController: AttachmentPrepViewController, didBeginEditingCaptionView captionView: CaptionView)
// func prepViewController(_ prepViewController: AttachmentPrepViewController, didEndEditingCaptionView captionView: CaptionView)
var bottomToolbarInset: CGFloat { get } var bottomToolbarInset: CGFloat { get }
} }
@ -646,6 +657,15 @@ public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarD
return CaptionView(attachmentItem: attachmentItem) 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
}()
override public func loadView() { override public func loadView() {
self.view = UIView() self.view = UIView()
@ -749,6 +769,10 @@ public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarD
// Caption // Caption
view.addSubview(touchInterceptorView)
touchInterceptorView.autoPinEdgesToSuperviewEdges()
touchInterceptorView.isHidden = true
view.addSubview(captionView) view.addSubview(captionView)
captionView.delegate = self captionView.delegate = self
@ -786,15 +810,21 @@ public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarD
captionView.superview?.layoutIfNeeded() captionView.superview?.layoutIfNeeded()
} }
// MARK: - // MARK: - Event Handlers
@objc public func didTapPlayerView(_ gestureRecognizer: UIGestureRecognizer) { @objc
func didTapTouchInterceptorView(gesture: UITapGestureRecognizer) {
Logger.info("")
captionView.endEditing()
touchInterceptorView.isHidden = true
}
@objc
public func didTapPlayerView(_ gestureRecognizer: UIGestureRecognizer) {
assert(self.videoPlayer != nil) assert(self.videoPlayer != nil)
self.pauseVideo() self.pauseVideo()
} }
// MARK: - Event Handlers
@objc @objc
public func playButtonTapped() { public func playButtonTapped() {
self.playVideo() self.playVideo()
@ -945,6 +975,21 @@ extension AttachmentPrepViewController: CaptionViewDelegate {
attachment.captionText = captionText attachment.captionText = captionText
prepDelegate?.prepViewController(self, didUpdateCaptionForAttachmentItem: attachmentItem) prepDelegate?.prepViewController(self, didUpdateCaptionForAttachmentItem: attachmentItem)
} }
func captionViewDidBeginEditing(_ captionView: CaptionView) {
// Don't allow user to pan until they've dismissed the keyboard.
// 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.prepDelegate?.prepViewController(self, didBeginEditingCaptionView: captionView)
}
func captionViewDidEndEditing(_ captionView: CaptionView) {
self.touchInterceptorView.isHidden = true
// self.prepDelegate?.prepViewController(self, didEndEditingCaptionView: captionView)
}
} }
extension AttachmentPrepViewController: UIScrollViewDelegate { extension AttachmentPrepViewController: UIScrollViewDelegate {
@ -1062,6 +1107,8 @@ class BottomToolView: UIView {
protocol CaptionViewDelegate: class { protocol CaptionViewDelegate: class {
func captionView(_ captionView: CaptionView, didChangeCaptionText captionText: String?, attachmentItem: SignalAttachmentItem) func captionView(_ captionView: CaptionView, didChangeCaptionText captionText: String?, attachmentItem: SignalAttachmentItem)
func captionViewDidBeginEditing(_ captionView: CaptionView)
func captionViewDidEndEditing(_ captionView: CaptionView)
} }
class CaptionView: UIView { class CaptionView: UIView {
@ -1113,7 +1160,12 @@ class CaptionView: UIView {
// MARK: // MARK:
func endEditing() {
textView.resignFirstResponder()
}
override var inputAccessoryView: UIView? { override var inputAccessoryView: UIView? {
// Don't inherit the vc's inputAccessoryView
return nil return nil
} }
@ -1169,10 +1221,12 @@ class CaptionView: UIView {
extension CaptionView: UITextViewDelegate { extension CaptionView: UITextViewDelegate {
public func textViewDidBeginEditing(_ textView: UITextView) { public func textViewDidBeginEditing(_ textView: UITextView) {
updatePlaceholderTextViewVisibility() updatePlaceholderTextViewVisibility()
delegate?.captionViewDidBeginEditing(self)
} }
public func textViewDidEndEditing(_ textView: UITextView) { public func textViewDidEndEditing(_ textView: UITextView) {
updatePlaceholderTextViewVisibility() updatePlaceholderTextViewVisibility()
delegate?.captionViewDidEndEditing(self)
} }
public func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { public func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {

Loading…
Cancel
Save