Ver Fonte

open detail, added animation

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana há 1 ano atrás
pai
commit
472de2f44c
1 ficheiros alterados com 27 adições e 23 exclusões
  1. 27 23
      iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift

+ 27 - 23
iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift

@@ -485,35 +485,39 @@ extension NCViewerMedia {
     private func openDetail(animate: Bool = true) {
         delegate?.didOpenDetail()
         self.dismissTip()
-        
-        self.scrollView.setZoomScale(1.0, animated: false)
 
-        statusLabel.isHidden = true
-        statusViewImage.isHidden = true
+        UIView.animate(withDuration: 0.3) {
+            self.scrollView.setZoomScale(1.0, animated: false)
 
-        NCUtility.shared.getExif(metadata: metadata) { exif in
-            self.view.layoutIfNeeded()
-            self.showDetailView(exif: exif)
-
-            if let image = self.imageVideoContainer.image {
-                let ratioW = self.imageVideoContainer.frame.width / image.size.width
-                let ratioH = self.imageVideoContainer.frame.height / image.size.height
-                let ratio = min(ratioW, ratioH)
-                let imageHeight = image.size.height * ratio
-                let imageContainerHeight = self.imageVideoContainer.frame.height * ratio
-                let height = max(imageHeight, imageContainerHeight)
-                self.imageViewConstraint = self.detailView.frame.height - ((self.view.frame.height - height) / 2) + self.view.safeAreaInsets.bottom
-                if self.imageViewConstraint < 0 { self.imageViewConstraint = 0 }
-            }
+            self.statusLabel.isHidden = true
+            self.statusViewImage.isHidden = true
 
-            UIView.animate(withDuration: animate ? 0.3 : 0) {
-                self.imageViewTopConstraint.constant = -self.imageViewConstraint
-                self.imageViewBottomConstraint.constant = self.imageViewConstraint
-                self.detailViewTopConstraint.constant = self.detailView.frame.height
+            NCUtility.shared.getExif(metadata: self.metadata) { exif in
                 self.view.layoutIfNeeded()
+                self.showDetailView(exif: exif)
+
+                if let image = self.imageVideoContainer.image {
+                    let ratioW = self.imageVideoContainer.frame.width / image.size.width
+                    let ratioH = self.imageVideoContainer.frame.height / image.size.height
+                    let ratio = min(ratioW, ratioH)
+                    let imageHeight = image.size.height * ratio
+                    let imageContainerHeight = self.imageVideoContainer.frame.height * ratio
+                    let height = max(imageHeight, imageContainerHeight)
+                    self.imageViewConstraint = self.detailView.frame.height - ((self.view.frame.height - height) / 2) + self.view.safeAreaInsets.bottom
+                    if self.imageViewConstraint < 0 { self.imageViewConstraint = 0 }
+                }
+
+                UIView.animate(withDuration: animate ? 0.3 : 0) {
+                    self.imageViewTopConstraint.constant = -self.imageViewConstraint
+                    self.imageViewBottomConstraint.constant = self.imageViewConstraint
+                    self.detailViewTopConstraint.constant = self.detailView.frame.height
+                    self.view.layoutIfNeeded()
+                }
+
+                self.scrollView.pinchGestureRecognizer?.isEnabled = false
             }
+        } completion: { _ in
 
-            self.scrollView.pinchGestureRecognizer?.isEnabled = false
         }
     }