Fix conversation view content offset and scroll down button layout.

pull/2/head
Matthew Chen 6 years ago
parent f50ec07248
commit 3b008ad963

@ -1272,6 +1272,7 @@ typedef enum : NSUInteger {
self.actionOnOpen = ConversationViewActionNone; self.actionOnOpen = ConversationViewActionNone;
[self updateInputToolbarLayout]; [self updateInputToolbarLayout];
[self ensureScrollDownButton];
} }
// `viewWillDisappear` is called whenever the view *starts* to disappear, // `viewWillDisappear` is called whenever the view *starts* to disappear,
@ -2500,7 +2501,7 @@ typedef enum : NSUInteger {
// The "scroll down" button layout tracks the content inset of the collection view, // The "scroll down" button layout tracks the content inset of the collection view,
// so pin to the edge of the collection view. // so pin to the edge of the collection view.
self.scrollDownButtonButtomConstraint = self.scrollDownButtonButtomConstraint =
[self.scrollDownButton autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.collectionView]; [self.scrollDownButton autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.view];
[self.scrollDownButton autoPinEdgeToSuperviewSafeArea:ALEdgeTrailing]; [self.scrollDownButton autoPinEdgeToSuperviewSafeArea:ALEdgeTrailing];
#ifdef DEBUG #ifdef DEBUG
@ -2520,7 +2521,9 @@ typedef enum : NSUInteger {
- (void)updateScrollDownButtonLayout - (void)updateScrollDownButtonLayout
{ {
self.scrollDownButtonButtomConstraint.constant = -1 * self.collectionView.contentInset.bottom; CGFloat inset = -(self.collectionView.contentInset.bottom + self.bottomLayoutGuide.length);
self.scrollDownButtonButtomConstraint.constant = inset;
[self.view setNeedsLayout];
} }
- (void)setHasUnreadMessages:(BOOL)hasUnreadMessages - (void)setHasUnreadMessages:(BOOL)hasUnreadMessages
@ -2593,20 +2596,11 @@ typedef enum : NSUInteger {
} }
} }
if (shouldShowScrollDownButton) { self.scrollDownButton.hidden = !shouldShowScrollDownButton;
self.scrollDownButton.hidden = NO;
} else {
self.scrollDownButton.hidden = YES;
}
#ifdef DEBUG #ifdef DEBUG
BOOL shouldShowScrollUpButton = self.collectionView.contentOffset.y > 0; BOOL shouldShowScrollUpButton = self.collectionView.contentOffset.y > 0;
if (shouldShowScrollUpButton) { self.scrollUpButton.hidden = !shouldShowScrollUpButton;
self.scrollUpButton.hidden = NO;
} else {
self.scrollUpButton.hidden = YES;
}
#endif #endif
} }
@ -3794,9 +3788,7 @@ typedef enum : NSUInteger {
// //
// Always reserve room for the input accessory, which we display even // Always reserve room for the input accessory, which we display even
// if the keyboard is not active. // if the keyboard is not active.
newInsets.bottom = MAX(0, newInsets.bottom = MAX(0, self.view.height - self.bottomLayoutGuide.length - keyboardEndFrameConverted.origin.y);
MAX(self.view.height - self.bottomLayoutGuide.length - keyboardEndFrameConverted.origin.y,
self.inputToolbar.height));
BOOL wasScrolledToBottom = [self isScrolledToBottom]; BOOL wasScrolledToBottom = [self isScrolledToBottom];

Loading…
Cancel
Save