marinofaggiana 4 жил өмнө
parent
commit
34643ccf7a

+ 42 - 29
iOSClient/Account Request/NCAccountRequest.swift

@@ -136,20 +136,25 @@ extension NCAccountRequest: UITableViewDelegate {
     
     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
         
-        let account = accounts[indexPath.row]
-        if account.account != appDelegate.account {
-            NCManageDatabase.shared.setAccountActive(account.account)
-            dismiss(animated: true) {
-                
-                NCOperationQueue.shared.cancelAllQueue()
-                NCNetworking.shared.cancelAllTask()
-                
-                self.appDelegate.settingAccount(account.account, urlBase: account.urlBase, user: account.user, userId: account.userId, password: CCUtility.getPassword(account.account))
-                
-                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
-            }
+        if indexPath.row == accounts.count {
+            
         } else {
-            dismiss(animated: true)
+        
+            let account = accounts[indexPath.row]
+            if account.account != appDelegate.account {
+                NCManageDatabase.shared.setAccountActive(account.account)
+                dismiss(animated: true) {
+                    
+                    NCOperationQueue.shared.cancelAllQueue()
+                    NCNetworking.shared.cancelAllTask()
+                    
+                    self.appDelegate.settingAccount(account.account, urlBase: account.urlBase, user: account.user, userId: account.userId, password: CCUtility.getPassword(account.account))
+                    
+                    NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
+                }
+            } else {
+                dismiss(animated: true)
+            }
         }
     }
 }
@@ -174,26 +179,34 @@ extension NCAccountRequest: UITableViewDataSource {
         let urlLabel = cell.viewWithTag(30) as? UILabel
         let activeImage = cell.viewWithTag(40) as? UIImageView
 
-        let account = accounts[indexPath.row]
+        if indexPath.row == accounts.count {
+           
+            avatarImage?.image = NCUtility.shared.loadImage(named: "plus")
+            urlLabel?.text = NSLocalizedString("_add_account_", comment: "")
+            
+        } else {
+        
+            let account = accounts[indexPath.row]
 
-        avatarImage?.image = NCUtility.shared.loadImage(named: "person.crop.circle")
-    
-        let fileNamePath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(account.user, urlBase: account.urlBase)) + "-" + account.user + ".png"
+            avatarImage?.image = NCUtility.shared.loadImage(named: "person.crop.circle")
         
-        if let userImage = UIImage(contentsOfFile: fileNamePath) {
-            avatarImage?.avatar(roundness: 2, borderWidth: 1, borderColor: NCBrandColor.shared.avatarBorder, backgroundColor: .clear)
-            avatarImage?.image = userImage
-        }
-                
-        userLabel?.text = account.user.uppercased()
-        urlLabel?.text = (URL(string: account.urlBase)?.host ?? "")
+            let fileNamePath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(account.user, urlBase: account.urlBase)) + "-" + account.user + ".png"
+            
+            if let userImage = UIImage(contentsOfFile: fileNamePath) {
+                avatarImage?.avatar(roundness: 2, borderWidth: 1, borderColor: NCBrandColor.shared.avatarBorder, backgroundColor: .clear)
+                avatarImage?.image = userImage
+            }
+                    
+            userLabel?.text = account.user.uppercased()
+            urlLabel?.text = (URL(string: account.urlBase)?.host ?? "")
 
-        if account.active {
-            activeImage?.image = NCUtility.shared.loadImage(named: "checkmark")
-        } else {
-            activeImage?.image = nil
+            if account.active {
+                activeImage?.image = NCUtility.shared.loadImage(named: "checkmark")
+            } else {
+                activeImage?.image = nil
+            }
         }
-
+        
         return cell
     }
 }

+ 2 - 1
iOSClient/AppDelegate.swift

@@ -614,7 +614,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                 vcAccountRequest.enableAddAccount = false
                 
                 let screenHeighMax = UIScreen.main.bounds.height - (UIScreen.main.bounds.height/5)
-                let height = min(CGFloat(accounts.count * Int(vcAccountRequest.heightCell) + 65), screenHeighMax)
+                let numberCell = accounts.count
+                let height = min(CGFloat(numberCell * Int(vcAccountRequest.heightCell) + 65), screenHeighMax)
                 
                 let popup = NCPopupViewController(contentController: vcAccountRequest, popupWidth: 300, popupHeight: height)
                 popup.backgroundAlpha = 0.8

+ 2 - 1
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -662,7 +662,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                 vcAccountRequest.enableAddAccount = true
 
                 let screenHeighMax = UIScreen.main.bounds.height - (UIScreen.main.bounds.height/5)
-                let height = min(CGFloat(accounts.count * Int(vcAccountRequest.heightCell) + 65), screenHeighMax)
+                let numberCell = accounts.count + 1
+                let height = min(CGFloat(numberCell * Int(vcAccountRequest.heightCell) + 65), screenHeighMax)
                 
                 let popup = NCPopupViewController(contentController: vcAccountRequest, popupWidth: 300, popupHeight: height)
                 popup.backgroundAlpha = 0.8