Skip to content

Commit

Permalink
open detail, added animation
Browse files Browse the repository at this point in the history
Signed-off-by: Marino Faggiana <[email protected]>
  • Loading branch information
marinofaggiana committed Oct 5, 2023
1 parent a245af4 commit 472de2f
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit 472de2f

Please sign in to comment.