Marino Faggiana 6 years ago
parent
commit
569dbe58ab
3 changed files with 15 additions and 11 deletions
  1. 10 7
      iOSClient/Offline/NCOffline.swift
  2. 1 1
      iOSClient/Utility/CCGraphics.h
  3. 4 3
      iOSClient/Utility/CCGraphics.m

+ 10 - 7
iOSClient/Offline/NCOffline.swift

@@ -545,6 +545,7 @@ class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewD
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         
         var image: UIImage?
+        var imagePreview = false
 
         guard let metadata = NCMainCommon.sharedInstance.getMetadataFromSectionDataSourceIndexPath(indexPath, sectionDataSource: sectionDatasource) else {
             return collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
@@ -558,6 +559,7 @@ class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewD
         
         if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconFileID(metadata.fileID, fileNameView: metadata.fileName)) {
             image = UIImage.init(contentsOfFile: CCUtility.getDirectoryProviderStorageIconFileID(metadata.fileID, fileNameView: metadata.fileName))
+            imagePreview = true
         } else {
             if metadata.thumbnailExists && !CCUtility.fileProviderStorageIconExists(metadata.fileID, fileNameView: metadata.fileName) {
                 downloadThumbnail(with: metadata, indexPath: indexPath)
@@ -619,15 +621,16 @@ class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewD
             cell.labelTitle.text = metadata.fileNameView
             
             if metadata.directory {
-//                cell.imageItem.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), multiplier: 3, color: NCBrandColor.sharedInstance.brandElement)
-                
-                let image = UIImage.init(named: "folder")!
-                
-                cell.imageItem.image = CCGraphics.changeThemingColorImage(image, width: image.size.width, height: image.size.height, color: NCBrandColor.sharedInstance.brandElement)
-                
-                
+                image = UIImage.init(named: "folder")
+                cell.imageItem.image = CCGraphics.changeThemingColorImage(image, width: image!.size.width*6, height: image!.size.height*6, scale: 3.0, color: NCBrandColor.sharedInstance.brandElement)
+                cell.imageItem.contentMode = .center
             } else {
                 cell.imageItem.image = image
+                if imagePreview == false {
+                    cell.imageItem.image = CCGraphics.scale(image, to: CGSize(width: image!.size.width*10, height: image!.size.height*10))
+//                    cell.imageItem.image = CCGraphics.changeThemingColorImage(image, width: image!.size.width*6, height: image!.size.height*6, scale: 3.0, color: nil)
+                    cell.imageItem.contentMode = .center
+                }
             }
             
             if isEditMode {

+ 1 - 1
iOSClient/Utility/CCGraphics.h

@@ -39,7 +39,7 @@
 
 + (UIColor *)colorFromHexString:(NSString *)hexString;
 + (UIImage *)changeThemingColorImage:(UIImage *)image multiplier:(NSInteger)multiplier color:(UIColor *)color;
-+ (UIImage *)changeThemingColorImage:(UIImage *)image width:(CGFloat)width height:(CGFloat)height color:(UIColor *)color;
++ (UIImage *)changeThemingColorImage:(UIImage *)image width:(CGFloat)width height:(CGFloat)height scale:(CGFloat)scale color:(UIColor *)color;
 
 + (UIImage*)drawText:(NSString*)text inImage:(UIImage*)image colorText:(UIColor *)colorText sizeOfFont:(CGFloat)sizeOfFont;
 

+ 4 - 3
iOSClient/Utility/CCGraphics.m

@@ -216,18 +216,19 @@
     return [UIImage imageWithCGImage:img.CGImage scale:2.0 orientation: UIImageOrientationDownMirrored];
 }
 
-+ (UIImage *)changeThemingColorImage:(UIImage *)image width:(CGFloat)width height:(CGFloat)height color:(UIColor *)color
++ (UIImage *)changeThemingColorImage:(UIImage *)image width:(CGFloat)width height:(CGFloat)height scale:(CGFloat)scale color:(UIColor *)color
 {
     CGRect rect = CGRectMake(0, 0, width, height);
     UIGraphicsBeginImageContext(rect.size);
     CGContextRef context = UIGraphicsGetCurrentContext();
     CGContextClipToMask(context, rect, image.CGImage);
-    CGContextSetFillColorWithColor(context, [color CGColor]);
+    if (color)
+        CGContextSetFillColorWithColor(context, [color CGColor]);
     CGContextFillRect(context, rect);
     UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
     UIGraphicsEndImageContext();
     
-    return [UIImage imageWithCGImage:img.CGImage scale:1.0 orientation: UIImageOrientationDownMirrored];
+    return [UIImage imageWithCGImage:img.CGImage scale:scale orientation: UIImageOrientationDownMirrored];
 }
 
 + (UIImage*)drawText:(NSString*)text inImage:(UIImage*)image colorText:(UIColor *)colorText sizeOfFont:(CGFloat)sizeOfFont