Browse Source

dev template form

Marino Faggiana 6 years ago
parent
commit
f3822dd1fb

+ 21 - 0
iOSClient/Images.xcassets/plus100.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "plus100@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
iOSClient/Images.xcassets/plus100.imageset/plus100@2x.png


+ 17 - 6
iOSClient/Main/Create cloud/NCCreateFormUploadRichdocuments.storyboard

@@ -19,10 +19,10 @@
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="kdt-bX-icm">
-                                <rect key="frame" x="0.0" y="64" width="375" height="395"/>
+                                <rect key="frame" x="0.0" y="64" width="375" height="200"/>
                                 <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 <constraints>
-                                    <constraint firstAttribute="height" constant="395" id="XAH-EC-bwE"/>
+                                    <constraint firstAttribute="height" constant="200" id="XAH-EC-bwE"/>
                                 </constraints>
                                 <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="5" minimumInteritemSpacing="5" id="pay-52-Gt0">
                                     <size key="itemSize" width="150" height="165"/>
@@ -38,7 +38,7 @@
                                             <rect key="frame" x="0.0" y="0.0" width="150" height="165"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
-                                                <imageView opaque="NO" userInteractionEnabled="NO" tag="100" contentMode="scaleAspectFit" translatesAutoresizingMaskIntoConstraints="NO" id="X31-eH-dH5" userLabel="Image">
+                                                <imageView opaque="NO" userInteractionEnabled="NO" tag="100" contentMode="scaleAspectFit" translatesAutoresizingMaskIntoConstraints="NO" id="X31-eH-dH5" userLabel="ImagePreview">
                                                     <rect key="frame" x="1" y="1" width="148" height="148"/>
                                                     <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                                     <constraints>
@@ -55,11 +55,20 @@
                                                     <nil key="textColor"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
+                                                <imageView userInteractionEnabled="NO" tag="300" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="plus100" translatesAutoresizingMaskIntoConstraints="NO" id="Byg-Ok-yCr" userLabel="imageSelect">
+                                                    <rect key="frame" x="50" y="50" width="50" height="50"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="width" constant="50" id="2ZV-XV-9Tj" userLabel="width = 50"/>
+                                                        <constraint firstAttribute="height" constant="50" id="DVP-w6-ED7" userLabel="height = 50"/>
+                                                    </constraints>
+                                                </imageView>
                                             </subviews>
                                         </view>
                                         <color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                         <constraints>
+                                            <constraint firstItem="Byg-Ok-yCr" firstAttribute="centerY" secondItem="X31-eH-dH5" secondAttribute="centerY" id="5Nv-Dp-EhZ"/>
                                             <constraint firstItem="BeG-go-HP6" firstAttribute="leading" secondItem="3Zg-hF-dVr" secondAttribute="leading" id="9aq-dC-p0W"/>
+                                            <constraint firstItem="Byg-Ok-yCr" firstAttribute="centerX" secondItem="X31-eH-dH5" secondAttribute="centerX" id="FBh-By-cXv"/>
                                             <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 firstAttribute="trailing" secondItem="X31-eH-dH5" secondAttribute="trailing" constant="1" id="OsG-61-SBl"/>
@@ -74,7 +83,7 @@
                                 </connections>
                             </collectionView>
                             <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" scrollEnabled="NO" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="eeP-9N-ZRP">
-                                <rect key="frame" x="0.0" y="467" width="375" height="200"/>
+                                <rect key="frame" x="0.0" y="297" width="375" height="200"/>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="200" id="kKy-VZ-d0g"/>
@@ -87,9 +96,8 @@
                         </subviews>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <constraints>
-                            <constraint firstItem="ILQ-5j-b92" firstAttribute="bottom" secondItem="eeP-9N-ZRP" secondAttribute="bottom" id="GzZ-KF-foB"/>
+                            <constraint firstItem="eeP-9N-ZRP" firstAttribute="top" secondItem="kdt-bX-icm" secondAttribute="bottom" constant="33" id="Fhq-zQ-1Cx"/>
                             <constraint firstItem="kdt-bX-icm" firstAttribute="leading" secondItem="eeP-9N-ZRP" secondAttribute="leading" id="M0y-VC-ex7"/>
-                            <constraint firstItem="eeP-9N-ZRP" firstAttribute="top" secondItem="kdt-bX-icm" secondAttribute="bottom" constant="8" id="PIz-JB-ikZ"/>
                             <constraint firstItem="kdt-bX-icm" firstAttribute="trailing" secondItem="eeP-9N-ZRP" secondAttribute="trailing" id="iNB-l9-u3p"/>
                             <constraint firstItem="kdt-bX-icm" firstAttribute="top" secondItem="ILQ-5j-b92" secondAttribute="top" id="nnJ-OQ-Uly"/>
                             <constraint firstItem="eeP-9N-ZRP" firstAttribute="leading" secondItem="ILQ-5j-b92" secondAttribute="leading" id="pNx-zH-54E"/>
@@ -126,4 +134,7 @@
             <point key="canvasLocation" x="256.80000000000001" y="228.93553223388307"/>
         </scene>
     </scenes>
+    <resources>
+        <image name="plus100" width="50" height="50"/>
+    </resources>
 </document>

+ 31 - 5
iOSClient/Main/Create cloud/NCCreateFormUploadRichdocuments.swift

@@ -31,7 +31,9 @@ class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate, U
     var serverUrl = ""
     var fileNameFolder = ""
     var fileName = ""
+    var fileNameExtension = ""
     var listOfTemplate = [NCRichDocumentTemplate]()
+    var selectTemplateName = ""
     
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     
@@ -129,26 +131,50 @@ class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate, U
         
         let template = listOfTemplate[indexPath.row]
         
-        let imageView = cell.viewWithTag(100) as! UIImageView
-        let name = cell.viewWithTag(200) as! UILabel
-        
+        // image
+        let imagePreview = cell.viewWithTag(100) as! UIImageView
         if template.preview != "" {
             let fileNameLocalPath = CCUtility.getDirectoryUserData() + "/" + template.name + ".png"
             if FileManager.default.fileExists(atPath: fileNameLocalPath) {
                 let imageURL = URL(fileURLWithPath: fileNameLocalPath)
                 if let image = UIImage(contentsOfFile: imageURL.path) {
-                    imageView.image = image
+                    imagePreview.image = image
                 }
             } else {
                 getImage(template: template, indexPath: indexPath)
             }
         }
         
+        // name
+        let name = cell.viewWithTag(200) as! UILabel
         name.text = template.name
-
+        
+        // select
+        let imageSelect = cell.viewWithTag(300) as! UIImageView
+        if selectTemplateName == template.name {
+            cell.backgroundColor = NCBrandColor.sharedInstance.brand
+            imageSelect.image = UIImage(named: "plus100")
+            imageSelect.isHidden = false
+        } else {
+            cell.backgroundColor = UIColor.black
+            imageSelect.isHidden = true
+        }
+        
         return cell
     }
     
+    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+        
+        let template = listOfTemplate[indexPath.row]
+        
+        selectTemplateName = template.name
+        fileNameExtension = template.extension
+        
+        self.navigationItem.rightBarButtonItem?.isEnabled = true
+
+        collectionView.reloadData()
+    }
+    
     // MARK: - Action
     
     func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String) {