marinofaggiana 4 жил өмнө
parent
commit
a5ca720b5f

+ 6 - 2
iOSClient/Share/NCShare.swift

@@ -405,12 +405,16 @@ extension NCShare: UITableViewDataSource {
                 
                 let fileNameLocalPath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase) + "-" + tableShare.shareWith + ".png"
                 if FileManager.default.fileExists(atPath: fileNameLocalPath) {
-                    if let image = UIImage(contentsOfFile: fileNameLocalPath) { cell.imageItem.image = image }
+                    if let image = UIImage(contentsOfFile: fileNameLocalPath) {
+                        cell.imageItem.enableAvatar = true
+                        cell.imageItem.image = image
+                    }
                 } else {
                     DispatchQueue.global().async {
                         NCCommunication.shared.downloadAvatar(userID: tableShare.shareWith, fileNameLocalPath: fileNameLocalPath, size: NCBrandGlobal.shared.avatarSize) { (account, data, errorCode, errorMessage) in
                             if errorCode == 0 && account == self.appDelegate.account && UIImage(data: data!) != nil {
                                 if let image = UIImage(contentsOfFile: fileNameLocalPath) {
+                                    cell.imageItem.enableAvatar = true
                                     cell.imageItem.image = image
                                 }
                             }
@@ -480,7 +484,7 @@ protocol NCShareLinkCellDelegate {
 
 class NCShareUserCell: UITableViewCell {
     
-    @IBOutlet weak var imageItem: UIImageView!
+    @IBOutlet weak var imageItem: NCAvatar!
     @IBOutlet weak var labelTitle: UILabel!
     @IBOutlet weak var labelCanEdit: UILabel!
     @IBOutlet weak var switchCanEdit: UISwitch!

+ 3 - 2
iOSClient/Share/NCShareUserCell.xib

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17505"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -23,6 +23,7 @@
                             <constraint firstAttribute="width" constant="40" id="GNY-Va-SIJ"/>
                         </constraints>
                         <userDefinedRuntimeAttributes>
+                            <userDefinedRuntimeAttribute type="boolean" keyPath="enableAvatar" value="NO"/>
                             <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
                                 <integer key="value" value="1"/>
                             </userDefinedRuntimeAttribute>

+ 8 - 0
iOSClient/Utility/NCAvatar.swift

@@ -50,6 +50,12 @@ import Foundation
         }
     }
     
+    @IBInspectable var enableAvatar: Bool = true {
+        didSet{
+            layoutSubviews()
+        }
+    }
+    
     required init?(coder aDecoder: NSCoder) {
         super.init(coder: aDecoder)
     }
@@ -68,6 +74,8 @@ import Foundation
     override func layoutSubviews() {
         super.layoutSubviews()
         
+        if !enableAvatar { return }
+        
         layer.cornerRadius = bounds.width / roundness
         layer.borderWidth = borderWidth
         layer.borderColor = borderColor.cgColor