marinofaggiana пре 6 година
родитељ
комит
428a94f377

+ 5 - 3
iOSClient/Main/CCMain.m

@@ -937,10 +937,12 @@
         
     if (cell) {
         previewingContext.sourceRect = cell.frame;
-        CCPeekPop *vc = [[UIStoryboard storyboardWithName:@"CCPeekPop" bundle:nil] instantiateViewControllerWithIdentifier:@"PeekPopImagePreview"];
+        CCPeekPop *viewController = [[UIStoryboard storyboardWithName:@"CCPeekPop" bundle:nil] instantiateViewControllerWithIdentifier:@"PeekPopImagePreview"];
             
-        vc.metadata = metadata;
-        return vc;
+        viewController.metadata = metadata;
+        viewController.imageFile = cell.file.image;
+        
+        return viewController;
     }
     
     return nil;

+ 3 - 20
iOSClient/Main/NCMainCommon.swift

@@ -274,7 +274,7 @@ class NCMainCommon: NSObject, PhotoEditorDelegate, NCAudioRecorderViewController
                     image = UIImage.init(named: "folder")
                 }
                 
-                cell.imageItem.image = CCGraphics.changeThemingColorImage(image, width: image!.size.width, height: image!.size.height, color: NCBrandColor.sharedInstance.brandElement)
+                cell.imageItem.image = CCGraphics.changeThemingColorImage(image, width: image!.size.width*2, height: image!.size.height*2, color: NCBrandColor.sharedInstance.brandElement)
                 cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date)
                 
                 let lockServerUrl = CCUtility.stringAppendServerUrl(serverUrl, addFileName: metadata.fileName)!
@@ -380,8 +380,7 @@ class NCMainCommon: NSObject, PhotoEditorDelegate, NCAudioRecorderViewController
                     image = UIImage.init(named: "folder")
                 }
                 
-                cell.imageItem.image = CCGraphics.changeThemingColorImage(image, width: image!.size.width, height: image!.size.height, color: NCBrandColor.sharedInstance.brandElement)
-                cell.imageItem.contentMode = .center
+                cell.imageItem.image = CCGraphics.changeThemingColorImage(image, width: image!.size.width*2, height: image!.size.height*2, color: NCBrandColor.sharedInstance.brandElement)
                 
                 let lockServerUrl = CCUtility.stringAppendServerUrl(serverUrl, addFileName: metadata.fileName)!
                 let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.activeAccount, lockServerUrl))
@@ -401,9 +400,7 @@ class NCMainCommon: NSObject, PhotoEditorDelegate, NCAudioRecorderViewController
                 cell.imageItem.image = image
                 if isImagePreviewLoaded == false {
                     let width = cell.imageItem.image!.size.width * 2
-                    //let scale = UIScreen.main.scale
                     cell.imageItem.image = NCUtility.sharedInstance.resizeImage(image: image!, newWidth: width)
-                    cell.imageItem.contentMode = .center
                 }
                 
                 // image Local
@@ -455,17 +452,8 @@ class NCMainCommon: NSObject, PhotoEditorDelegate, NCAudioRecorderViewController
             cell.imageStatus.image = nil
             cell.imageLocal.image = nil
             cell.imageFavorite.image = nil
-            
             cell.imageItem.image = image
           
-            if isImagePreviewLoaded {
-                // Preview
-                cell.imageItem.contentMode = .scaleAspectFill
-            } else {
-                // Default xcassets
-                cell.imageItem.contentMode = .scaleAspectFit
-            }
-            
             // image Local
             let tableLocalFile = NCManageDatabase.sharedInstance.getTableLocalFile(predicate: NSPredicate(format: "fileID == %@", metadata.fileID))
             if tableLocalFile != nil && CCUtility.fileProviderStorageExists(metadata.fileID, fileNameView: metadata.fileNameView) {
@@ -567,7 +555,7 @@ class NCMainCommon: NSObject, PhotoEditorDelegate, NCAudioRecorderViewController
                     image = UIImage.init(named: "folder")
                 }
                 
-                cell.file.image = CCGraphics.changeThemingColorImage(image, width: image!.size.width, height: image!.size.height, color: NCBrandColor.sharedInstance.brandElement)
+                cell.file.image = CCGraphics.changeThemingColorImage(image, width: image!.size.width*2, height: image!.size.height*2, color: NCBrandColor.sharedInstance.brandElement)
                 
                 let lockServerUrl = CCUtility.stringAppendServerUrl(serverUrl, addFileName: metadata.fileName)!
                 let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.activeAccount, lockServerUrl))
@@ -1312,13 +1300,10 @@ class NCNetworkingMain: NSObject, CCNetworkingDelegate {
                         if let cell = (view as! UICollectionView).cellForItem(at: indexPath) {
                             if cell is NCListCell {
                                 (cell as! NCListCell).imageItem.image = image
-                                (cell as! NCListCell).imageItem.contentMode = .scaleAspectFill
                             } else if cell is NCGridCell {
                                 (cell as! NCGridCell).imageItem.image = image
-                                (cell as! NCGridCell).imageItem.contentMode = .scaleAspectFill
                             } else if cell is NCGridMediaCell {
                                 (cell as! NCGridMediaCell).imageItem.image = image
-                                (cell as! NCGridMediaCell).imageItem.contentMode = .scaleAspectFill
                             }
                         }
                     }
