NCViewerMedia.swift 23 KB

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