NCViewerMedia.swift 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. //
  2. // NCViewerMedia.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 24/10/2020.
  6. // Copyright © 2020 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. import UIKit
  24. import SVGKit
  25. import NextcloudKit
  26. import EasyTipView
  27. import SwiftUI
  28. import MobileVLCKit
  29. import JGProgressHUD
  30. import Alamofire
  31. import VisionKit
  32. public protocol NCViewerMediaViewDelegate: AnyObject {
  33. func didOpenDetail()
  34. func didCloseDetail()
  35. }
  36. class NCViewerMedia: UIViewController {
  37. @IBOutlet weak var detailViewTopConstraint: NSLayoutConstraint!
  38. @IBOutlet weak var imageViewTopConstraint: NSLayoutConstraint!
  39. @IBOutlet weak var imageViewBottomConstraint: NSLayoutConstraint!
  40. @IBOutlet weak var scrollView: UIScrollView!
  41. @IBOutlet weak var imageVideoContainer: UIImageView!
  42. @IBOutlet weak var statusViewImage: UIImageView!
  43. @IBOutlet weak var statusLabel: UILabel!
  44. @IBOutlet weak var detailView: NCViewerMediaDetailView!
  45. private var tipView: EasyTipView?
  46. private let player = VLCMediaPlayer()
  47. private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
  48. let analyzer = Analyzer()
  49. let utilityFileSystem = NCUtilityFileSystem()
  50. let utility = NCUtility()
  51. weak var viewerMediaPage: NCViewerMediaPage?
  52. var playerToolBar: NCPlayerToolBar?
  53. var ncplayer: NCPlayer?
  54. var image: UIImage? {
  55. didSet {
  56. if #available(iOS 16, *), metadata.isImage {
  57. analyzer.imageInteraction?.preferredInteractionTypes = []
  58. analyzer.imageInteraction?.analysis = nil
  59. // analyzeCurrentImage()
  60. }
  61. }
  62. }
  63. var metadata: tableMetadata = tableMetadata()
  64. var index: Int = 0
  65. var doubleTapGestureRecognizer: UITapGestureRecognizer = UITapGestureRecognizer()
  66. var imageViewConstraint: CGFloat = 0
  67. var isDetailViewInitializze: Bool = false
  68. weak var delegate: NCViewerMediaViewDelegate?
  69. private var allowOpeningDetails = true
  70. // MARK: - View Life Cycle
  71. required init?(coder aDecoder: NSCoder) {
  72. super.init(coder: aDecoder)
  73. doubleTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(didDoubleTapWith(gestureRecognizer:)))
  74. doubleTapGestureRecognizer.numberOfTapsRequired = 2
  75. }
  76. deinit {
  77. print("deinit NCViewerMedia")
  78. self.tipView?.dismiss()
  79. NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterOpenMediaDetail), object: nil)
  80. }
  81. override func viewDidLoad() {
  82. super.viewDidLoad()
  83. scrollView.delegate = self
  84. scrollView.maximumZoomScale = 4
  85. scrollView.minimumZoomScale = 1
  86. view.addGestureRecognizer(doubleTapGestureRecognizer)
  87. if NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata) != nil {
  88. statusViewImage.image = utility.loadImage(named: "livephoto", color: .gray)
  89. statusLabel.text = "LIVE"
  90. } else {
  91. statusViewImage.image = nil
  92. statusLabel.text = ""
  93. }
  94. if metadata.isAudioOrVideo {
  95. playerToolBar = Bundle.main.loadNibNamed("NCPlayerToolBar", owner: self, options: nil)?.first as? NCPlayerToolBar
  96. if let playerToolBar = playerToolBar {
  97. view.addSubview(playerToolBar)
  98. playerToolBar.translatesAutoresizingMaskIntoConstraints = false
  99. playerToolBar.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true
  100. playerToolBar.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
  101. playerToolBar.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
  102. playerToolBar.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
  103. }
  104. self.ncplayer = NCPlayer(imageVideoContainer: self.imageVideoContainer, playerToolBar: self.playerToolBar, metadata: self.metadata, viewerMediaPage: self.viewerMediaPage)
  105. }
  106. // TIP
  107. var preferences = EasyTipView.Preferences()
  108. preferences.drawing.foregroundColor = .white
  109. preferences.drawing.backgroundColor = NCBrandColor.shared.nextcloud
  110. preferences.drawing.textAlignment = .left
  111. preferences.drawing.arrowPosition = .bottom
  112. preferences.drawing.cornerRadius = 10
  113. preferences.animating.dismissTransform = CGAffineTransform(translationX: 0, y: -15)
  114. preferences.animating.showInitialTransform = CGAffineTransform(translationX: 0, y: -15)
  115. preferences.animating.showInitialAlpha = 0
  116. preferences.animating.showDuration = 0.5
  117. preferences.animating.dismissDuration = 0
  118. tipView = EasyTipView(text: NSLocalizedString("_tip_open_mediadetail_", comment: ""), preferences: preferences, delegate: self)
  119. detailViewTopConstraint.constant = 0
  120. detailView.hide()
  121. self.image = nil
  122. self.imageVideoContainer.image = nil
  123. loadImage()
  124. if #available(iOS 16, *) {
  125. if let interaction = analyzer.imageInteraction {
  126. self.imageVideoContainer.addInteraction(interaction)
  127. }
  128. }
  129. }
  130. override func viewWillAppear(_ animated: Bool) {
  131. super.viewWillAppear(animated)
  132. viewerMediaPage?.navigationController?.navigationBar.prefersLargeTitles = false
  133. viewerMediaPage?.navigationItem.title = (metadata.fileNameView as NSString).deletingPathExtension
  134. if metadata.isImage, let viewerMediaPage = self.viewerMediaPage {
  135. if viewerMediaPage.modifiedOcId.contains(metadata.ocId) {
  136. viewerMediaPage.modifiedOcId.removeAll(where: { $0 == metadata.ocId })
  137. loadImage()
  138. }
  139. }
  140. }
  141. override func viewDidAppear(_ animated: Bool) {
  142. super.viewDidAppear(animated)
  143. // Set Last Opening Date
  144. NCManageDatabase.shared.setLastOpeningDate(metadata: metadata)
  145. viewerMediaPage?.clearCommandCenter()
  146. if metadata.isAudioOrVideo {
  147. if let ncplayer = self.ncplayer {
  148. if ncplayer.url == nil {
  149. NCActivityIndicator.shared.startActivity(backgroundView: self.view, style: .medium)
  150. NCNetworking.shared.getVideoUrl(metadata: metadata) { url, autoplay, error in
  151. NCActivityIndicator.shared.stop()
  152. if error == .success, let url = url {
  153. ncplayer.openAVPlayer(url: url, autoplay: autoplay)
  154. } else {
  155. guard let metadata = NCManageDatabase.shared.setMetadatasSessionInWaitDownload(metadatas: [self.metadata],
  156. session: NextcloudKit.shared.nkCommonInstance.sessionIdentifierDownload,
  157. selector: "") else { return }
  158. var downloadRequest: DownloadRequest?
  159. let hud = JGProgressHUD()
  160. hud.indicatorView = JGProgressHUDRingIndicatorView()
  161. hud.textLabel.text = NSLocalizedString("_downloading_", comment: "")
  162. hud.detailTextLabel.text = NSLocalizedString("_tap_to_cancel_", comment: "")
  163. if let indicatorView = hud.indicatorView as? JGProgressHUDRingIndicatorView { indicatorView.ringWidth = 1.5 }
  164. hud.tapOnHUDViewBlock = { _ in
  165. if let request = downloadRequest {
  166. request.cancel()
  167. }
  168. }
  169. if let view = self.appDelegate.window?.rootViewController?.view {
  170. hud.show(in: view)
  171. }
  172. NCNetworking.shared.download(metadata: metadata, withNotificationProgressTask: false) {
  173. } requestHandler: { request in
  174. downloadRequest = request
  175. } progressHandler: { progress in
  176. hud.progress = Float(progress.fractionCompleted)
  177. } completion: { _, error in
  178. DispatchQueue.main.async {
  179. if error == .success {
  180. hud.dismiss()
  181. if self.utilityFileSystem.fileProviderStorageExists(self.metadata) {
  182. let url = URL(fileURLWithPath: self.utilityFileSystem.getDirectoryProviderStorageOcId(self.metadata.ocId, fileNameView: self.metadata.fileNameView))
  183. ncplayer.openAVPlayer(url: url, autoplay: autoplay)
  184. }
  185. } else {
  186. hud.indicatorView = JGProgressHUDErrorIndicatorView()
  187. hud.textLabel.text = error.errorDescription
  188. hud.dismiss(afterDelay: NCGlobal.shared.dismissAfterSecond)
  189. }
  190. }
  191. }
  192. }
  193. }
  194. } else {
  195. var position: Float = 0
  196. if let result = NCManageDatabase.shared.getVideo(metadata: metadata), let resultPosition = result.position {
  197. position = resultPosition
  198. }
  199. ncplayer.restartAVPlayer(position: position, pauseAfterPlay: true)
  200. }
  201. }
  202. } else if metadata.isImage {
  203. DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
  204. self.showTip()
  205. }
  206. }
  207. NotificationCenter.default.addObserver(self, selector: #selector(openDetail(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterOpenMediaDetail), object: nil)
  208. NotificationCenter.default.addObserver(self, selector: #selector(closeDetail(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterDownloadStartFile), object: nil)
  209. }
  210. override func viewWillDisappear(_ animated: Bool) {
  211. super.viewWillDisappear(animated)
  212. self.tipView?.dismiss()
  213. }
  214. override func viewDidDisappear(_ animated: Bool) {
  215. super.viewDidDisappear(animated)
  216. if let ncplayer = ncplayer, ncplayer.isPlay() {
  217. ncplayer.playerPause()
  218. }
  219. }
  220. override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
  221. super.viewWillTransition(to: size, with: coordinator)
  222. let wasShown = detailView.isShown
  223. if UIDevice.current.orientation.isValidInterfaceOrientation {
  224. if wasShown { closeDetail(animate: false) }
  225. self.tipView?.dismiss()
  226. if metadata.isVideo {
  227. self.imageVideoContainer.isHidden = true
  228. }
  229. coordinator.animate(alongsideTransition: { _ in
  230. // back to the original size
  231. self.scrollView.zoom(to: CGRect(x: 0, y: 0, width: self.scrollView.bounds.width, height: self.scrollView.bounds.height), animated: false)
  232. self.view.layoutIfNeeded()
  233. }, completion: { _ in
  234. if self.metadata.isVideo {
  235. self.imageVideoContainer.isHidden = false
  236. } else if self.metadata.isImage {
  237. self.showTip()
  238. }
  239. if wasShown {
  240. self.openDetail(animate: true)
  241. }
  242. })
  243. }
  244. }
  245. // MARK: - Tip
  246. func showTip() {
  247. if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCViewerMediaDetailView) {
  248. self.tipView?.show(forView: detailView)
  249. }
  250. }
  251. // MARK: - Image
  252. func loadImage() {
  253. guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(metadata.ocId) else { return }
  254. self.metadata = metadata
  255. if metadata.isLivePhoto,
  256. let metadata = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata),
  257. !utilityFileSystem.fileProviderStorageExists(metadata),
  258. let metadata = NCManageDatabase.shared.setMetadatasSessionInWaitDownload(metadatas: [metadata],
  259. session: NextcloudKit.shared.nkCommonInstance.sessionIdentifierDownload,
  260. selector: "") {
  261. NCNetworking.shared.download(metadata: metadata, withNotificationProgressTask: true)
  262. }
  263. if metadata.isImage, (metadata.fileExtension.lowercased() == "gif" || metadata.fileExtension.lowercased() == "svg"), !utilityFileSystem.fileProviderStorageExists(metadata) {
  264. downloadImage()
  265. }
  266. // Get image
  267. let image = getImageMetadata(metadata)
  268. if self.metadata.ocId == metadata.ocId {
  269. self.image = image
  270. self.imageVideoContainer.image = image
  271. }
  272. }
  273. func getImageMetadata(_ metadata: tableMetadata) -> UIImage? {
  274. if let image = utility.getImage(metadata: metadata) {
  275. return image
  276. }
  277. if metadata.isVideo && !metadata.hasPreview {
  278. utility.createImageFrom(fileNameView: metadata.fileNameView, ocId: metadata.ocId, etag: metadata.etag, classFile: metadata.classFile)
  279. }
  280. if utilityFileSystem.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) {
  281. return UIImage(contentsOfFile: utilityFileSystem.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag))
  282. }
  283. if metadata.isAudio {
  284. return UIImage(named: "noPreviewAudio")!.image(color: .gray, size: view.frame.width)
  285. } else if metadata.isImage {
  286. return UIImage(named: "noPreview")!.image(color: .gray, size: view.frame.width)
  287. } else {
  288. return nil
  289. }
  290. }
  291. func downloadImage(withSelector selector: String = "") {
  292. guard let metadata = NCManageDatabase.shared.setMetadatasSessionInWaitDownload(metadatas: [metadata],
  293. session: NextcloudKit.shared.nkCommonInstance.sessionIdentifierDownload,
  294. selector: selector) else { return }
  295. NCNetworking.shared.download(metadata: metadata, withNotificationProgressTask: true) {
  296. } requestHandler: { _ in
  297. self.allowOpeningDetails = false
  298. } completion: { _, _ in
  299. DispatchQueue.main.async {
  300. let image = self.getImageMetadata(self.metadata)
  301. self.image = image
  302. self.imageVideoContainer.image = image
  303. self.allowOpeningDetails = true
  304. }
  305. }
  306. }
  307. // MARK: - Live Photo
  308. func playLivePhoto(filePath: String) {
  309. updateViewConstraints()
  310. statusViewImage.isHidden = true
  311. statusLabel.isHidden = true
  312. player.media = VLCMedia(url: URL(fileURLWithPath: filePath))
  313. player.drawable = imageVideoContainer
  314. player.play()
  315. }
  316. func stopLivePhoto() {
  317. player.stop()
  318. statusViewImage.isHidden = false
  319. statusLabel.isHidden = false
  320. }
  321. // MARK: - Gesture
  322. @objc func didDoubleTapWith(gestureRecognizer: UITapGestureRecognizer) {
  323. guard metadata.isImage, !detailView.isShown else { return }
  324. let pointInView = gestureRecognizer.location(in: self.imageVideoContainer)
  325. var newZoomScale = self.scrollView.maximumZoomScale
  326. if self.scrollView.zoomScale >= newZoomScale || abs(self.scrollView.zoomScale - newZoomScale) <= 0.01 {
  327. newZoomScale = self.scrollView.minimumZoomScale
  328. }
  329. let width = self.scrollView.bounds.width / newZoomScale
  330. let height = self.scrollView.bounds.height / newZoomScale
  331. let originX = pointInView.x - (width / 2.0)
  332. let originY = pointInView.y - (height / 2.0)
  333. let rectToZoomTo = CGRect(x: originX, y: originY, width: width, height: height)
  334. self.scrollView.zoom(to: rectToZoomTo, animated: true)
  335. }
  336. @objc func didPanWith(gestureRecognizer: UIPanGestureRecognizer) {
  337. guard metadata.isImage else { return }
  338. let currentLocation = gestureRecognizer.translation(in: self.view)
  339. switch gestureRecognizer.state {
  340. case .ended:
  341. if detailView.isShown {
  342. self.imageViewTopConstraint.constant = -imageViewConstraint
  343. self.imageViewBottomConstraint.constant = imageViewConstraint
  344. } else {
  345. self.imageViewTopConstraint.constant = 0
  346. self.imageViewBottomConstraint.constant = 0
  347. }
  348. case .changed:
  349. imageViewTopConstraint.constant = (currentLocation.y - imageViewConstraint)
  350. imageViewBottomConstraint.constant = -(currentLocation.y - imageViewConstraint)
  351. // DISMISS VIEW
  352. if detailView.isHidden && (currentLocation.y > 20) {
  353. viewerMediaPage?.navigationController?.popViewController(animated: true)
  354. gestureRecognizer.state = .ended
  355. }
  356. // CLOSE DETAIL
  357. if !detailView.isHidden && (currentLocation.y > 20) {
  358. self.closeDetail()
  359. gestureRecognizer.state = .ended
  360. }
  361. // OPEN DETAIL
  362. if detailView.isHidden && (currentLocation.y < -20) {
  363. self.openDetail()
  364. gestureRecognizer.state = .ended
  365. }
  366. default:
  367. break
  368. }
  369. }
  370. }
  371. extension NCViewerMedia {
  372. @objc func openDetail(_ notification: NSNotification) {
  373. if let userInfo = notification.userInfo as NSDictionary?, let ocId = userInfo["ocId"] as? String, ocId == metadata.ocId {
  374. allowOpeningDetails = true
  375. openDetail()
  376. }
  377. }
  378. @objc func closeDetail(_ notification: NSNotification) {
  379. DispatchQueue.main.async {
  380. self.closeDetail()
  381. }
  382. }
  383. func toggleDetail () {
  384. detailView.isShown ? closeDetail() : openDetail()
  385. }
  386. private func openDetail(animate: Bool = true) {
  387. if !allowOpeningDetails { return }
  388. delegate?.didOpenDetail()
  389. self.dismissTip()
  390. UIView.animate(withDuration: 0.3) {
  391. self.scrollView.setZoomScale(1.0, animated: false)
  392. self.statusLabel.isHidden = true
  393. self.statusViewImage.isHidden = true
  394. }
  395. self.utility.getExif(metadata: self.metadata) { exif in
  396. self.view.layoutIfNeeded()
  397. self.showDetailView(exif: exif)
  398. if let image = self.imageVideoContainer.image {
  399. let ratioW = self.imageVideoContainer.frame.width / image.size.width
  400. let ratioH = self.imageVideoContainer.frame.height / image.size.height
  401. let ratio = min(ratioW, ratioH)
  402. let imageHeight = image.size.height * ratio
  403. var imageContainerHeight = self.imageVideoContainer.frame.height * ratio
  404. let height = max(imageHeight, imageContainerHeight)
  405. self.imageViewConstraint = self.detailView.frame.height - ((self.view.frame.height - height) / 2) + self.view.safeAreaInsets.bottom
  406. if self.imageViewConstraint < 0 { self.imageViewConstraint = 0 }
  407. self.imageViewConstraint = min(self.imageViewConstraint, self.detailView.frame.height + 30)
  408. imageContainerHeight = self.imageViewConstraint.truncatingRemainder(dividingBy: 1000)
  409. }
  410. UIView.animate(withDuration: animate ? 0.3 : 0) {
  411. self.imageViewTopConstraint.constant = -self.imageViewConstraint
  412. self.imageViewBottomConstraint.constant = self.imageViewConstraint
  413. self.detailViewTopConstraint.constant = self.detailView.frame.height
  414. self.view.layoutIfNeeded()
  415. }
  416. self.scrollView.pinchGestureRecognizer?.isEnabled = false
  417. }
  418. }
  419. func closeDetail(animate: Bool = true) {
  420. delegate?.didCloseDetail()
  421. self.detailView.hide()
  422. imageViewConstraint = 0
  423. statusLabel.isHidden = false
  424. statusViewImage.isHidden = false
  425. UIView.animate(withDuration: animate ? 0.3 : 0) {
  426. self.imageViewTopConstraint.constant = 0
  427. self.imageViewBottomConstraint.constant = 0
  428. self.detailViewTopConstraint.constant = 0
  429. self.view.layoutIfNeeded()
  430. }
  431. scrollView.pinchGestureRecognizer?.isEnabled = true
  432. }
  433. private func showDetailView(exif: ExifData) {
  434. self.detailView.show(
  435. metadata: self.metadata,
  436. image: self.image,
  437. textColor: self.viewerMediaPage?.textColor,
  438. exif: exif,
  439. ncplayer: self.ncplayer,
  440. delegate: self)
  441. }
  442. func reloadDetail() {
  443. if self.detailView.isShown {
  444. utility.getExif(metadata: metadata) { exif in
  445. self.showDetailView(exif: exif)
  446. }
  447. }
  448. }
  449. }
  450. extension NCViewerMedia: UIScrollViewDelegate {
  451. func viewForZooming(in scrollView: UIScrollView) -> UIView? {
  452. return imageVideoContainer
  453. }
  454. func scrollViewDidZoom(_ scrollView: UIScrollView) {
  455. if scrollView.zoomScale > 1 {
  456. if let image = imageVideoContainer.image {
  457. let ratioW = imageVideoContainer.frame.width / image.size.width
  458. let ratioH = imageVideoContainer.frame.height / image.size.height
  459. let ratio = ratioW < ratioH ? ratioW : ratioH
  460. let newWidth = image.size.width * ratio
  461. let newHeight = image.size.height * ratio
  462. let conditionLeft = newWidth * scrollView.zoomScale > imageVideoContainer.frame.width
  463. let left = 0.5 * (conditionLeft ? newWidth - imageVideoContainer.frame.width : (scrollView.frame.width - scrollView.contentSize.width))
  464. let conditioTop = newHeight * scrollView.zoomScale > imageVideoContainer.frame.height
  465. let top = 0.5 * (conditioTop ? newHeight - imageVideoContainer.frame.height : (scrollView.frame.height - scrollView.contentSize.height))
  466. scrollView.contentInset = UIEdgeInsets(top: top, left: left, bottom: top, right: left)
  467. }
  468. } else {
  469. scrollView.contentInset = .zero
  470. }
  471. }
  472. }
  473. extension NCViewerMedia: NCViewerMediaDetailViewDelegate {
  474. func downloadFullResolution() {
  475. downloadImage(withSelector: NCGlobal.shared.selectorOpenDetail)
  476. }
  477. }
  478. extension NCViewerMedia: EasyTipViewDelegate {
  479. // TIP
  480. func easyTipViewDidTap(_ tipView: EasyTipView) {
  481. NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCViewerMediaDetailView)
  482. }
  483. func easyTipViewDidDismiss(_ tipView: EasyTipView) { }
  484. func dismissTip() {
  485. NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCViewerMediaDetailView)
  486. self.tipView?.dismiss()
  487. }
  488. }