marinofaggiana 4 жил өмнө
parent
commit
8382cbbc69

+ 9 - 3
iOSClient/Account Request/NCAccountRequest.swift

@@ -32,6 +32,7 @@ class NCAccountRequest: UIViewController {
     
     public var accounts: [tableAccount] = []
     public let heightCell: CGFloat = 80
+    public var enableTimerProgress: Bool = true
     
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
     private var timer: Timer?
@@ -84,9 +85,14 @@ class NCAccountRequest: UIViewController {
     
     @objc func startTimer() {
         
-        time = 0
-        timer?.invalidate()
-        timer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(updateProgress), userInfo: nil, repeats: true)
+        if enableTimerProgress {
+            time = 0
+            timer?.invalidate()
+            timer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(updateProgress), userInfo: nil, repeats: true)
+            progressView.isHidden = false
+        } else {
+            progressView.isHidden = true
+        }
     }
     
     @objc func updateProgress() {

+ 53 - 0
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -217,13 +217,43 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     func setNavigationItem() {
         
         if isEditMode {
+            
             navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage.init(named: "navigationMore"), style: .plain, target: self, action:#selector(tapSelectMenu(sender:)))
             navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: .plain, target: self, action: #selector(tapSelect(sender:)))
             navigationItem.title = NSLocalizedString("_selected_", comment: "") + " : \(selectOcId.count)" + " / \(dataSource.metadatas.count)"
+            
         } else {
+            
             navigationItem.rightBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_select_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(tapSelect(sender:)))
             navigationItem.leftBarButtonItem = nil
             navigationItem.title = titleCurrentFolder
+            
+            // PROFILE BUTTON
+            
+            if layoutKey == NCGlobal.shared.layoutViewFiles {
+            
+                let profileButton = UIButton.init(type: .custom)
+                profileButton.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
+                profileButton.addTarget(self, action: #selector(profileButtonTapped(sender:)), for: .touchUpInside)
+
+                var image = NCUtility.shared.loadImage(named: "person.crop.circle")
+                let fileNamePath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + appDelegate.user + ".png"
+                if let userImage = UIImage(contentsOfFile: fileNamePath) {
+                    image = userImage
+                }
+                
+                UIGraphicsBeginImageContextWithOptions(profileButton.bounds.size, false, 3.0)
+                UIBezierPath.init(roundedRect: profileButton.bounds, cornerRadius: profileButton.bounds.size.height).addClip()
+                image.draw(in: profileButton.bounds)
+                image = UIGraphicsGetImageFromCurrentImageContext() ?? NCUtility.shared.loadImage(named: "person.crop.circle")
+                UIGraphicsEndImageContext()
+
+                profileButton.setImage(image, for: .normal)
+                profileButton.widthAnchor.constraint(equalToConstant: 30).isActive = true
+                profileButton.heightAnchor.constraint(equalToConstant: 30).isActive = true
+
+                navigationItem.setLeftBarButton(UIBarButtonItem(customView: profileButton), animated: true)
+            }
         }
     }
     
@@ -255,6 +285,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         appDelegate.listOfflineVC.removeAll()
         selectOcId.removeAll()
         
+        setNavigationItem()
+    
         reloadDataSource()
     }
     
@@ -618,6 +650,27 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         self.collectionView.reloadData()
     }
     
+    @objc func profileButtonTapped(sender: Any) {
+        
+        let accounts = NCManageDatabase.shared.getAllAccount()
+        if accounts.count > 1 {
+            
+            if let vcAccountRequest = UIStoryboard(name: "NCAccountRequest", bundle: nil).instantiateInitialViewController() as? NCAccountRequest {
+               
+                vcAccountRequest.accounts = accounts
+                vcAccountRequest.enableTimerProgress = false
+                
+                let screenHeighMax = UIScreen.main.bounds.height - (UIScreen.main.bounds.height/5)
+                let height = min(CGFloat(accounts.count * Int(vcAccountRequest.heightCell) + 65), screenHeighMax)
+                
+                let popup = NCPopupViewController(contentController: vcAccountRequest, popupWidth: 300, popupHeight: height)
+                popup.backgroundAlpha = 0.8
+                
+                UIApplication.shared.keyWindow?.rootViewController?.present(popup, animated: true)
+            }
+        }
+    }
+    
     func tapSwitchHeader(sender: Any) {
         
         if collectionView.collectionViewLayout == gridLayout {