marinofaggiana 4 years ago
parent
commit
95efa19ff4

+ 2 - 2
Nextcloud.xcodeproj/project.pbxproj

@@ -2807,8 +2807,8 @@
 			isa = XCRemoteSwiftPackageReference;
 			repositoryURL = "https://github.com/nextcloud/ios-communication-library/";
 			requirement = {
-				kind = revision;
-				revision = 628f524daac4a98f1cdb2da5adccd1f70cc18c07;
+				kind = exactVersion;
+				version = 0.88.0;
 			};
 		};
 		F7C4D88B2534887E00C142DA /* XCRemoteSwiftPackageReference "Parchment" */ = {

+ 2 - 2
Nextcloud.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

@@ -15,8 +15,8 @@
         "repositoryURL": "https://github.com/nextcloud/ios-communication-library/",
         "state": {
           "branch": null,
-          "revision": "628f524daac4a98f1cdb2da5adccd1f70cc18c07",
-          "version": null
+          "revision": "eaac1d250efa5aa9035c953f45949bce576fb469",
+          "version": "0.88.0"
         }
       },
       {

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

@@ -1421,11 +1421,11 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 if FileManager.default.fileExists(atPath: fileNameSourceAvatar) {
                     cell.imageShared.image = UIImage(contentsOfFile: fileNameSourceAvatar)
                 } else if FileManager.default.fileExists(atPath: fileNameSource) {
-                    cell.imageShared.image = NCUtility.shared.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar, borderColor: .white, borderWidth: 1)
+                    cell.imageShared.image = NCUtility.shared.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar, size: cell.imageShared.frame.width, borderColor: .white, borderWidth: 1)
                 } else {
                     NCCommunication.shared.downloadAvatar(userID: metadata.ownerId, fileNameLocalPath: fileNameSource, size: NCBrandGlobal.shared.avatarSize) { (account, data, errorCode, errorMessage) in
                         if errorCode == 0 && account == self.appDelegate.account {
-                            cell.imageShared.image = NCUtility.shared.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar, borderColor: .white, borderWidth: 1)
+                            cell.imageShared.image = NCUtility.shared.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar, size: cell.imageShared.frame.width, borderColor: .white, borderWidth: 1)
                         }
                     }
                 }

+ 2 - 2
iOSClient/Select/NCSelect.swift

@@ -572,11 +572,11 @@ extension NCSelect: UICollectionViewDataSource {
                 if FileManager.default.fileExists(atPath: fileNameSourceAvatar) {
                     cell.imageShared.image = UIImage(contentsOfFile: fileNameSourceAvatar)
                 } else if FileManager.default.fileExists(atPath: fileNameSource) {
-                    cell.imageShared.image = NCUtility.shared.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar, borderColor: .white, borderWidth: 1)
+                    cell.imageShared.image = NCUtility.shared.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar, size: cell.imageShared.frame.width, borderColor: .white, borderWidth: 1)
                 } else {
                     NCCommunication.shared.downloadAvatar(userID: metadata.ownerId, fileNameLocalPath: fileNameSource, size: NCBrandGlobal.shared.avatarSize) { (account, data, errorCode, errorMessage) in
                         if errorCode == 0 && account == self.appDelegate.account {
-                            cell.imageShared.image = NCUtility.shared.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar, borderColor: .white, borderWidth: 1)
+                            cell.imageShared.image = NCUtility.shared.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar, size: cell.imageShared.frame.width, borderColor: .white, borderWidth: 1)
                         }
                     }
                 }

+ 1 - 28
iOSClient/Utility/NCUtility.swift

@@ -407,10 +407,9 @@ class NCUtility: NSObject {
     }
     
     #if !EXTENSION
-    @objc func createAvatar(fileNameSource: String, fileNameSourceAvatar: String, borderColor: UIColor, borderWidth: CGFloat) -> UIImage? {
+    @objc func createAvatar(fileNameSource: String, fileNameSourceAvatar: String, size: CGFloat, borderColor: UIColor, borderWidth: CGFloat) -> UIImage? {
         
         guard let imageFile = UIImage(contentsOfFile: fileNameSource) else { return nil }
-        let size = NCBrandGlobal.shared.avatarSize
         guard let imageSource = imageFile.resizeImage(size: CGSize(width: size, height: size), isAspectRation: true) else { return nil }
         
         UIGraphicsBeginImageContextWithOptions(CGSize(width: size, height: size), false, UIScreen.main.scale)
@@ -433,32 +432,6 @@ class NCUtility: NSObject {
         } catch { }
         
         return imageAvatar
-        
-        /*
-        guard let imageSource = UIImage(contentsOfFile: fileNameSource) else { return nil }
-        let size = NCBrandGlobal.shared.avatarSize
-        
-        UIGraphicsBeginImageContextWithOptions(CGSize(width: size, height: size), false, UIScreen.main.scale)
-        imageSource.draw(in: CGRect(x: 0, y: 0, width: size, height: size))
-        let image = UIGraphicsGetImageFromCurrentImageContext()
-        UIGraphicsEndImageContext()
-
-        UIGraphicsBeginImageContextWithOptions(CGSize(width: size, height: size), false, UIScreen.main.scale)
-        let avatarImageView = NCAvatar.init(image: image, borderColor: borderColor, borderWidth: borderWidth)
-        guard let context = UIGraphicsGetCurrentContext() else { return nil }
-        avatarImageView.layer.render(in: context)
-        guard let imageAvatar = UIGraphicsGetImageFromCurrentImageContext() else { return nil }
-        UIGraphicsEndImageContext()
-        
-        guard let data = imageAvatar.pngData() else {
-            return nil
-        }
-        do {
-            try data.write(to: NSURL(fileURLWithPath: fileNameSourceAvatar) as URL, options: .atomic)
-        } catch { }
-        
-        return imageAvatar
-        */
     }
     #endif