UX Rework - Rooms tab: Tap on the current tab's icon jumps to next unread.

This commit is contained in:
Giom Foret
2017-06-14 09:41:15 +02:00
parent 718d0847df
commit 8cd95af42c
3 changed files with 53 additions and 0 deletions
+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