Public rooms search: Automatically scroll to the top on each new seach

This commit is contained in:
manuroe
2015-12-21 11:13:46 +01:00
parent 68fd187509
commit 6ff5cadfee
4 changed files with 27 additions and 27 deletions
+12 -4
View File
@@ -680,11 +680,19 @@
{
[super searchWithPatterns:patternsList];
if (patternsList && _publicRoomsDirectoryDataSource)
if (_publicRoomsDirectoryDataSource)
{
// Search only on the first pattern
// XXX: Why is it an array?
_publicRoomsDirectoryDataSource.filter = patternsList[0];
if (patternsList)
{
// Search only on the first pattern
// XXX: Why is it an array?
_publicRoomsDirectoryDataSource.filter = patternsList[0];
}
else
{
_publicRoomsDirectoryDataSource.filter = nil; // = patternsList
}
}
}
@@ -490,12 +490,19 @@
if (self.selectedViewController == recentsViewController)
{
[recentsDataSource searchWithPatterns:@[searchBar.text]];
recentsViewController.shouldScrollToTopOnRefresh = YES;
}
}
else
{
// Nothing to search = Show nothing
self.selectedViewController.view.hidden = YES;
if (self.selectedViewController == recentsViewController)
{
[recentsDataSource searchWithPatterns:nil];
recentsViewController.shouldScrollToTopOnRefresh = YES;
}
}
}
@@ -20,6 +20,12 @@
@interface RecentsViewController : MXKRecentListViewController
/**
If YES, the table view will scroll at the top on the next data source refresh.
It comes back to NO after each refresh.
*/
@property (nonatomic) BOOL shouldScrollToTopOnRefresh;
/**
Display the recents described in the provided data source.
+2 -23
View File
@@ -32,9 +32,6 @@
@interface RecentsViewController ()
{
// Recents refresh handling
BOOL shouldScrollToTopOnRefresh;
// The "parent" segmented view controller
HomeViewController *homeViewController;
@@ -254,10 +251,10 @@
[self.recentsTableView reloadData];
if (shouldScrollToTopOnRefresh)
if (_shouldScrollToTopOnRefresh)
{
[self scrollToTop];
shouldScrollToTopOnRefresh = NO;
_shouldScrollToTopOnRefresh = NO;
}
// In case of split view controller where the primary and secondary view controllers are displayed side-by-side on screen,
@@ -432,24 +429,6 @@ static NSMutableDictionary* backgroundByImageNameDict;
[self.recentsTableView setEditing:NO];
}
#pragma mark - Override UISearchBarDelegate
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
// Prepare table refresh on new search session
shouldScrollToTopOnRefresh = YES;
[super searchBar:searchBar textDidChange:searchText];
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
// Prepare table refresh on end of search
shouldScrollToTopOnRefresh = YES;
[super searchBarCancelButtonClicked: searchBar];
}
#pragma mark - UITableView delegate
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section