Browse Source

remove search bar ios11 restore old bar

Marino Faggiana 7 năm trước cách đây
mục cha
commit
f5eef0deb3

+ 1 - 1
iOSClient/Brand/Picker.plist

@@ -19,7 +19,7 @@
 	<key>CFBundleShortVersionString</key>
 	<string>2.19.0</string>
 	<key>CFBundleVersion</key>
-	<string>00008</string>
+	<string>00009</string>
 	<key>NSAppTransportSecurity</key>
 	<dict>
 		<key>NSAllowsArbitraryLoads</key>

+ 1 - 1
iOSClient/Brand/PickerFileProvider.plist

@@ -19,7 +19,7 @@
 	<key>CFBundleShortVersionString</key>
 	<string>2.19.0</string>
 	<key>CFBundleVersion</key>
-	<string>00008</string>
+	<string>00009</string>
 	<key>NSExtension</key>
 	<dict>
 		<key>NSExtensionFileProviderDocumentGroup</key>

+ 1 - 1
iOSClient/Brand/Share.plist

@@ -19,7 +19,7 @@
 	<key>CFBundleShortVersionString</key>
 	<string>2.19.0</string>
 	<key>CFBundleVersion</key>
-	<string>00008</string>
+	<string>00009</string>
 	<key>NSAppTransportSecurity</key>
 	<dict>
 		<key>NSAllowsArbitraryLoads</key>

+ 1 - 1
iOSClient/Brand/iOSClient.plist

@@ -69,7 +69,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>00008</string>
+	<string>00009</string>
 	<key>Fabric</key>
 	<dict>
 		<key>APIKey</key>

+ 15 - 48
iOSClient/Main/CCMain.m

@@ -316,6 +316,9 @@
     // Refresh control
     _refreshControl.tintColor = [NCBrandColor sharedInstance].brand;
     
+    // color searchbar
+    self.searchController.searchBar.barTintColor = [NCBrandColor sharedInstance].brand;
+    
     // Reload Table View
     [self tableViewReloadData];
 }
@@ -1858,59 +1861,23 @@
 - (void)searchEnabled:(BOOL)enabled
 {
     if (enabled) {
+    
+        if (self.tableView.tableHeaderView != nil)
+            return;
         
-        if (@available(iOS 11, *)) {
-            
-            if (self.navigationItem.searchController != nil)
-                return;
-            
-            self.definesPresentationContext = YES;
-            self.searchController.searchResultsUpdater = self;
-            self.searchController.dimsBackgroundDuringPresentation = NO;
-            self.searchController.searchBar.barTintColor = [NCBrandColor sharedInstance].seperator;
-            [self.searchController.searchBar sizeToFit];
-            self.searchController.searchBar.delegate = self;
-            
-            self.navigationItem.searchController = self.searchController;
-            self.navigationItem.hidesSearchBarWhenScrolling = true;
-            self.navigationItem.searchController.searchBar.tintColor = [UIColor whiteColor];
+        self.definesPresentationContext = YES;
+        self.searchController.searchResultsUpdater = self;
+        self.searchController.dimsBackgroundDuringPresentation = NO;
+        self.searchController.searchBar.barTintColor = [NCBrandColor sharedInstance].brand;
+        [self.searchController.searchBar sizeToFit];
+        self.searchController.searchBar.delegate = self;
         
-            UITextField *textField = [self.searchController.searchBar valueForKey:@"searchField"];
-            textField.textColor = [UIColor blackColor];
-            textField.tintColor = [UIColor blackColor];
-        
-            UIView *backgroundView = textField.subviews.firstObject;
-            backgroundView.backgroundColor = UIColor.whiteColor;
-            backgroundView.layer.cornerRadius = 10;
-            backgroundView.clipsToBounds = YES;
-            
-        } else {
-            
-            if (self.tableView.tableHeaderView != nil)
-                return;
-            
-            self.definesPresentationContext = YES;
-            self.searchController.searchResultsUpdater = self;
-            self.searchController.dimsBackgroundDuringPresentation = NO;
-            self.searchController.searchBar.barTintColor = [NCBrandColor sharedInstance].seperator;
-            [self.searchController.searchBar sizeToFit];
-            self.searchController.searchBar.delegate = self;
-            
-            self.tableView.tableHeaderView = self.searchController.searchBar;
-            [self.tableView setContentOffset:CGPointMake(0, self.searchController.searchBar.frame.size.height - self.tableView.contentOffset.y)];
-        }
+        self.tableView.tableHeaderView = self.searchController.searchBar;
+        [self.tableView setContentOffset:CGPointMake(0, self.searchController.searchBar.frame.size.height - self.tableView.contentOffset.y)];
         
     } else {
         
-        if (@available(iOS 11, *)) {
-            
-            self.navigationItem.searchController = nil;
-            
-        } else {
-            
-            self.tableView.tableHeaderView = nil;
-        }
-        
+        self.tableView.tableHeaderView = nil;
     }
 }