marinofaggiana 6 years ago
parent
commit
5ceb2eba82
2 changed files with 24 additions and 16 deletions
  1. 19 11
      iOSClient/PeekPop/CCPeekPop.m
  2. 5 5
      iOSClient/PeekPop/CCPeekPop.storyboard

+ 19 - 11
iOSClient/PeekPop/CCPeekPop.m

@@ -46,17 +46,21 @@
     [super viewDidLoad];
     
     appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-    
+    UIImage *image;
+
     self.fileName.text = self.metadata.fileNameView;
     
     if (self.metadata.hasPreview) {
         
         if ([CCUtility fileProviderStorageIconExists:self.metadata.fileID fileNameView:self.metadata.fileNameView]) {
             
-            self.imagePreview.image = [UIImage imageWithContentsOfFile:[CCUtility getDirectoryProviderStorageIconFileID:self.metadata.fileID fileNameView:self.metadata.fileNameView]];
+            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;
         
             self.imagePreview.contentMode = UIViewContentModeScaleToFill;
-            self.preferredContentSize = CGSizeMake(self.imagePreview.image.size.width, self.imagePreview.image.size.height);
+            self.preferredContentSize = CGSizeMake(image.size.width, image.size.height);
             
         } else {
             
@@ -72,19 +76,20 @@
         
         if (self.metadata.directory) {
             
-            self.imagePreview.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"folder"] multiplier:2 color:[NCBrandColor sharedInstance].brandElement];
+            image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"folder"] multiplier:2 color:[NCBrandColor sharedInstance].brandElement];
             
         } else {
             
             if (self.metadata.iconName.length > 0) {
-                self.imagePreview.image = [UIImage imageNamed:self.metadata.iconName];
+                image = [UIImage imageNamed:self.metadata.iconName];
             } else {
-                self.imagePreview.image = [UIImage imageNamed:@"file"];
+                image = [UIImage imageNamed:@"file"];
             }
         }
         
-        self.imagePreview.contentMode = UIViewContentModeScaleToFill;
-        self.preferredContentSize = CGSizeMake(self.imagePreview.image.size.width, self.imagePreview.image.size.height);
+        self.imagePreview.image = image;
+        self.imagePreview.contentMode = UIViewContentModeCenter;
+        self.preferredContentSize = CGSizeMake(image.size.width, image.size.height + 100);
     }
 }
 
@@ -125,6 +130,9 @@
             
             self.imagePreview.image = image;
             
+            self.imagePreview.contentMode = UIViewContentModeScaleToFill;
+            self.preferredContentSize = CGSizeMake(image.size.width, image.size.height);
+            
         } else {
             
             if (self.metadata.iconName.length > 0) {
@@ -132,10 +140,10 @@
             } else {
                 self.imagePreview.image = [UIImage imageNamed:@"file"];
             }
+            
+            self.imagePreview.contentMode = UIViewContentModeCenter;
+            self.preferredContentSize = CGSizeMake(self.imagePreview.image.size.width, self.imagePreview.image.size.height + 100);
         }
-        
-        self.imagePreview.contentMode = UIViewContentModeScaleToFill;
-        self.preferredContentSize = CGSizeMake(self.imagePreview.image.size.width, self.imagePreview.image.size.height);
     }];
 }
 

+ 5 - 5
iOSClient/PeekPop/CCPeekPop.storyboard

@@ -22,14 +22,14 @@
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="e9H-uI-9UA" userLabel="ImagePreview">
-                                <rect key="frame" x="0.0" y="104" width="375" height="674"/>
+                                <rect key="frame" x="0.0" y="129" width="375" height="649"/>
                             </imageView>
-                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Dhr-ST-vvT">
-                                <rect key="frame" x="5" y="49" width="365" height="50"/>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="characterWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Dhr-ST-vvT">
+                                <rect key="frame" x="5" y="49" width="365" height="75"/>
                                 <constraints>
-                                    <constraint firstAttribute="height" constant="50" id="2I2-hl-qUk"/>
+                                    <constraint firstAttribute="height" constant="75" id="2I2-hl-qUk"/>
                                 </constraints>
-                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                 <nil key="textColor"/>
                                 <nil key="highlightedColor"/>
                             </label>