Przeglądaj źródła

Improved message detail

Signed-off-by: marinofaggiana <marino@marinofaggiana.com>
marinofaggiana 3 lat temu
rodzic
commit
823533a5a1

+ 4 - 0
iOSClient/Main/NCFunctionCenter.swift

@@ -137,6 +137,10 @@ import Queuer
                         
                         saveAsScan(metadata: metadata)
                         
+                    case NCGlobal.shared.selectorOpenDetail:
+                        
+                        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterOpenMediaDetail, userInfo: ["ocId":metadata.ocId])
+                        
                     default:
                         
                         break

+ 4 - 0
iOSClient/NCGlobal.swift

@@ -288,6 +288,7 @@ class NCGlobal: NSObject {
     let selectorSaveAlbumLivePhotoIMG               = "saveAlbumLivePhotoIMG"
     let selectorSaveAlbumLivePhotoMOV               = "saveAlbumLivePhotoMOV"
     let selectorSaveAsScan                          = "saveAsScan"
+    let selectorOpenDetail                          = "openDetail"
 
     // Metadata : Status
     //
@@ -359,6 +360,9 @@ class NCGlobal: NSObject {
     
     let notificationCenterHidePlayerToolBar                     = "hidePlayerToolBar"               // userInfo: ocId
     let notificationCenterShowPlayerToolBar                     = "showPlayerToolBar"               // userInfo: ocId, enableTimerAutoHide
+    
+    let notificationCenterOpenMediaDetail                       = "openMediaDetail"                 // userInfo: ocId
+
 }
 
 //let rootView = UIApplication.shared.keyWindow?.rootViewController?.view

+ 17 - 1
iOSClient/Viewer/NCViewerMedia/NCViewerMediaZoom.swift

@@ -136,6 +136,9 @@ class NCViewerMediaZoom: UIViewController {
             viewerMedia?.textColor = NCBrandColor.shared.label
             viewerMedia?.progressView.isHidden = false
         }
+        
+        NotificationCenter.default.addObserver(self, selector: #selector(openDetail(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterOpenMediaDetail), object: nil)
+
     }
     
     override func viewDidAppear(_ animated: Bool) {
@@ -151,6 +154,12 @@ class NCViewerMediaZoom: UIViewController {
         downloadFile()
     }
     
+    override func viewWillDisappear(_ animated: Bool) {
+        super.viewWillDisappear(animated)
+        
+        NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterOpenMediaDetail), object: nil)
+    }
+    
     override func viewDidDisappear(_ animated: Bool) {
         super.viewDidDisappear(animated)
         
@@ -270,6 +279,13 @@ class NCViewerMediaZoom: UIViewController {
 
 extension NCViewerMediaZoom {
     
+    @objc func openDetail(_ notification: NSNotification) {
+        
+        if let userInfo = notification.userInfo as NSDictionary?, let ocId = userInfo["ocId"] as? String, ocId == metadata.ocId {
+            openDetail()
+        }
+    }
+    
     private func openDetail() {
         
         CCUtility.setExif(metadata) { (latitude, longitude, location, date, lensModel) in
@@ -401,7 +417,7 @@ extension NCViewerMediaZoom: NCViewerMediaDetailViewDelegate  {
     
     func downloadFullResolution() {
         closeDetail()
-        NCNetworking.shared.download(metadata: metadata, selector: "") { (_) in }
+        NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorOpenDetail) { (_) in }
     }
 }