Browse Source

alignament V4.0.5

marinofaggiana 3 years ago
parent
commit
2c6a4da2dc

+ 12 - 0
iOSClient/Viewer/NCViewerImage/NCViewerImageDetailView.swift

@@ -51,6 +51,10 @@ class NCViewerImageDetailView: UIView {
     var size: Int64 = 0
     var image: UIImage?
     
+    var imageViewTopConstraintConstant: CGFloat = 0
+    var imageViewBottomConstraintConstant: CGFloat = 0
+    var detailViewTopConstraintConstant: CGFloat = 0
+    
     override func awakeFromNib() {
         super.awakeFromNib()
            
@@ -81,12 +85,20 @@ class NCViewerImageDetailView: UIView {
     
     func hide() {
         isHidden = true
+        
+        imageViewTopConstraintConstant = 0
+        imageViewBottomConstraintConstant = 0
+        detailViewTopConstraintConstant = 0
     }
     
     func isShow() -> Bool {
         return !isHidden
     }
     
+    func isSavedContraint() -> Bool {
+        return imageViewTopConstraintConstant != 0 && imageViewBottomConstraintConstant != 0 && detailViewTopConstraintConstant != 0
+    }
+    
     //MARK: - EXIF
     
     func update(metadata: tableMetadata, image: UIImage?, heightMap:  CGFloat) {

+ 13 - 2
iOSClient/Viewer/NCViewerImage/NCViewerImageZoom.swift

@@ -200,6 +200,14 @@ class NCViewerImageZoom: UIViewController {
                     self.updateZoomScale()
                     self.centreConstraints()
                 }
+            } else if detailView.isSavedContraint() {
+                UIView.animate(withDuration: 0.3) {
+                    self.imageViewTopConstraint.constant = self.detailView.imageViewTopConstraintConstant
+                    self.imageViewBottomConstraint.constant = self.detailView.imageViewBottomConstraintConstant
+                    self.detailViewTopConstraint.constant = self.detailView.detailViewTopConstraintConstant
+                    self.view.layoutIfNeeded()
+                } completion: { (_) in
+                }
             }
             
         case .changed:
@@ -231,11 +239,14 @@ class NCViewerImageZoom: UIViewController {
                         self.detailViewTopConstraint.constant = -self.imageViewBottomConstraint.constant
                         self.view.layoutIfNeeded()
                     } completion: { (_) in
-                        //end.
+                        // Save detail constraints
+                        self.detailView.imageViewTopConstraintConstant = self.imageViewTopConstraint.constant
+                        self.detailView.imageViewBottomConstraintConstant = self.imageViewBottomConstraint.constant
+                        self.detailView.detailViewTopConstraintConstant = self.detailViewTopConstraint.constant
                     }
                 }
                 
-                detailView.show(textColor: self.viewerImage?.textColor)
+                //detailView.show(textColor: self.viewerImage?.textColor)
             }
             
             // CLOSE DETAIL