Browse Source

clear code

marinofaggiana 4 years ago
parent
commit
171bea8580

+ 13 - 0
iOSClient/Extensions/UIImageView+Extensions.swift

@@ -41,4 +41,17 @@ extension UIImageView {
         mask.path = path.cgPath
         layer.mask = mask
     }
+    
+    func clearLayerMask() {
+        
+        layer.cornerRadius = 0
+        layer.borderWidth = 0
+        layer.borderColor = UIColor.black.cgColor
+        layer.backgroundColor = nil
+        
+        clipsToBounds = false
+        
+        mask = nil
+        layer.mask = nil
+    }
 }

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

@@ -1427,6 +1427,8 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                         }
                     }
                 }
+            } else {
+                cell.imageShared.clearLayerMask()
             }
             
             // Transfer

+ 3 - 3
iOSClient/Share/NCShare.swift

@@ -406,7 +406,7 @@ 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.disableAvatar = false
+                        cell.imageItem.avatar()
                         cell.imageItem.image = image
                     }
                 } else {
@@ -414,7 +414,7 @@ extension NCShare: UITableViewDataSource {
                         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.disableAvatar = false
+                                    cell.imageItem.avatar()
                                     cell.imageItem.image = image
                                 }
                             }
@@ -484,7 +484,7 @@ protocol NCShareLinkCellDelegate {
 
 class NCShareUserCell: UITableViewCell {
     
-    @IBOutlet weak var imageItem: NCAvatar!
+    @IBOutlet weak var imageItem: UIImageView!
     @IBOutlet weak var labelTitle: UILabel!
     @IBOutlet weak var labelCanEdit: UILabel!
     @IBOutlet weak var switchCanEdit: UISwitch!

+ 1 - 6
iOSClient/Share/NCShareUserCell.xib

@@ -16,7 +16,7 @@
                 <rect key="frame" x="0.0" y="0.0" width="600" height="90"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
-                    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" image="avatar" translatesAutoresizingMaskIntoConstraints="NO" id="qDs-UG-Mn7" userLabel="ImageItem" customClass="NCAvatar" customModule="Nextcloud" customModuleProvider="target">
+                    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" image="avatar" translatesAutoresizingMaskIntoConstraints="NO" id="qDs-UG-Mn7" userLabel="ImageItem">
                         <rect key="frame" x="5" y="25" width="40" height="40"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="40" id="8et-YH-T1D"/>
@@ -118,11 +118,6 @@
             <point key="canvasLocation" x="97.599999999999994" y="276.1619190404798"/>
         </tableViewCell>
     </objects>
-    <designables>
-        <designable name="qDs-UG-Mn7">
-            <size key="intrinsicContentSize" width="25" height="25"/>
-        </designable>
-    </designables>
     <resources>
         <image name="avatar" width="25" height="25"/>
         <image name="shareMenu" width="329" height="329"/>

+ 1 - 9
iOSClient/Utility/NCAvatar.swift

@@ -50,12 +50,6 @@ import Foundation
         }
     }
     
-    @IBInspectable var disableAvatar: Bool = false {
-        didSet{
-            layoutSubviews()
-        }
-    }
-    
     required init?(coder aDecoder: NSCoder) {
         super.init(coder: aDecoder)
     }
@@ -73,9 +67,7 @@ import Foundation
 
     override func layoutSubviews() {
         super.layoutSubviews()
-        
-        if disableAvatar { return }
-        
+                
         layer.cornerRadius = bounds.width / roundness
         layer.borderWidth = borderWidth
         layer.borderColor = borderColor.cgColor