marinofaggiana 4 rokov pred
rodič
commit
3685fefd7c

+ 1 - 1
iOSClient/Viewer/NCViewerImage/NCViewerImage.swift

@@ -640,7 +640,7 @@ extension NCViewerImage: UIGestureRecognizerDelegate {
     @objc func didSingleTapWith(gestureRecognizer: UITapGestureRecognizer) {
     @objc func didSingleTapWith(gestureRecognizer: UITapGestureRecognizer) {
              
              
         if currentViewerImageZoom?.detailView.isShow() ?? false {
         if currentViewerImageZoom?.detailView.isShow() ?? false {
-            currentViewerImageZoom?.updateConstraints()
+            currentViewerImageZoom?.centreConstraints()
             return
             return
         }
         }
         
         

+ 9 - 16
iOSClient/Viewer/NCViewerImage/NCViewerImageZoom.swift

@@ -88,14 +88,14 @@ class NCViewerImageZoom: UIViewController {
         }
         }
         
         
         updateZoomScale()
         updateZoomScale()
-        updateConstraints()
+        centreConstraints()
     }
     }
     
     
     override func viewWillAppear(_ animated: Bool) {
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
         super.viewWillAppear(animated)
 
 
         updateZoomScale()
         updateZoomScale()
-        updateConstraints()
+        centreConstraints()
     }
     }
     
     
     override func viewDidAppear(_ animated: Bool) {
     override func viewDidAppear(_ animated: Bool) {
@@ -106,7 +106,7 @@ class NCViewerImageZoom: UIViewController {
         detailView.hide()
         detailView.hide()
         
         
         updateZoomScale()
         updateZoomScale()
-        updateConstraints()
+        centreConstraints()
         
         
         delegate?.presentImageZoom(viewerImageZoom: self, metadata: metadata)
         delegate?.presentImageZoom(viewerImageZoom: self, metadata: metadata)
     }
     }
@@ -115,7 +115,7 @@ class NCViewerImageZoom: UIViewController {
         super.viewDidLayoutSubviews()
         super.viewDidLayoutSubviews()
         
         
         updateZoomScale()
         updateZoomScale()
-        updateConstraints()
+        centreConstraints()
     }
     }
     
     
     //MARK: - Gesture
     //MARK: - Gesture
@@ -151,7 +151,6 @@ class NCViewerImageZoom: UIViewController {
         case .began:
         case .began:
             
             
             startPoint = CGPoint(x: currentLocation.x, y: currentLocation.y)
             startPoint = CGPoint(x: currentLocation.x, y: currentLocation.y)
-            scrollView.isScrollEnabled = false
             // save start
             // save start
             startImageViewTopConstraint = imageViewTopConstraint.constant
             startImageViewTopConstraint = imageViewTopConstraint.constant
             startImageViewBottomConstraint = imageViewBottomConstraint.constant
             startImageViewBottomConstraint = imageViewBottomConstraint.constant
@@ -159,8 +158,7 @@ class NCViewerImageZoom: UIViewController {
         case .ended:
         case .ended:
             
             
             if !detailView.isShow() {
             if !detailView.isShow() {
-                updateConstraints()
-                scrollView.isScrollEnabled = true
+                centreConstraints()
             }
             }
             
             
         case .changed:
         case .changed:
@@ -168,17 +166,12 @@ class NCViewerImageZoom: UIViewController {
             let deltaY = startPoint.y - currentLocation.y
             let deltaY = startPoint.y - currentLocation.y
             print(deltaY)
             print(deltaY)
             
             
-            // close
-            if deltaY < -50 && detailView.isShow() {
-                
-            }
-                        
             imageViewTopConstraint.constant = startImageViewTopConstraint + currentLocation.y
             imageViewTopConstraint.constant = startImageViewTopConstraint + currentLocation.y
             imageViewBottomConstraint.constant = startImageViewBottomConstraint - currentLocation.y
             imageViewBottomConstraint.constant = startImageViewBottomConstraint - currentLocation.y
             detailViewTopConstraint.constant = -imageViewBottomConstraint.constant
             detailViewTopConstraint.constant = -imageViewBottomConstraint.constant
             
             
             // DISMISS
             // DISMISS
-            if imageView.center.y > view.center.y + 150 {
+            if imageView.center.y > view.center.y + (view.bounds.height / 4) {
                 
                 
                 delegate?.dismissImageZoom()
                 delegate?.dismissImageZoom()
             }
             }
@@ -201,7 +194,7 @@ class NCViewerImageZoom: UIViewController {
                 
                 
                 if detailView.isShow() {
                 if detailView.isShow() {
                     detailView.hide()
                     detailView.hide()
-                    gestureRecognizer.state = .ended
+//                    gestureRecognizer.state = .ended
                 }
                 }
             }
             }
             
             
@@ -224,7 +217,7 @@ class NCViewerImageZoom: UIViewController {
         scrollView.maximumZoomScale = 1
         scrollView.maximumZoomScale = 1
     }
     }
     
     
-    func updateConstraints() {
+    func centreConstraints() {
         
         
         let size = view.bounds.size
         let size = view.bounds.size
         let yOffset = max(0, (size.height - imageView.frame.height) / 2)
         let yOffset = max(0, (size.height - imageView.frame.height) / 2)
@@ -253,7 +246,7 @@ extension NCViewerImageZoom: UIScrollViewDelegate {
     }
     }
     
     
     func scrollViewDidZoom(_ scrollView: UIScrollView) {
     func scrollViewDidZoom(_ scrollView: UIScrollView) {
-        updateConstraints()
+        centreConstraints()
     }
     }
     
     
     func scrollViewDidScroll(_ scrollView: UIScrollView) {
     func scrollViewDidScroll(_ scrollView: UIScrollView) {