marinofaggiana 4 年之前
父节点
当前提交
6fc0852860

+ 2 - 2
Cartfile.resolved

@@ -3,7 +3,7 @@ github "AssistoLab/DropDown" "v2.3.13"
 github "CocoaLumberjack/CocoaLumberjack" "3.6.2"
 github "FabrizioBrancati/Queuer" "2.1.1"
 github "MortimerGoro/MGSwipeTableCell" "1.6.8"
-github "SVGKit/SVGKit" "c7557c9576fa34ba3f01b7e70f0f681b87e1eb4e"
+github "SVGKit/SVGKit" "967b2435466504195f109bac5cbdd08bb96f201e"
 github "SwiftyJSON/SwiftyJSON" "5.0.0"
 github "WeTransfer/WeScan" "1.2.0"
 github "WenchaoD/FSCalendar" "2.8.0"
@@ -18,7 +18,7 @@ github "krzyzanowskim/OpenSSL" "1.0.218"
 github "malcommac/SwiftRichString" "3.7.2"
 github "marinofaggiana/KTVHTTPCache" "2.0.2"
 github "marinofaggiana/TOPasscodeViewController" "0.0.7"
-github "nextcloud/ios-communication-library" "350d2a3188a877373832fd4eaa4e7018cd8022cc"
+github "nextcloud/ios-communication-library" "fbca44bf0b5125a60eaef61ea0984d1c1a423b11"
 github "realm/realm-cocoa" "v5.3.6"
 github "rechsteiner/Parchment" "v2.4.0"
 github "scenee/FloatingPanel" "v1.7.5"

+ 2 - 2
Carthage/Checkouts/SVGKit/.travis.yml

@@ -13,8 +13,8 @@ notifications:
 before_install:
     - env
     - locale
-    - gem install cocoapods --no-rdoc --no-ri --no-document --quiet
-    - gem install xcpretty --no-rdoc --no-ri --no-document --quiet
+    - gem install cocoapods --no-document --quiet
+    - gem install xcpretty --no-document --quiet
     - pod --version
     - pod setup --silent > /dev/null
     - pod repo update --silent

+ 10 - 0
iOSClient/Favorites/NCFavorite.swift

@@ -22,6 +22,7 @@
 //
 
 import Foundation
+import NCCommunication
 
 class NCFavorite: NCCollectionViewCommon  {
     
@@ -31,6 +32,7 @@ class NCFavorite: NCCollectionViewCommon  {
         appDelegate.activeFavorite = self
         titleCurrentFolder = NSLocalizedString("_favorites_", comment: "")
         layoutKey = k_layout_view_favorite
+        enableSearchBar = true
     }
     
     // MARK: DZNEmpty
@@ -148,5 +150,13 @@ class NCFavorite: NCCollectionViewCommon  {
             }
         }
     }
+    
+    override func searchDataSourceNetwork() {
+        if literalSearch == "" { return }
+        
+        NCNetworking.shared.searchFiles(urlBase: appDelegate.urlBase, user: appDelegate.user, literal: literalSearch) { (account, metadatas, errorCode, errorDescription) in
+            
+        }
+    }
 }
 

+ 15 - 1
iOSClient/Main/NCCollectionCommon.swift

@@ -634,7 +634,7 @@ extension NCCollectionCommon: NCSelectDelegate {
 
 // MARK: - Nextcloud CollectionView Common
 
-class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate  {
+class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate  {
 
     @IBOutlet weak var collectionView: UICollectionView!
 
@@ -662,6 +662,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     private let headerMenuHeight: CGFloat = 50
     private let sectionHeaderHeight: CGFloat = 20
     private let footerHeight: CGFloat = 50
+    
+    private var timerInputSearch: Timer?
+    internal var literalSearch: String = ""
         
     internal let refreshControl = UIRefreshControl()
     
@@ -683,6 +686,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
             let search = UISearchController(searchResultsController: nil)
             search.searchResultsUpdater = self
             self.navigationItem.searchController = search
+            search.delegate = self
+            search.searchBar.delegate = self
         }
         
         // Cell
@@ -947,8 +952,16 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     
     func updateSearchResults(for searchController: UISearchController) {
 
+        timerInputSearch?.invalidate()
+        timerInputSearch = Timer.scheduledTimer(timeInterval: 1.5, target: self, selector: #selector(searchDataSourceNetwork), userInfo: nil, repeats: false)
+        
+        literalSearch = searchController.searchBar.text ?? ""
     }
+    
+    func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
         
+    }
+    
     // MARK: TAP EVENT
     
     func tapSwitchHeader(sender: Any) {
@@ -1041,6 +1054,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     
     @objc func reloadDataSource() { }
     @objc func reloadDataSourceNetwork() { }
+    @objc func searchDataSourceNetwork() { }
 }
 
 // MARK: - 3D Touch peek and pop

+ 34 - 0
iOSClient/Networking/NCNetworking.swift

@@ -691,6 +691,35 @@ import Queuer
         }
     }
     
+    @objc func searchFiles(urlBase: String, user: String, dataFileXML: String, literal: String, completion: @escaping (_ account: String, _ metadatas: [tableMetadata]?, _ errorCode: Int, _ errorDescription: String)->()) {
+        
+        NCCommunication.shared.searchLiteral(serverUrl: urlBase, depth: "infinity", literal: literal, showHiddenFiles: CCUtility.getShowHiddenFiles(), user: user) { (account, files, errorCode, errorDescription) in
+            
+            if errorCode == 0  {
+                NCManageDatabase.sharedInstance.convertNCCommunicationFilesToMetadatas(files, useMetadataFolder: false, account: account) { (metadataFolder, metadatasFolder, metadatas) in
+                    
+                    // Update sub directories
+                    for metadata in metadatasFolder {
+                        let serverUrl = metadata.serverUrl + "/" + metadata.fileName
+                        NCManageDatabase.sharedInstance.addDirectory(encrypted: metadata.e2eEncrypted, favorite: metadata.favorite, ocId: metadata.ocId, fileId: metadata.fileId, etag: nil, permissions: metadata.permissions, serverUrl: serverUrl, richWorkspace: metadata.richWorkspace, account: account)
+                    }
+                    
+                    NCManageDatabase.sharedInstance.addMetadatas(metadatas)
+                    
+                    completion(account, metadatas, errorCode, errorDescription)
+                }
+                
+            } else {
+                
+                #if !EXTENSION
+                NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
+                #endif
+                
+                completion(account, nil, errorCode, errorDescription)
+            }
+        }
+    }
+    
     //MARK: - WebDav Create Folder
 
     @objc func createFolder(fileName: String, serverUrl: String, account: String, urlBase: String, overwrite: Bool = false, completion: @escaping (_ errorCode: Int, _ errorDescription: String)->()) {
@@ -733,6 +762,11 @@ import Queuer
             } else if errorCode == 405 && overwrite {
                 self.NotificationPost(name: k_notificationCenter_createFolder, userInfo: ["fileName": fileName, "serverUrl": serverUrl, "errorCode": 0], errorDescription: "", completion: completion)
             } else {
+                
+                #if !EXTENSION
+                NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
+                #endif
+                
                 self.NotificationPost(name: k_notificationCenter_createFolder, userInfo: ["fileName": fileName, "serverUrl": serverUrl, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
             }
         }