mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
ScrollToBottom accounts for top inset
// FREEBIE
This commit is contained in:
parent
4ee4df631c
commit
0847c0bafb
|
@ -4286,13 +4286,27 @@ typedef enum : NSUInteger {
|
||||||
// we use the collectionView bounds to determine where the "bottom" is.
|
// we use the collectionView bounds to determine where the "bottom" is.
|
||||||
[self.view layoutIfNeeded];
|
[self.view layoutIfNeeded];
|
||||||
|
|
||||||
CGFloat contentHeight = self.safeContentHeight;
|
const CGFloat topInset = ^{
|
||||||
|
if (@available(iOS 11, *)) {
|
||||||
|
return -self.collectionView.adjustedContentInset.top;
|
||||||
|
} else {
|
||||||
|
return -self.collectionView.contentInset.top;
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
// bottomLayoutGuide accounts for extra offset needed on iPhoneX
|
const CGFloat bottomInset = ^{
|
||||||
|
if (@available(iOS 11, *)) {
|
||||||
|
return -self.collectionView.adjustedContentInset.bottom;
|
||||||
|
} else {
|
||||||
|
return -self.collectionView.contentInset.bottom;
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
CGFloat dstY = MAX(0,
|
const CGFloat firstContentPageTop = topInset;
|
||||||
contentHeight + self.collectionView.contentInset.bottom + self.bottomLayoutGuide.length
|
const CGFloat collectionViewUnobscuredHeight = self.collectionView.bounds.size.height + bottomInset;
|
||||||
- self.collectionView.bounds.size.height);
|
const CGFloat lastContentPageTop = self.safeContentHeight - collectionViewUnobscuredHeight;
|
||||||
|
|
||||||
|
CGFloat dstY = MAX(firstContentPageTop, lastContentPageTop);
|
||||||
|
|
||||||
[self.collectionView setContentOffset:CGPointMake(0, dstY) animated:NO];
|
[self.collectionView setContentOffset:CGPointMake(0, dstY) animated:NO];
|
||||||
[self didScrollToBottom];
|
[self didScrollToBottom];
|
||||||
|
|
Loading…
Reference in a new issue