marinofaggiana 4 years ago
parent
commit
f69ac4b9c3
1 changed files with 15 additions and 7 deletions
  1. 15 7
      iOSClient/Main/NCCollectionCommon.swift

+ 15 - 7
iOSClient/Main/NCCollectionCommon.swift

@@ -634,8 +634,8 @@ extension NCCollectionCommon: NCSelectDelegate {
 
 // MARK: - Nextcloud CollectionView Common
 
-class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate  {
-        
+class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate  {
+
     @IBOutlet weak var collectionView: UICollectionView!
 
     @objc var serverUrl = ""
@@ -668,6 +668,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, NCL
     // DECLARE
     internal var layoutKey = ""
     internal var titleCurrentFolder = ""
+    internal var enableSearchBar: Bool = false
     
     required init?(coder aDecoder: NSCoder) {
         super.init(coder: aDecoder)
@@ -677,11 +678,12 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, NCL
         super.viewDidLoad()
         
         self.navigationController?.navigationBar.prefersLargeTitles = true
-        /*
-         let search = UISearchController(searchResultsController: nil)
-         search.searchResultsUpdater = self
-         self.navigationItem.searchController = search
-         */
+        
+        if enableSearchBar {
+            let search = UISearchController(searchResultsController: nil)
+            search.searchResultsUpdater = self
+            self.navigationItem.searchController = search
+        }
         
         // Cell
         collectionView.register(UINib.init(nibName: "NCListCell", bundle: nil), forCellWithReuseIdentifier: "listCell")
@@ -940,6 +942,12 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, NCL
     func emptyDataSetShouldAllowScroll(_ scrollView: UIScrollView) -> Bool {
         return true
     }
+    
+    // MARK: SEARCH
+    
+    func updateSearchResults(for searchController: UISearchController) {
+
+    }
         
     // MARK: TAP EVENT