Merge pull request #1287 from vector-im/scroll_to_unread_on_rooms_tab_tap

UX Rework - Rooms tab: Tap on the current tab's icon jumps to next un…
This commit is contained in:
giomfo
2017-06-14 10:35:53 +02:00
committed by GitHub
3 changed files with 53 additions and 0 deletions
@@ -674,4 +674,15 @@
[currentAlert showInViewController:self];
}
#pragma mark - UITabBarDelegate
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
if (item.tag == TABBAR_ROOMS_INDEX && self.selectedIndex == TABBAR_ROOMS_INDEX)
{
// Scroll to the next room with missed notifications.
[self.roomsViewController scrollToNextRoomWithMissedNotifications];
}
}
@end
@@ -21,4 +21,10 @@
*/
@interface RoomsViewController : RecentsViewController
/**
Scroll to the potential room with missed notifications which is not visible yet.
*/
- (void)scrollToNextRoomWithMissedNotifications;
@end
+36
View File
@@ -125,6 +125,42 @@
}
}
#pragma mark -
- (void)scrollToNextRoomWithMissedNotifications
{
// Check whether the recents data source is correctly configured.
if (recentsDataSource.recentsDataSourceMode != RecentsDataSourceModeRooms)
{
return;
}
NSIndexPath *lastVisibleIndexPath = self.recentsTableView.indexPathsForVisibleRows.lastObject;
if (lastVisibleIndexPath.section == recentsDataSource.conversationSection)
{
// Look for the next room with missed notifications.
NSIndexPath *nextIndexPath = [NSIndexPath indexPathForRow:lastVisibleIndexPath.row + 1 inSection:recentsDataSource.conversationSection];
id<MXKRecentCellDataStoring> cellData = [recentsDataSource cellDataAtIndexPath:nextIndexPath];
while (cellData)
{
if (cellData.notificationCount)
{
[self.recentsTableView scrollToRowAtIndexPath:nextIndexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
break;
}
nextIndexPath = [NSIndexPath indexPathForRow:nextIndexPath.row + 1 inSection:recentsDataSource.conversationSection];
cellData = [recentsDataSource cellDataAtIndexPath:nextIndexPath];
}
if (!cellData)
{
// Scroll back to the top.
[self.recentsTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:recentsDataSource.conversationSection] atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
}
}
#pragma mark - Navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender