Browse Source

dev Select

Marino Faggiana 6 years ago
parent
commit
4ec017c018
2 changed files with 55 additions and 37 deletions
  1. 31 3
      iOSClient/Select/NCSelect.storyboard
  2. 24 34
      iOSClient/Select/NCSelect.swift

+ 31 - 3
iOSClient/Select/NCSelect.storyboard

@@ -19,7 +19,7 @@
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="0HI-k1-SD0">
-                                <rect key="frame" x="0.0" y="64" width="375" height="603"/>
+                                <rect key="frame" x="0.0" y="64" width="375" height="559"/>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="0.0" minimumInteritemSpacing="0.0" id="D7P-75-aB1">
                                     <size key="itemSize" width="0.0" height="0.0"/>
@@ -33,19 +33,47 @@
                                     <outlet property="delegate" destination="VYq-xA-D35" id="EXB-bA-tje"/>
                                 </connections>
                             </collectionView>
+                            <toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2ha-lH-BXy">
+                                <rect key="frame" x="0.0" y="623" width="375" height="44"/>
+                                <items>
+                                    <barButtonItem title="Left" id="CIy-cf-IQn">
+                                        <connections>
+                                            <action selector="actionToolbarButtonLeft:" destination="VYq-xA-D35" id="kgc-Ce-adE"/>
+                                        </connections>
+                                    </barButtonItem>
+                                    <barButtonItem style="plain" systemItem="flexibleSpace" id="mLU-GT-QAB"/>
+                                    <barButtonItem title="Right" id="tL8-Fx-8pT">
+                                        <connections>
+                                            <action selector="actioToolbarButtonRight:" destination="VYq-xA-D35" id="zcv-wE-Noj"/>
+                                        </connections>
+                                    </barButtonItem>
+                                </items>
+                            </toolbar>
                         </subviews>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <constraints>
+                            <constraint firstItem="2ha-lH-BXy" firstAttribute="leading" secondItem="vaA-85-uNN" secondAttribute="leading" id="3qQ-yJ-DJf"/>
                             <constraint firstItem="vaA-85-uNN" firstAttribute="trailing" secondItem="0HI-k1-SD0" secondAttribute="trailing" id="Dk4-c3-6wl"/>
                             <constraint firstItem="0HI-k1-SD0" firstAttribute="top" secondItem="vaA-85-uNN" secondAttribute="top" id="GKj-QM-2Yy"/>
-                            <constraint firstItem="vaA-85-uNN" firstAttribute="bottom" secondItem="0HI-k1-SD0" secondAttribute="bottom" id="rfT-Rj-oeD"/>
+                            <constraint firstItem="vaA-85-uNN" firstAttribute="bottom" secondItem="2ha-lH-BXy" secondAttribute="bottom" id="MuH-2B-u4g"/>
+                            <constraint firstItem="2ha-lH-BXy" firstAttribute="top" secondItem="0HI-k1-SD0" secondAttribute="bottom" id="gSg-go-7CN"/>
+                            <constraint firstItem="vaA-85-uNN" firstAttribute="trailing" secondItem="2ha-lH-BXy" secondAttribute="trailing" id="tJa-IY-yQP"/>
                             <constraint firstItem="0HI-k1-SD0" firstAttribute="leading" secondItem="vaA-85-uNN" secondAttribute="leading" id="uLL-RT-YFO"/>
                         </constraints>
                         <viewLayoutGuide key="safeArea" id="vaA-85-uNN"/>
                     </view>
-                    <navigationItem key="navigationItem" id="N5K-De-4CP"/>
+                    <navigationItem key="navigationItem" id="N5K-De-4CP">
+                        <barButtonItem key="rightBarButtonItem" title="Right" id="qHj-AF-EN7">
+                            <connections>
+                                <action selector="actionNavigationButtonRight:" destination="VYq-xA-D35" id="H7V-FR-TAf"/>
+                            </connections>
+                        </barButtonItem>
+                    </navigationItem>
                     <connections>
                         <outlet property="collectionView" destination="0HI-k1-SD0" id="xme-mG-bnz"/>
+                        <outlet property="navigationButtonRight" destination="qHj-AF-EN7" id="ijb-ca-mcN"/>
+                        <outlet property="toolbarButtonLeft" destination="CIy-cf-IQn" id="t5v-Og-7hE"/>
+                        <outlet property="toolbarButtonRight" destination="tL8-Fx-8pT" id="LcJ-Ni-K2m"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="vH8-UY-9MN" userLabel="First Responder" sceneMemberID="firstResponder"/>

+ 24 - 34
iOSClient/Select/NCSelect.swift

