marinofaggiana 4 years ago
parent
commit
2ea3059f86

+ 2 - 2
iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift

@@ -1417,16 +1417,16 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             if metadata.ownerId.count > 0 && metadata.ownerId != appDelegate.userID {
                 let fileNameUser = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase) + "-" + metadata.ownerId + ".png"
                 if FileManager.default.fileExists(atPath: fileNameUser) {
+                    cell.imageShared.avatar()
                     cell.imageShared.image = UIImage(contentsOfFile: fileNameUser)
                 } else {
                     NCCommunication.shared.downloadAvatar(userID: metadata.ownerId, fileNameLocalPath: fileNameUser, size: NCBrandGlobal.shared.avatarSize) { (account, data, errorCode, errorMessage) in
                         if errorCode == 0 && account == self.appDelegate.account {
+                            cell.imageShared.avatar()
                             cell.imageShared.image = UIImage(contentsOfFile: fileNameUser)
                         }
                     }
                 }
-            } else {
-                cell.imageShared.borderColor = .clear
             }
             
             // Transfer

+ 1 - 1
iOSClient/Main/Colleaction Common/NCListCell.swift

@@ -38,7 +38,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCell
 
     @IBOutlet weak var labelInfo: UILabel!
 
-    @IBOutlet weak var imageShared: NCAvatar!
+    @IBOutlet weak var imageShared: UIImageView!
     @IBOutlet weak var buttonShared: UIButton!
 
     @IBOutlet weak var imageMore: UIImageView!

+ 1 - 6
iOSClient/Main/Colleaction Common/NCListCell.xib

@@ -75,7 +75,7 @@
                             <action selector="touchUpInsideShare:" destination="jxV-Pk-fPt" eventType="touchUpInside" id="UVA-XS-fRf"/>
                         </connections>
                     </button>
-                    <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="avatar" translatesAutoresizingMaskIntoConstraints="NO" id="jc6-Vg-TaS" userLabel="imageShared" customClass="NCAvatar" customModule="Nextcloud" customModuleProvider="target">
+                    <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="avatar" translatesAutoresizingMaskIntoConstraints="NO" id="jc6-Vg-TaS" userLabel="imageShared">
                         <rect key="frame" x="520" y="15" width="30" height="30"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="30" id="Cvy-nZ-zyD"/>
@@ -174,11 +174,6 @@
             <point key="canvasLocation" x="97.599999999999994" y="129.53523238380811"/>
         </collectionViewCell>
     </objects>
-    <designables>
-        <designable name="jc6-Vg-TaS">
-            <size key="intrinsicContentSize" width="25" height="25"/>
-        </designable>
-    </designables>
     <resources>
         <image name="avatar" width="25" height="25"/>
     </resources>

+ 0 - 2
iOSClient/Select/NCSelect.swift

@@ -576,8 +576,6 @@ extension NCSelect: UICollectionViewDataSource {
                         }
                     }
                 }
-            } else {
-                cell.imageShared.borderColor = .clear
             }
             
             cell.imageSelect.isHidden = true

+ 13 - 19
iOSClient/Utility/UIImageView+Extensions.swift

@@ -26,25 +26,19 @@ import Foundation
 
 extension UIImageView {
     
-    func avatar(roundness: CGFloat, borderWidth: CGFloat, borderColor: UIColor, backgroundColor: UIColor, disable: Bool = false) {
-     
-        if disable {
-            
-            layer.mask = nil
-            
-        } else {
+    func avatar(roundness: CGFloat = 2, borderWidth: CGFloat = 1, borderColor: UIColor = .lightGray, backgroundColor: UIColor = .clear) {
         
-            layer.cornerRadius = bounds.width / roundness
-            layer.borderWidth = borderWidth
-            layer.borderColor = borderColor.cgColor
-            layer.backgroundColor = backgroundColor.cgColor
-            clipsToBounds = true
-            
-            let path = UIBezierPath(roundedRect: bounds.insetBy(dx: 0.5, dy: 0.5), cornerRadius: bounds.width / roundness)
-            let mask = CAShapeLayer()
-            
-            mask.path = path.cgPath
-            layer.mask = mask
-        }
+        layer.cornerRadius = bounds.width / roundness
+        layer.borderWidth = borderWidth
+        layer.borderColor = borderColor.cgColor
+        layer.backgroundColor = backgroundColor.cgColor
+
+        clipsToBounds = true
+        
+        let path = UIBezierPath(roundedRect: bounds.insetBy(dx: 0.5, dy: 0.5), cornerRadius: bounds.width / roundness)
+        let mask = CAShapeLayer()
+        
+        mask.path = path.cgPath
+        layer.mask = mask
     }
 }