diff --git a/Vector.xcodeproj/project.pbxproj b/Vector.xcodeproj/project.pbxproj index 302cbcbbc..654adc5e4 100644 --- a/Vector.xcodeproj/project.pbxproj +++ b/Vector.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 3223A3E41C10AB0D00E7FD8F /* SearchViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3223A3E31C10AB0D00E7FD8F /* SearchViewController.m */; }; 32D200831C15C56A00A4E396 /* search_bg.png in Resources */ = {isa = PBXBuildFile; fileRef = 32D200801C15C56A00A4E396 /* search_bg.png */; }; 32D200841C15C56A00A4E396 /* search_bg@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 32D200811C15C56A00A4E396 /* search_bg@2x.png */; }; 32D200851C15C56A00A4E396 /* search_bg@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 32D200821C15C56A00A4E396 /* search_bg@3x.png */; }; @@ -138,8 +137,6 @@ /* Begin PBXFileReference section */ 11865E69C29698A4179E1F3F /* Pods-Vector.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Vector.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Vector/Pods-Vector.debug.xcconfig"; sourceTree = ""; }; - 3223A3E21C10AB0D00E7FD8F /* SearchViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchViewController.h; sourceTree = ""; }; - 3223A3E31C10AB0D00E7FD8F /* SearchViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SearchViewController.m; sourceTree = ""; }; 32D200801C15C56A00A4E396 /* search_bg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = search_bg.png; sourceTree = ""; }; 32D200811C15C56A00A4E396 /* search_bg@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "search_bg@2x.png"; sourceTree = ""; }; 32D200821C15C56A00A4E396 /* search_bg@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "search_bg@3x.png"; sourceTree = ""; }; @@ -314,15 +311,6 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 3223A3E11C10AAF000E7FD8F /* Search */ = { - isa = PBXGroup; - children = ( - 3223A3E21C10AB0D00E7FD8F /* SearchViewController.h */, - 3223A3E31C10AB0D00E7FD8F /* SearchViewController.m */, - ); - path = Search; - sourceTree = ""; - }; 6567B0BBF3C05D7F7A7F79CC /* Frameworks */ = { isa = PBXGroup; children = ( @@ -582,7 +570,6 @@ F094AA151B78E42600B1FBBF /* ViewController */ = { isa = PBXGroup; children = ( - 3223A3E11C10AAF000E7FD8F /* Search */, F094AA161B78E42600B1FBBF /* AccountDetailsViewController.h */, F094AA171B78E42600B1FBBF /* AccountDetailsViewController.m */, F094AA181B78E42600B1FBBF /* AuthenticationViewController.h */, @@ -925,7 +912,6 @@ 71352D591C10569F001D50B0 /* AvatarGenerator.m in Sources */, 717928471C03852C00407D96 /* TableViewCellWithLabelAndLargeTextView.m in Sources */, 7165A25B1C05CD42003635D7 /* SegmentedViewController.m in Sources */, - 3223A3E41C10AB0D00E7FD8F /* SearchViewController.m in Sources */, F094AA321B78E42600B1FBBF /* GlobalNotificationSettingsViewController.m in Sources */, F094A9A81B78D8F000B1FBBF /* main.m in Sources */, F00C47861BFF77C800DBABC9 /* RecentTableViewCell.m in Sources */, diff --git a/Vector/Base.lproj/Main.storyboard b/Vector/Base.lproj/Main.storyboard index 7fd81ad33..8df82a6cb 100644 --- a/Vector/Base.lproj/Main.storyboard +++ b/Vector/Base.lproj/Main.storyboard @@ -236,32 +236,12 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/Vector/ViewController/HomeViewController.h b/Vector/ViewController/HomeViewController.h index f8aabaa45..d8109fae5 100644 --- a/Vector/ViewController/HomeViewController.h +++ b/Vector/ViewController/HomeViewController.h @@ -16,7 +16,7 @@ #import "SegmentedViewController.h" -@interface HomeViewController : SegmentedViewController +@interface HomeViewController : SegmentedViewController @property (weak, nonatomic) IBOutlet UIBarButtonItem *settingsBarButtonItem; @property (weak, nonatomic) IBOutlet UIBarButtonItem *searchBarButtonIem; diff --git a/Vector/ViewController/RecentsViewController.m b/Vector/ViewController/RecentsViewController.m index f2a44f244..090c799a2 100644 --- a/Vector/ViewController/RecentsViewController.m +++ b/Vector/ViewController/RecentsViewController.m @@ -27,8 +27,6 @@ #import "VectorDesignValues.h" -#import "SearchViewController.h" - @interface RecentsViewController () { // Recents refresh handling @@ -303,11 +301,6 @@ controller.navigationItem.leftItemsSupplementBackButton = YES; } } - else if ([[segue identifier] isEqualToString:@"presentSearch"]) - { - SearchViewController *searchViewController = (SearchViewController*)segue.destinationViewController; - [searchViewController displayWithSession:self.dataSource.mxSession]; - } // Hide back button title self.navigationItem.backBarButtonItem =[[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; diff --git a/Vector/ViewController/Search/SearchViewController.h b/Vector/ViewController/Search/SearchViewController.h deleted file mode 100644 index 038b06639..000000000 --- a/Vector/ViewController/Search/SearchViewController.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright 2015 OpenMarket Ltd - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -#import "SegmentedViewController.h" - -@class MXSession; - -@interface SearchViewController : SegmentedViewController - -- (void)displayWithSession:(MXSession*)session; - -@end diff --git a/Vector/ViewController/Search/SearchViewController.m b/Vector/ViewController/Search/SearchViewController.m deleted file mode 100644 index a3bd87717..000000000 --- a/Vector/ViewController/Search/SearchViewController.m +++ /dev/null @@ -1,140 +0,0 @@ -/* - Copyright 2015 OpenMarket Ltd - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -#import "SearchViewController.h" - -#import "RecentsViewController.h" -#import "RecentsDataSource.h" - -@interface SearchViewController () -{ - // The search bar - UISearchBar *searchBar; - - // The view controller used under the "rooms" tab. - // This is a RecentsViewController which is used only for its search feature. - // This means that the search is done locally - RecentsViewController *roomsSearchViewController; - RecentsDataSource *roomsSearchDataSource; -} - -@end - -@implementation SearchViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - searchBar = [[UISearchBar alloc] initWithFrame:self.navigationController.navigationBar.frame]; - searchBar.autoresizingMask = UIViewAutoresizingFlexibleWidth; - searchBar.showsCancelButton = YES; - searchBar.returnKeyType = UIReturnKeyDone; // UIReturnKeySearch - searchBar.delegate = self; - - self.navigationItem.leftBarButtonItem = [UIBarButtonItem new]; - self.navigationItem.titleView = searchBar; - - self.backgroundImageView.image = [UIImage imageNamed:@"search_bg"]; - - // This is a VC for searching. So, show the keyboard with the VC - [searchBar becomeFirstResponder]; -} - -- (void)displayWithSession:(MXSession *)session -{ - NSMutableArray* viewControllers = [[NSMutableArray alloc] init]; - NSMutableArray* titles = [[NSMutableArray alloc] init]; - - [titles addObject: NSLocalizedStringFromTable(@"Rooms", @"Vector", nil)]; - roomsSearchViewController = [RecentsViewController recentListViewController]; - roomsSearchDataSource = [[RecentsDataSource alloc] initWithMatrixSession:session]; - [roomsSearchViewController displayList:roomsSearchDataSource]; - [viewControllers addObject:roomsSearchViewController]; - - [titles addObject: NSLocalizedStringFromTable(@"Messages", @"Vector", nil)]; - RecentsViewController *recentsViewController = [RecentsViewController recentListViewController]; - RecentsDataSource *recentlistDataSource = [[RecentsDataSource alloc] initWithMatrixSession:session]; - [recentsViewController displayList:recentlistDataSource]; - [viewControllers addObject:recentsViewController]; - - [titles addObject: NSLocalizedStringFromTable(@"People", @"Vector", nil)]; - /*RecentsViewController**/ recentsViewController = [RecentsViewController recentListViewController]; - /*RecentsDataSource **/recentlistDataSource = [[RecentsDataSource alloc] initWithMatrixSession:session]; - [recentsViewController displayList:recentlistDataSource]; - [viewControllers addObject:recentsViewController]; - - //segmentedViewController.title = NSLocalizedStringFromTable(@"room_details_title", @"Vector", nil); - [self initWithTitles:titles viewControllers:viewControllers defaultSelected:0]; - - // to display a red navbar when the home server cannot be reached. - [self addMatrixSession:session]; -} - -- (void)viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; - - // Reset current results - [self updateSearch]; -} - -// Update search results under the currently selected tab -- (void)updateSearch -{ - if (searchBar.text.length) - { - self.displayedViewController.view.hidden = NO; - - // Forward the search request to the data source - if (self.displayedViewController == roomsSearchViewController) - { - [roomsSearchDataSource searchWithPatterns:@[searchBar.text]]; - } - } - else - { - // Nothing to search = Show nothing - self.displayedViewController.view.hidden = YES; - } -} - - -#pragma mark - UISearchBarDelegate -- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText -{ - if (self.displayedViewController == roomsSearchViewController) - { - // As the search is local, it can be updated on each text change - [self updateSearch]; - } -} - -- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar2 -{ - // "Done" key has been pressed - [searchBar resignFirstResponder]; -} - -- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar2 -{ - // Leave search - [searchBar resignFirstResponder]; - - // Leave this VC - [self.navigationController popViewControllerAnimated:YES]; -} -@end