Merge branch 'charlesmchen/moreScrollDownButton'
This commit is contained in:
commit
d00928902f
@ -2793,6 +2793,7 @@ typedef enum : NSUInteger {
|
||||
[super viewDidLayoutSubviews];
|
||||
|
||||
[self updateLastVisibleTimestamp];
|
||||
[self ensureScrollDownButton];
|
||||
}
|
||||
|
||||
- (void)createScrollDownButton
|
||||
@ -2838,6 +2839,14 @@ typedef enum : NSUInteger {
|
||||
|
||||
BOOL shouldShowScrollDownButton = NO;
|
||||
NSUInteger numberOfMessages = [self.messageMappings numberOfItemsInSection:0];
|
||||
CGFloat scrollSpaceToBottom = (self.collectionView.contentSize.height + self.collectionView.contentInset.bottom
|
||||
- (self.collectionView.contentOffset.y + self.collectionView.frame.size.height));
|
||||
CGFloat pageHeight = (self.collectionView.frame.size.height
|
||||
- (self.collectionView.contentInset.top + self.collectionView.contentInset.bottom));
|
||||
// Show "scroll down" button if user is scrolled up at least
|
||||
// one page.
|
||||
BOOL isScrolledUp = scrollSpaceToBottom > pageHeight * 1.f;
|
||||
|
||||
if (numberOfMessages > 0) {
|
||||
TSInteraction *lastInteraction =
|
||||
[self interactionAtIndexPath:[NSIndexPath indexPathForRow:(NSInteger)numberOfMessages - 1 inSection:0]];
|
||||
@ -2845,6 +2854,8 @@ typedef enum : NSUInteger {
|
||||
|
||||
if (lastInteraction.timestampForSorting > self.lastVisibleTimestamp) {
|
||||
shouldShowScrollDownButton = YES;
|
||||
} else if (isScrolledUp) {
|
||||
shouldShowScrollDownButton = YES;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3992,7 +4003,7 @@ typedef enum : NSUInteger {
|
||||
[self presentViewController:controller animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)textViewDidChangePosition
|
||||
- (void)textViewDidChangeLayout
|
||||
{
|
||||
OWSAssert([NSThread isMainThread]);
|
||||
|
||||
@ -4006,6 +4017,8 @@ typedef enum : NSUInteger {
|
||||
userInfo:nil
|
||||
repeats:NO];
|
||||
}
|
||||
|
||||
[self ensureScrollDownButton];
|
||||
}
|
||||
|
||||
- (void)scrollToBottomImmediately
|
||||
@ -4096,6 +4109,8 @@ typedef enum : NSUInteger {
|
||||
// We want to show the "voice message" button if the text input is empty
|
||||
// and the "send" button if it isn't.
|
||||
[((OWSMessagesToolbarContentView *)self.inputToolbar.contentView)ensureEnabling];
|
||||
|
||||
[self ensureScrollDownButton];
|
||||
}
|
||||
|
||||
#pragma mark - UIScrollViewDelegate
|
||||
@ -4162,7 +4177,6 @@ typedef enum : NSUInteger {
|
||||
|
||||
#pragma mark - OWSMessagesCollectionViewFlowLayoutDelegate
|
||||
|
||||
|
||||
- (BOOL)shouldShowCellDecorationsAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TSInteraction *interaction = [self interactionAtIndexPath:indexPath];
|
||||
|
||||
@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)didPasteAttachment:(SignalAttachment *_Nullable)attachment;
|
||||
|
||||
- (void)textViewDidChangePosition;
|
||||
- (void)textViewDidChangeLayout;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
BOOL becameFirstResponder = [super becomeFirstResponder];
|
||||
if (becameFirstResponder) {
|
||||
// Intercept to scroll to bottom when text view is tapped.
|
||||
[self.textViewPasteDelegate textViewDidChangePosition];
|
||||
[self.textViewPasteDelegate textViewDidChangeLayout];
|
||||
}
|
||||
return becameFirstResponder;
|
||||
}
|
||||
@ -61,7 +61,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
[super setFrame:frame];
|
||||
|
||||
if (didChangeSize && isNonEmpty) {
|
||||
[self.textViewPasteDelegate textViewDidChangePosition];
|
||||
[self.textViewPasteDelegate textViewDidChangeLayout];
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
[super setBounds:bounds];
|
||||
|
||||
if (didChangeSize && isNonEmpty) {
|
||||
[self.textViewPasteDelegate textViewDidChangePosition];
|
||||
[self.textViewPasteDelegate textViewDidChangeLayout];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user