Browse Source

dev template

Marino Faggiana 6 years ago
parent
commit
dbbe4e3af0

+ 19 - 13
iOSClient/Main/Create cloud/NCCreateFormUploadRichdocuments.storyboard

@@ -24,41 +24,47 @@
                                 <constraints>
                                     <constraint firstAttribute="height" constant="395" id="XAH-EC-bwE"/>
                                 </constraints>
-                                <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="pay-52-Gt0">
-                                    <size key="itemSize" width="100" height="120"/>
+                                <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="5" minimumInteritemSpacing="5" id="pay-52-Gt0">
+                                    <size key="itemSize" width="150" height="165"/>
                                     <size key="headerReferenceSize" width="0.0" height="0.0"/>
                                     <size key="footerReferenceSize" width="0.0" height="0.0"/>
-                                    <inset key="sectionInset" minX="1" minY="1" maxX="1" maxY="1"/>
+                                    <inset key="sectionInset" minX="5" minY="5" maxX="5" maxY="0.0"/>
                                 </collectionViewFlowLayout>
                                 <cells>
                                     <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="cell" id="3Zg-hF-dVr">
-                                        <rect key="frame" x="1" y="1" width="100" height="120"/>
+                                        <rect key="frame" x="5" y="5" width="150" height="165"/>
                                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                         <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
-                                            <rect key="frame" x="0.0" y="0.0" width="100" height="120"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="150" height="165"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
-                                                <imageView userInteractionEnabled="NO" tag="100" contentMode="scaleAspectFit" translatesAutoresizingMaskIntoConstraints="NO" id="X31-eH-dH5" userLabel="Image">
-                                                    <rect key="frame" x="0.0" y="0.0" width="100" height="100"/>
+                                                <imageView opaque="NO" userInteractionEnabled="NO" tag="100" contentMode="scaleAspectFit" translatesAutoresizingMaskIntoConstraints="NO" id="X31-eH-dH5" userLabel="Image">
+                                                    <rect key="frame" x="1" y="1" width="148" height="148"/>
+                                                    <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                                     <constraints>
-                                                        <constraint firstAttribute="height" constant="100" id="BG3-vx-4j8"/>
-                                                        <constraint firstAttribute="width" constant="100" id="yuL-xg-218"/>
+                                                        <constraint firstAttribute="height" constant="148" id="BG3-vx-4j8"/>
                                                     </constraints>
                                                 </imageView>
                                                 <label opaque="NO" userInteractionEnabled="NO" tag="200" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BeG-go-HP6">
-                                                    <rect key="frame" x="0.0" y="105" width="100" height="16"/>
+                                                    <rect key="frame" x="0.0" y="150" width="150" height="15"/>
+                                                    <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="height" constant="15" id="SB5-4E-7OZ"/>
+                                                    </constraints>
                                                     <fontDescription key="fontDescription" type="system" pointSize="13"/>
                                                     <nil key="textColor"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                             </subviews>
                                         </view>
+                                        <color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                         <constraints>
                                             <constraint firstItem="BeG-go-HP6" firstAttribute="leading" secondItem="3Zg-hF-dVr" secondAttribute="leading" id="9aq-dC-p0W"/>
-                                            <constraint firstItem="X31-eH-dH5" firstAttribute="leading" secondItem="3Zg-hF-dVr" secondAttribute="leading" id="HCI-EG-bNi"/>
+                                            <constraint firstItem="X31-eH-dH5" firstAttribute="leading" secondItem="3Zg-hF-dVr" secondAttribute="leading" constant="1" id="HCI-EG-bNi"/>
                                             <constraint firstAttribute="trailing" secondItem="BeG-go-HP6" secondAttribute="trailing" id="Ir1-IG-qyG"/>
-                                            <constraint firstItem="BeG-go-HP6" firstAttribute="top" secondItem="X31-eH-dH5" secondAttribute="bottom" constant="5" id="g4f-fe-BO0"/>
-                                            <constraint firstItem="X31-eH-dH5" firstAttribute="top" secondItem="3Zg-hF-dVr" secondAttribute="top" id="jik-qq-poj"/>
+                                            <constraint firstAttribute="trailing" secondItem="X31-eH-dH5" secondAttribute="trailing" constant="1" id="OsG-61-SBl"/>
+                                            <constraint firstItem="X31-eH-dH5" firstAttribute="top" secondItem="3Zg-hF-dVr" secondAttribute="top" constant="1" id="jik-qq-poj"/>
+                                            <constraint firstAttribute="bottom" secondItem="BeG-go-HP6" secondAttribute="bottom" id="qCU-fe-CS8"/>
                                         </constraints>
                                     </collectionViewCell>
                                 </cells>

+ 33 - 1
iOSClient/Main/Create cloud/NCCreateFormUploadRichdocuments.swift

@@ -132,7 +132,7 @@ class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate, U
         let imageView = cell.viewWithTag(100) as! UIImageView
         let name = cell.viewWithTag(200) as! UILabel
         
-        imageView.image = UIImage.init(named: "folder")
+        imageView.image = template.image
         name.text = template.name
 
         return cell
@@ -202,6 +202,38 @@ class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate, U
         ocNetworking?.createTemplateRichdocuments(withTemplate: typeTemplate, success: { (listOfTemplate) in
             
             self.listOfTemplate = listOfTemplate as! [NCRichDocumentTemplate]
+            for template: NCRichDocumentTemplate in self.listOfTemplate {
+                if let url = URL(string: template.preview.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!) {
+                    if let imageData = try? Data(contentsOf: url) {
+                        if let image = UIImage.init(data: imageData) {
+                            template.image = image
+                        }
+                    }
+                }
+                
+                /*
+ self.listOfTemplate = listOfTemplate as! [NCRichDocumentTemplate]
+ for template: NCRichDocumentTemplate in self.listOfTemplate {
+ 
+ if let url = URL(string: template.preview.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!) {
+ let task = URLSession.shared.dataTask(with: NSURLRequest(url: url) as URLRequest, completionHandler: { data,response,error in
+ if error == nil && data != nil && data!.count > 0 {
+ if let image = UIImage.init(data: data!) {
+ template.image = image
+ self.collectionView.reloadData()
+ }
+ } else {
+ print(error?.localizedDescription)
+ }
+ 
+ })
+ task.resume()
+ }
+ }
+ */
+                
+            }
+            
             self.collectionView.reloadData()
             
         }, failure: { (message, errorCode) in