@@ -1327,10 +1312,8 @@ class NCNetworkingMain: NSObject, CCNetworkingDelegate {
                         if let cell = (view as! UITableView).cellForRow(at: indexPath) {
                             if cell is CCCellMainTransfer {
                                 (cell as! CCCellMainTransfer).file.image = image
-                                (cell as! CCCellMainTransfer).file.contentMode = .scaleAspectFill
                             } else if cell is CCCellMain {
                                 (cell as! CCCellMain).file.image = image
-                                (cell as! CCCellMain).file.contentMode = .scaleAspectFill
                             }
                         }
                     }

+ 3 - 1
iOSClient/Media/NCMedia.swift

@@ -364,11 +364,13 @@ extension NCMedia: UIViewControllerPreviewingDelegate {
         guard let point = collectionView?.convert(location, from: collectionView?.superview) else { return nil }
         guard let indexPath = collectionView?.indexPathForItem(at: point) else { return nil }
         guard let metadata = NCMainCommon.sharedInstance.getMetadataFromSectionDataSourceIndexPath(indexPath, sectionDataSource: sectionDatasource) else { return nil }
-        guard let cell = collectionView?.cellForItem(at: indexPath) else { return nil }
+        guard let cell = collectionView?.cellForItem(at: indexPath) as? NCGridMediaCell  else { return nil }
         guard let viewController = UIStoryboard(name: "CCPeekPop", bundle: nil).instantiateViewController(withIdentifier: "PeekPopImagePreview") as? CCPeekPop else { return nil }
         
         previewingContext.sourceRect = cell.frame
         viewController.metadata = metadata
+        viewController.imageFile = cell.imageItem.image
+        
         viewController.hideAction = true
         
         return viewController

+ 1 - 0
iOSClient/PeekPop/CCPeekPop.h

@@ -29,6 +29,7 @@
 @interface CCPeekPop : UIViewController
 
 @property (nonatomic, strong) tableMetadata *metadata;
+@property (nonatomic, strong) UIImage *imageFile;
 @property BOOL hideAction;
 
 @property (nonatomic, weak) IBOutlet UILabel *fileName;

+ 34 - 2
iOSClient/PeekPop/CCPeekPop.m

@@ -52,11 +52,37 @@
     self.fileName.text = self.metadata.fileNameView;
     highLabelFileName = self.fileName.bounds.size.height + 5;
     
+    /*
+    if (self.imageFile != nil) {
+        
+        image = [UIImage imageWithContentsOfFile:[CCUtility getDirectoryProviderStorageFileID:self.metadata.fileID fileNameView:self.metadata.fileNameView]];
+        if (image == nil) {
+            image = self.imageFile;
+        }
+        
+    } else {
+        
+        if (self.metadata.iconName.length > 0) {
+            image = [UIImage imageNamed:self.metadata.iconName];
+        } else {
+            image = [UIImage imageNamed:@"file"];
+        }
+    }
+    
+    self.imagePreview.image = image;
+    self.imagePreview.contentMode = UIViewContentModeScaleToFill;
+    self.preferredContentSize = CGSizeMake(image.size.width, image.size.height + highLabelFileName);
+    */
+    
     if (self.metadata.hasPreview) {
         
         if ([CCUtility fileProviderStorageIconExists:self.metadata.fileID fileNameView:self.metadata.fileNameView]) {
             
-            image = [UIImage imageWithContentsOfFile:[CCUtility getDirectoryProviderStorageIconFileID:self.metadata.fileID fileNameView:self.metadata.fileNameView]];
+            image = [UIImage imageWithContentsOfFile:[CCUtility getDirectoryProviderStorageFileID:self.metadata.fileID fileNameView:self.metadata.fileNameView]];
+            if (image == nil) {
+                image = [UIImage imageWithContentsOfFile:[CCUtility getDirectoryProviderStorageIconFileID:self.metadata.fileID fileNameView:self.metadata.fileNameView]];
+            }
+            
             image = [CCGraphics scaleImage:image toSize:CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height) isAspectRation:true];
             
             self.imagePreview.image = image;
@@ -78,7 +104,11 @@
         
         if (self.metadata.directory) {
             
-            image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"folder"] multiplier:2 color:[NCBrandColor sharedInstance].brandElement];
+            if (self.imageFile != nil) {
+                image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"folder"] multiplier:2 color:[NCBrandColor sharedInstance].brandElement];
+            } else {
+                image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"folder"] multiplier:2 color:[NCBrandColor sharedInstance].brandElement];
+            }
             
         } else {
             
@@ -92,6 +122,8 @@
         self.imagePreview.image = image;
         self.imagePreview.contentMode = UIViewContentModeCenter;
         self.preferredContentSize = CGSizeMake(image.size.width, image.size.height + highLabelFileName);
+
+        self.preferredContentSize = CGSizeMake(image.size.width, image.size.height + highLabelFileName);
     }
 }