Marino Faggiana 6 years ago
parent
commit
9e42a80126

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

@@ -33,12 +33,16 @@
                                     <outlet property="delegate" destination="uQo-FX-ejX" id="b4f-61-b7l"/>
                                 </connections>
                             </collectionView>
-                            <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="eeP-9N-ZRP">
+                            <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"/>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="200" id="kKy-VZ-d0g"/>
                                 </constraints>
+                                <connections>
+                                    <outlet property="dataSource" destination="uQo-FX-ejX" id="Y7U-AM-3WZ"/>
+                                    <outlet property="delegate" destination="uQo-FX-ejX" id="gsE-cc-f9G"/>
+                                </connections>
                             </tableView>
                         </subviews>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -56,6 +60,7 @@
                     <navigationItem key="navigationItem" id="YB9-Lg-X9d"/>
                     <connections>
                         <outlet property="collectioView" destination="QFQ-b1-sYp" id="BaZ-Ko-IUq"/>
+                        <outlet property="tableView" destination="eeP-9N-ZRP" id="dzG-bV-m9u"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="tPT-Fr-1CS" userLabel="First Responder" sceneMemberID="firstResponder"/>

+ 23 - 23
iOSClient/Main/Create cloud/NCCreateFormUploadRichdocuments.swift

@@ -25,7 +25,7 @@ import Foundation
 
 // MARK: -
 
-class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate {
+class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate, UICollectionViewDataSource, UICollectionViewDelegate {
     
     var typeTemplate = ""
     var serverUrl = ""
@@ -35,19 +35,6 @@ class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate {
     
     @IBOutlet weak var collectioView: UICollectionView!
 
-    @objc convenience init(typeTemplate : String) {
-        self.init()
-        
-        self.typeTemplate = typeTemplate
-        serverUrl = appDelegate.activeMain.serverUrl
-        
-        if serverUrl == CCUtility.getHomeServerUrlActiveUrl(appDelegate.activeUrl) {
-            fileNameFolder = "/"
-        } else {
-            fileNameFolder = (serverUrl as NSString).lastPathComponent
-        }
-    }
-    
     func initializeForm() {
         
         let form : XLFormDescriptor = XLFormDescriptor(title: NSLocalizedString("_upload_photos_videos_", comment: "")) as XLFormDescriptor
@@ -63,6 +50,7 @@ class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate {
         
         row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: XLFormRowDescriptorTypeButton, title: fileNameFolder)
         row.action.formSelector = #selector(changeDestinationFolder(_:))
+        row.value = fileNameFolder
         
         let imageFolder = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, multiplier:1, color: NCBrandColor.sharedInstance.brandElement) as UIImage
         row.cellConfig["imageView.image"] = imageFolder
@@ -77,11 +65,8 @@ class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate {
         section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_filename_", comment: ""))
         form.addFormSection(section)
         
-        
         row = XLFormRowDescriptor(tag: "fileName", rowType: XLFormRowDescriptorTypeAccount, title: NSLocalizedString("_filename_", comment: ""))
-        row.value = self.fileName
-        
-        row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
+        row.value = fileName
         
         row.cellConfig["textField.textAlignment"] = NSTextAlignment.right.rawValue
         row.cellConfig["textField.font"] = UIFont.systemFont(ofSize: 15.0)
@@ -91,13 +76,32 @@ class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate {
         self.form = form
     }
     
+    // MARK: - CollectionView
+    
+    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
+        return 0
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+        return UICollectionViewCell()
+    }
+    
     // MARK: - View Life Cycle
     
     override func viewDidLoad() {
         super.viewDidLoad()
         
+        if serverUrl == CCUtility.getHomeServerUrlActiveUrl(appDelegate.activeUrl) {
+            fileNameFolder = "/"
+        } else {
+            fileNameFolder = (serverUrl as NSString).lastPathComponent
+        }
+        
         self.initializeForm()
-
+        
+        collectioView.delegate = self
+        self.tableView.separatorStyle = UITableViewCell.SeparatorStyle.none
+        
         let ocNetworking = OCnetworking.init(delegate: nil, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
         
         ocNetworking?.createTemplateRichdocuments(withTemplate: typeTemplate, success: { (listOfTemplate) in
@@ -116,10 +120,6 @@ class NCCreateFormUploadRichdocuments: XLFormViewController, NCSelectDelegate {
         self.navigationController?.navigationBar.barTintColor = NCBrandColor.sharedInstance.brand
         self.navigationController?.navigationBar.tintColor = NCBrandColor.sharedInstance.brandText
         self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: NCBrandColor.sharedInstance.brandText]
-        
-        self.tableView.separatorStyle = UITableViewCell.SeparatorStyle.none
-        
-        self.reloadForm()
     }
     
     func reloadForm() {

+ 8 - 3
iOSClient/Main/Create cloud/NCCreateMenuAdd.swift

@@ -96,11 +96,16 @@ class NCCreateMenuAdd: NSObject {
             if item.value as? Int == 5 { self.appDelegate.activeMain.createFolder() }
             
             if item.value as? Int == 6 {
-                guard let viewController = UIStoryboard(name: "NCCreateFormUploadRichdocuments", bundle: nil).instantiateInitialViewController() else {
+                guard let navigationController = UIStoryboard(name: "NCCreateFormUploadRichdocuments", bundle: nil).instantiateInitialViewController() else {
                     return
                 }
-                viewController.modalPresentationStyle = UIModalPresentationStyle.pageSheet
-                self.appDelegate.window.rootViewController?.present(viewController, animated: true, completion: nil)
+                navigationController.modalPresentationStyle = UIModalPresentationStyle.pageSheet
+                
+                let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadRichdocuments
+                viewController.typeTemplate = k_richdocument_document
+                viewController.serverUrl = self.appDelegate.activeMain.serverUrl
+                
+                self.appDelegate.window.rootViewController?.present(navigationController, animated: true, completion: nil)
 
                 /*
                 let viewController = NCCreateFormUploadRichdocuments.init(typeTemplate: k_richdocument_document)