diff --git a/Vector.xcodeproj/project.pbxproj b/Vector.xcodeproj/project.pbxproj index a3158e3a0..4ca2249a5 100644 --- a/Vector.xcodeproj/project.pbxproj +++ b/Vector.xcodeproj/project.pbxproj @@ -8,6 +8,9 @@ /* 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 */; }; 71046D5E1C0C639300DCA984 /* RoomTitleViewWithTopic.m in Sources */ = {isa = PBXBuildFile; fileRef = 71046D5D1C0C639300DCA984 /* RoomTitleViewWithTopic.m */; }; 71046D601C0C86C600DCA984 /* RoomTitleViewWithTopic.xib in Resources */ = {isa = PBXBuildFile; fileRef = 71046D5F1C0C86C600DCA984 /* RoomTitleViewWithTopic.xib */; }; 71352D591C10569F001D50B0 /* AvatarGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 71352D581C10569F001D50B0 /* AvatarGenerator.m */; }; @@ -136,6 +139,9 @@ 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 = ""; }; 435C7E1A9BC3DE28D526540F /* Pods-Vector.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Vector.release.xcconfig"; path = "Pods/Target Support Files/Pods-Vector/Pods-Vector.release.xcconfig"; sourceTree = ""; }; 71046D5C1C0C639300DCA984 /* RoomTitleViewWithTopic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RoomTitleViewWithTopic.h; path = RoomTitle/RoomTitleViewWithTopic.h; sourceTree = ""; }; 71046D5D1C0C639300DCA984 /* RoomTitleViewWithTopic.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RoomTitleViewWithTopic.m; path = RoomTitle/RoomTitleViewWithTopic.m; sourceTree = ""; }; @@ -607,6 +613,9 @@ F0DD7D1B1B7AA8C900C4BE02 /* Images */ = { isa = PBXGroup; children = ( + 32D200801C15C56A00A4E396 /* search_bg.png */, + 32D200811C15C56A00A4E396 /* search_bg@2x.png */, + 32D200821C15C56A00A4E396 /* search_bg@3x.png */, F02528971C11B6FC00E1FE1B /* add.png */, F02528981C11B6FC00E1FE1B /* add@2x.png */, F02528991C11B6FC00E1FE1B /* camera_capture.png */, @@ -779,6 +788,7 @@ F02529011C11B6FC00E1FE1B /* settings_icon@2x.png in Resources */, F02528F91C11B6FC00E1FE1B /* search_icon@3x.png in Resources */, F02528D31C11B6FC00E1FE1B /* add.png in Resources */, + 32D200831C15C56A00A4E396 /* search_bg.png in Resources */, F02529061C11B6FC00E1FE1B /* unmute_icon.png in Resources */, F02529041C11B6FC00E1FE1B /* typing@2x.png in Resources */, F02528D61C11B6FC00E1FE1B /* camera_capture@2x.png in Resources */, @@ -811,6 +821,7 @@ F02528E41C11B6FC00E1FE1B /* favorite_icon@2x.png in Resources */, F001D76E1B83156000A162C3 /* MediaPickerViewController.xib in Resources */, F02529031C11B6FC00E1FE1B /* typing.png in Resources */, + 32D200851C15C56A00A4E396 /* search_bg@3x.png in Resources */, 71EBE66E1C04C4D300E7D953 /* RoomActivitiesView.xib in Resources */, 717928461C03852C00407D96 /* TableViewCellSeparator.xib in Resources */, F02528ED1C11B6FC00E1FE1B /* mute_icon@2x.png in Resources */, @@ -827,6 +838,7 @@ F02528E51C11B6FC00E1FE1B /* favorite_icon@3x.png in Resources */, F02529051C11B6FC00E1FE1B /* typing@3x.png in Resources */, F02528E71C11B6FC00E1FE1B /* logo.png in Resources */, + 32D200841C15C56A00A4E396 /* search_bg@2x.png in Resources */, F094AA2C1B78E42600B1FBBF /* Vector.strings in Resources */, F02528D41C11B6FC00E1FE1B /* add@2x.png in Resources */, F02528FD1C11B6FC00E1FE1B /* selection_untick.png in Resources */, diff --git a/Vector/Assets/Images/search_bg.png b/Vector/Assets/Images/search_bg.png new file mode 100644 index 000000000..2531f48c9 Binary files /dev/null and b/Vector/Assets/Images/search_bg.png differ diff --git a/Vector/Assets/Images/search_bg@2x.png b/Vector/Assets/Images/search_bg@2x.png new file mode 100644 index 000000000..b78748b04 Binary files /dev/null and b/Vector/Assets/Images/search_bg@2x.png differ diff --git a/Vector/Assets/Images/search_bg@3x.png b/Vector/Assets/Images/search_bg@3x.png new file mode 100644 index 000000000..b42555e83 Binary files /dev/null and b/Vector/Assets/Images/search_bg@3x.png differ diff --git a/Vector/ViewController/Search/SearchViewController.m b/Vector/ViewController/Search/SearchViewController.m index 41cd796df..a3bd87717 100644 --- a/Vector/ViewController/Search/SearchViewController.m +++ b/Vector/ViewController/Search/SearchViewController.m @@ -48,6 +48,8 @@ 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]; } @@ -82,21 +84,42 @@ [self addMatrixSession:session]; } -#pragma mark - UISearchBarDelegate +- (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 - if (searchText.length) - { - [roomsSearchDataSource searchWithPatterns:@[searchText]]; - } - else - { - [roomsSearchDataSource searchWithPatterns:nil]; - } + [self updateSearch]; } }