Scroll down button scrolls to unread

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent ed0e0fadcd
commit 370364c936

@ -2271,6 +2271,28 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
- (void)scrollDownButtonTapped - (void)scrollDownButtonTapped
{ {
NSIndexPath *indexPathOfUnreadMessagesIndicator = [self indexPathOfUnreadMessagesIndicator];
if (indexPathOfUnreadMessagesIndicator != nil) {
NSInteger unreadRow = indexPathOfUnreadMessagesIndicator.row;
BOOL isScrolledAboveUnreadIndicator = YES;
NSArray<NSIndexPath *> *visibleIndices = self.collectionView.indexPathsForVisibleItems;
for (NSIndexPath *indexPath in visibleIndices) {
if (indexPath.row > unreadRow) {
isScrolledAboveUnreadIndicator = NO;
break;
}
}
if (isScrolledAboveUnreadIndicator) {
// Only scroll as far as the unread indicator if we're scrolled above the unread indicator.
[[self collectionView] scrollToItemAtIndexPath:indexPathOfUnreadMessagesIndicator
atScrollPosition:UICollectionViewScrollPositionTop
animated:YES];
return;
}
}
[self scrollToBottomAnimated:YES]; [self scrollToBottomAnimated:YES];
} }

Loading…
Cancel
Save