@@ -27,6 +27,11 @@ class NCSelect: UIViewController ,UICollectionViewDataSource, UICollectionViewDe
     
     @IBOutlet fileprivate weak var collectionView: UICollectionView!
     
+    @IBOutlet fileprivate weak var navigationButtonRight: UIBarButtonItem!
+
+    @IBOutlet fileprivate weak var toolbarButtonLeft: UIBarButtonItem!
+    @IBOutlet fileprivate weak var toolbarButtonRight: UIBarButtonItem!
+
     var titleCurrentFolder = NSLocalizedString("_select_", comment: "")
     var serverUrl = ""
     var directoryID = ""
@@ -144,6 +149,18 @@ class NCSelect: UIViewController ,UICollectionViewDataSource, UICollectionViewDe
         return true
     }
     
+    
+    // MARK: ACTION
+    
+    @IBAction func actionNavigationButtonRight(_ sender: Any) {
+    }
+    
+    @IBAction func actioToolbarButtonRight(_ sender: Any) {
+    }
+    
+    @IBAction func actionToolbarButtonLeft(_ sender: Any) {
+    }
+    
     // MARK: TAP EVENT
     
     func tapSwitchHeader(sender: Any) {
@@ -282,7 +299,7 @@ class NCSelect: UIViewController ,UICollectionViewDataSource, UICollectionViewDe
                     self.loadDatasource(withLoadFolder: false)
                 }
                 if item.value as? Int == 1 { self.appDelegate.activeMain.openWindowShare(metadata) }
-                if item.value as? Int == 2 { self.deleteItem(with: metadata, sender: sender) }
+                if item.value as? Int == 2 {  print("option 2") }
                 if item is ActionSheetCancelButton { print("Cancel buttons has the value `true`") }
             }
             
@@ -370,47 +387,20 @@ class NCSelect: UIViewController ,UICollectionViewDataSource, UICollectionViewDe
     
     // MARK: NC API
     
-    func downloadThumbnail(with tableMetadata: tableMetadata, indexPath: IndexPath) {
+    func downloadThumbnail(with metadata: tableMetadata, indexPath: IndexPath) {
+        
+        let width = NCUtility.sharedInstance.getScreenWidthForPreview()
+        let height = NCUtility.sharedInstance.getScreenHeightForPreview()
         
         let ocNetworking = OCnetworking.init(delegate: self, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
         
-        ocNetworking?.downloadPreviewTrash(withFileID: tableMetadata.fileID, fileName: tableMetadata.fileName, completion: { (message, errorCode) in
-            if errorCode == 0 && CCUtility.fileProviderStorageIconExists(tableMetadata.fileID, fileNameView: tableMetadata.fileName) {
+        ocNetworking?.downloadPreview(with: metadata, serverUrl: serverUrl, withWidth: width, andHeight: height, completion: { (message, errorCode) in
+            if errorCode == 0 && CCUtility.fileProviderStorageIconExists(metadata.fileID, fileNameView: metadata.fileName) {
                 self.collectionView.reloadItems(at: [indexPath])
             }
         })
     }
     
-    func deleteItem(with metadata: tableMetadata, sender: Any) {
-        
-        var items = [ActionSheetItem]()
-        
-        guard let serverUrl = NCManageDatabase.sharedInstance.getServerUrl(metadata.directoryID) else {
-            return
-        }
-        guard let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == serverUrl", appDelegate.activeAccount, serverUrl)) else {
-            return
-        }
-        
-        items.append(ActionSheetDangerButton(title: NSLocalizedString("_delete_", comment: "")))
-        items.append(ActionSheetCancelButton(title: NSLocalizedString("_cancel_", comment: "")))
-        
-        actionSheet = ActionSheet(items: items) { sheet, item in
-            if item is ActionSheetDangerButton {
-                NCMainCommon.sharedInstance.deleteFile(metadatas: [metadata], e2ee: tableDirectory.e2eEncrypted, serverUrl: serverUrl, folderFileID: tableDirectory.fileID) { (errorCode, message) in
-                    self.loadDatasource(withLoadFolder: false)
-                }
-            }
-            if item is ActionSheetCancelButton { print("Cancel buttons has the value `true`") }
-        }
-        
-        let headerView = actionSheetHeader(with: metadata)
-        actionSheet?.headerView = headerView
-        actionSheet?.headerView?.frame.size.height = 50
-        
-        actionSheet?.present(in: self, from: sender as! UIButton)
-    }
-    
     func loadFolder() {
         
         let ocNetworking = OCnetworking.init(delegate: self, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)