marinofaggiana 3 年之前
父节点
当前提交
a92a714886

+ 2 - 0
iOSClient/NCGlobal.swift

@@ -323,6 +323,8 @@ class NCGlobal: NSObject {
     let notificationCenterShareChangePermissions                = "shareChangePermissions"          // userInfo: idShare, permissions, hideDownload
     
     let notificationCenterDownloadedThumbnail                   = "DownloadedThumbnail"             // userInfo: ocId
+    
+    let notificationCenterHidePlayerToolBar                     = "hidePlayerToolBar"               // userInfo:
 }
 
 //let rootView = UIApplication.shared.keyWindow?.rootViewController?.view

+ 3 - 1
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift

@@ -126,8 +126,10 @@ class NCPlayerToolBar: UIView {
     
     @objc public func hideToolBar() {
         
-        updateToolBar()
+        if self.isHidden { return }
       
+        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterHidePlayerToolBar)
+        
         UIView.animate(withDuration: 0.3, animations: {
             self.alpha = 0
         }, completion: { (value: Bool) in

+ 54 - 36
iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift

@@ -107,6 +107,8 @@ class NCViewerMedia: UIViewController {
         NotificationCenter.default.addObserver(self, selector: #selector(triggerProgressTask(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterProgressTask), object:nil)
         
         NotificationCenter.default.addObserver(self, selector: #selector(downloadedThumbnail(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterDownloadedThumbnail), object: nil)
+        
+        NotificationCenter.default.addObserver(self, selector: #selector(hidePlayerToolBar(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterHidePlayerToolBar), object: nil)
     }
     
     override func viewWillDisappear(_ animated: Bool) {
@@ -145,6 +147,50 @@ class NCViewerMedia: UIViewController {
         print("deinit NCViewerMedia")        
     }
     
+    func changeScreenMode(mode: ScreenMode) {
+        
+        if mode == .normal {
+            
+            navigationController?.setNavigationBarHidden(false, animated: false)
+            progressView.isHidden = false
+
+            // show playerToolBar
+            currentViewController.playerToolBar.showToolBar(metadata: currentViewController.metadata, detailView: currentViewController.detailView)
+            
+            if (!currentViewController.metadata.livePhoto && currentViewController.metadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue) {
+                
+                NCUtility.shared.colorNavigationController(navigationController, backgroundColor: .black, titleColor: .white, tintColor: nil)
+                view.backgroundColor = .black
+                textColor = .white
+                
+            } else {
+                
+                NCUtility.shared.colorNavigationController(navigationController, backgroundColor: NCBrandColor.shared.systemBackground, titleColor: NCBrandColor.shared.label, tintColor: nil)
+                view.backgroundColor = NCBrandColor.shared.systemBackground
+                textColor = NCBrandColor.shared.label
+            }
+            
+            currentMode = .normal
+            
+        } else {
+            
+            navigationController?.setNavigationBarHidden(true, animated: false)
+            progressView.isHidden = true
+            
+            currentViewController.playerToolBar.hideToolBar()
+
+            NCUtility.shared.colorNavigationController(navigationController, backgroundColor: .black, titleColor: .white, tintColor: nil)
+            
+            view.backgroundColor = .black
+            textColor = .white
+                        
+            currentMode = .full
+        }
+        
+        // Detail Text Color
+        currentViewController.detailView.textColor(textColor)
+    }
+    
     //MARK: - NotificationCenter
 
     @objc func downloadedFile(_ notification: NSNotification) {
@@ -261,6 +307,10 @@ class NCViewerMedia: UIViewController {
     @objc func changeTheming() {
     }
     
+    @objc func hidePlayerToolBar(_ notification: NSNotification) {
+        changeScreenMode(mode: .full)
+    }
+    
     //MARK: - Image
     
     func getImageMetadata(_ metadata: tableMetadata) -> UIImage? {
@@ -454,47 +504,15 @@ extension NCViewerMedia: UIGestureRecognizerDelegate {
     }
     
     @objc func didSingleTapWith(gestureRecognizer: UITapGestureRecognizer) {
-        
-        if currentMode == .full {
-            
-            navigationController?.setNavigationBarHidden(false, animated: false)
-            progressView.isHidden = false
-
-            // show playerToolBar
-            currentViewController.playerToolBar.showToolBar(metadata: currentViewController.metadata, detailView: currentViewController.detailView)
-            
-            if (!currentViewController.metadata.livePhoto && currentViewController.metadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue) {
-                
-                NCUtility.shared.colorNavigationController(navigationController, backgroundColor: .black, titleColor: .white, tintColor: nil)
-                view.backgroundColor = .black
-                textColor = .white
-                
-            } else {
                 
-                NCUtility.shared.colorNavigationController(navigationController, backgroundColor: NCBrandColor.shared.systemBackground, titleColor: NCBrandColor.shared.label, tintColor: nil)
-                view.backgroundColor = NCBrandColor.shared.systemBackground
-                textColor = NCBrandColor.shared.label
-            }
-            
-            currentMode = .normal
+        if currentMode == .full {
             
+            changeScreenMode(mode: .normal)
+                        
         } else {
             
-            navigationController?.setNavigationBarHidden(true, animated: false)
-            progressView.isHidden = true
-            
-            currentViewController.playerToolBar.hideToolBar()
-
-            NCUtility.shared.colorNavigationController(navigationController, backgroundColor: .black, titleColor: .white, tintColor: nil)
-            
-            view.backgroundColor = .black
-            textColor = .white
-                        
-            currentMode = .full
+            changeScreenMode(mode: .full)
         }
-        
-        // Detail Text Color
-        currentViewController.detailView.textColor(textColor)
     }
     
     //