marinofaggiana 4 years ago
parent
commit
0fda7bfb17

+ 20 - 13
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -230,30 +230,37 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
             
             // PROFILE BUTTON
             
-            if layoutKey == NCGlobal.shared.layoutViewFiles { //&& serverUrl == NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)  {
+            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)
+                let rect = CGRect(x: 0, y: 0, width: 30, height: 30)
+                UIGraphicsBeginImageContextWithOptions(rect.size, false, 3.0)
+                UIBezierPath.init(roundedRect: rect, cornerRadius: rect.size.height).addClip()
+                image.draw(in: rect)
                 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)
+                let button = UIButton(type: .custom)
+                button.setImage(image, for: .normal)
+                
+                if serverUrl == NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
+                 
+                    let account = NCManageDatabase.shared.getAccountActive()
+                    if account?.alias != "" {
+                        button.setTitle("  " + (account?.alias ?? ""), for: .normal)
+                        button.setTitleColor(NCBrandColor.shared.textView, for: .normal)
+                    }
+                }
                 
+                button.semanticContentAttribute = .forceLeftToRight
+                button.sizeToFit()
+                       
+                navigationItem.setLeftBarButton(UIBarButtonItem(customView: button), animated: true)
                 navigationItem.leftItemsSupplementBackButton = true
             }
         }

+ 5 - 2
iOSClient/More/NCMore.swift

@@ -337,10 +337,13 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
             cell.avatar?.layer.masksToBounds = true
             cell.avatar?.layer.cornerRadius = cell.avatar.frame.size.width / 2
             if let account = tabAccount {
-                cell.displayName?.text = account.displayName
+                if account.alias == "" {
+                    cell.displayName?.text = account.displayName
+                } else {
+                    cell.displayName?.text = account.displayName + " (" + account.alias + ")"
+                }
                 cell.displayName.textColor = NCBrandColor.shared.textView
             }
-
             cell.selectedBackgroundView = selectionColor
             cell.backgroundColor = NCBrandColor.shared.backgroundView
             cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator