From 472de2f44cd2cf0f2157233a1eeb650f03884e91 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Thu, 5 Oct 2023 10:35:26 +0200 Subject: [PATCH] open detail, added animation Signed-off-by: Marino Faggiana --- .../Viewer/NCViewerMedia/NCViewerMedia.swift | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift index 4a2b4c4cec..e7856e0bc3 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift +++ b/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 } }