mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-08 13:42:51 +00:00
[Table and collection views] Consider content inset when calculating (default) element size range (#525)
* Table and collection views to consider their content inset when calculating element size range * Update CHANGELOG * Address comments * -[ASPagerNode currentPageIndex] to use pageSize instead of bounds * Update documentation in ASPagerNode * Minor change
This commit is contained in:
parent
359b5f0b5b
commit
884a4f56f1
@ -11,6 +11,7 @@
|
|||||||
- Remove re-entrant access to self.view when applying initial pending state. [Adlai Holler](https://github.com/Adlai-Holler) [#510](https://github.com/TextureGroup/Texture/pull/510)
|
- Remove re-entrant access to self.view when applying initial pending state. [Adlai Holler](https://github.com/Adlai-Holler) [#510](https://github.com/TextureGroup/Texture/pull/510)
|
||||||
- Small improvements in ASCollectionLayout [Huy Nguyen](https://github.com/nguyenhuy) [#509](https://github.com/TextureGroup/Texture/pull/509) [#513](https://github.com/TextureGroup/Texture/pull/513)
|
- Small improvements in ASCollectionLayout [Huy Nguyen](https://github.com/nguyenhuy) [#509](https://github.com/TextureGroup/Texture/pull/509) [#513](https://github.com/TextureGroup/Texture/pull/513)
|
||||||
- Fix retain cycle between ASImageNode and PINAnimatedImage [Phil Larson](https://github.com/plarson) [#520](https://github.com/TextureGroup/Texture/pull/520)
|
- Fix retain cycle between ASImageNode and PINAnimatedImage [Phil Larson](https://github.com/plarson) [#520](https://github.com/TextureGroup/Texture/pull/520)
|
||||||
|
- Table and collection views to consider content inset when calculating (default) element size range [Huy Nguyen](https://github.com/nguyenhuy) [#525](https://github.com/TextureGroup/Texture/pull/525)
|
||||||
|
|
||||||
##2.4
|
##2.4
|
||||||
- Fix an issue where inserting/deleting sections could lead to inconsistent supplementary element behavior. [Adlai Holler](https://github.com/Adlai-Holler)
|
- Fix an issue where inserting/deleting sections could lead to inconsistent supplementary element behavior. [Adlai Holler](https://github.com/Adlai-Holler)
|
||||||
|
@ -1536,10 +1536,6 @@ minimumLineSpacingForSectionAtIndex:(NSInteger)section
|
|||||||
return [self.layoutInspector scrollableDirections];
|
return [self.layoutInspector scrollableDirections];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ASScrollDirection)flowLayoutScrollableDirections:(UICollectionViewFlowLayout *)flowLayout {
|
|
||||||
return (flowLayout.scrollDirection == UICollectionViewScrollDirectionHorizontal) ? ASScrollDirectionHorizontalDirections : ASScrollDirectionVerticalDirections;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)layoutSubviews
|
- (void)layoutSubviews
|
||||||
{
|
{
|
||||||
if (_cellsForLayoutUpdates.count > 0) {
|
if (_cellsForLayoutUpdates.count > 0) {
|
||||||
|
@ -75,6 +75,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A horizontal, paging collection node.
|
||||||
|
*/
|
||||||
@interface ASPagerNode : ASCollectionNode
|
@interface ASPagerNode : ASCollectionNode
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,6 +87,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializer with custom-configured flow layout properties.
|
* Initializer with custom-configured flow layout properties.
|
||||||
|
*
|
||||||
|
* NOTE: The flow layout must have a horizontal scroll direction.
|
||||||
*/
|
*/
|
||||||
- (instancetype)initWithCollectionViewLayout:(ASPagerFlowLayout *)flowLayout;
|
- (instancetype)initWithCollectionViewLayout:(ASPagerFlowLayout *)flowLayout;
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@
|
|||||||
- (instancetype)initWithCollectionViewLayout:(ASPagerFlowLayout *)flowLayout;
|
- (instancetype)initWithCollectionViewLayout:(ASPagerFlowLayout *)flowLayout;
|
||||||
{
|
{
|
||||||
ASDisplayNodeAssert([flowLayout isKindOfClass:[ASPagerFlowLayout class]], @"ASPagerNode requires a flow layout.");
|
ASDisplayNodeAssert([flowLayout isKindOfClass:[ASPagerFlowLayout class]], @"ASPagerNode requires a flow layout.");
|
||||||
|
ASDisplayNodeAssertTrue(flowLayout.scrollDirection == UICollectionViewScrollDirectionHorizontal);
|
||||||
self = [super initWithCollectionViewLayout:flowLayout];
|
self = [super initWithCollectionViewLayout:flowLayout];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -112,7 +113,15 @@
|
|||||||
|
|
||||||
- (NSInteger)currentPageIndex
|
- (NSInteger)currentPageIndex
|
||||||
{
|
{
|
||||||
return (self.view.contentOffset.x / CGRectGetWidth(self.view.bounds));
|
return (self.view.contentOffset.x / [self pageSize].width);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CGSize)pageSize
|
||||||
|
{
|
||||||
|
UIEdgeInsets contentInset = self.view.contentInset;
|
||||||
|
CGSize pageSize = self.bounds.size;
|
||||||
|
pageSize.height -= (contentInset.top + contentInset.bottom);
|
||||||
|
return pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Helpers
|
#pragma mark - Helpers
|
||||||
@ -142,7 +151,7 @@
|
|||||||
- (CGSize)sizeForElements:(ASElementMap *)elements
|
- (CGSize)sizeForElements:(ASElementMap *)elements
|
||||||
{
|
{
|
||||||
ASDisplayNodeAssertMainThread();
|
ASDisplayNodeAssertMainThread();
|
||||||
return self.bounds.size;
|
return [self pageSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - ASCollectionDataSource
|
#pragma mark - ASCollectionDataSource
|
||||||
@ -179,7 +188,7 @@
|
|||||||
}
|
}
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
return ASSizeRangeMake(self.bounds.size);
|
return ASSizeRangeMake([self pageSize]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Data Source Proxy
|
#pragma mark - Data Source Proxy
|
||||||
|
@ -751,7 +751,8 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
|||||||
{
|
{
|
||||||
// Remeasure all rows if our row width has changed.
|
// Remeasure all rows if our row width has changed.
|
||||||
_remeasuringCellNodes = YES;
|
_remeasuringCellNodes = YES;
|
||||||
CGFloat constrainedWidth = self.bounds.size.width - [self sectionIndexWidth];
|
UIEdgeInsets contentInset = self.contentInset;
|
||||||
|
CGFloat constrainedWidth = self.bounds.size.width - [self sectionIndexWidth] - contentInset.left - contentInset.right;
|
||||||
if (constrainedWidth > 0 && _nodesConstrainedWidth != constrainedWidth) {
|
if (constrainedWidth > 0 && _nodesConstrainedWidth != constrainedWidth) {
|
||||||
_nodesConstrainedWidth = constrainedWidth;
|
_nodesConstrainedWidth = constrainedWidth;
|
||||||
|
|
||||||
|
@ -27,9 +27,12 @@
|
|||||||
// of the collection view
|
// of the collection view
|
||||||
ASSizeRange NodeConstrainedSizeForScrollDirection(ASCollectionView *collectionView) {
|
ASSizeRange NodeConstrainedSizeForScrollDirection(ASCollectionView *collectionView) {
|
||||||
CGSize maxSize = collectionView.bounds.size;
|
CGSize maxSize = collectionView.bounds.size;
|
||||||
|
UIEdgeInsets contentInset = collectionView.contentInset;
|
||||||
if (ASScrollDirectionContainsHorizontalDirection(collectionView.scrollableDirections)) {
|
if (ASScrollDirectionContainsHorizontalDirection(collectionView.scrollableDirections)) {
|
||||||
maxSize.width = CGFLOAT_MAX;
|
maxSize.width = CGFLOAT_MAX;
|
||||||
|
maxSize.height -= (contentInset.top + contentInset.bottom);
|
||||||
} else {
|
} else {
|
||||||
|
maxSize.width -= (contentInset.left + contentInset.right);
|
||||||
maxSize.height = CGFLOAT_MAX;
|
maxSize.height = CGFLOAT_MAX;
|
||||||
}
|
}
|
||||||
return ASSizeRangeMake(CGSizeZero, maxSize);
|
return ASSizeRangeMake(CGSizeZero, maxSize);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user