mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Improve Our Handling of Flow Layout Headers/Footers (#2939)
* Rejigger our flow layout supplementary support to make more sense. * Support old protocol * Update * Update deprecation message * Undeprecate insetForSection method, because it actually _does_ still work * Update the tests * Remove irrelevant junk * Remove cast, add pragma
This commit is contained in:
@@ -29,7 +29,7 @@ static const NSInteger kBatchSize = 20;
|
||||
static const CGFloat kHorizontalSectionPadding = 10.0f;
|
||||
static const CGFloat kVerticalSectionPadding = 20.0f;
|
||||
|
||||
@interface ViewController () <ASCollectionDataSource, ASCollectionDelegate, ASCollectionViewDelegateFlowLayout>
|
||||
@interface ViewController () <ASCollectionDataSource, ASCollectionDelegate, ASCollectionDelegateFlowLayout>
|
||||
{
|
||||
ASCollectionNode *_collectionNode;
|
||||
NSMutableArray *_data;
|
||||
@@ -203,27 +203,24 @@ static const CGFloat kVerticalSectionPadding = 20.0f;
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - ASCollectionViewDelegateFlowLayout
|
||||
#pragma mark - ASCollectionDelegateFlowLayout
|
||||
|
||||
- (UIEdgeInsets)collectionView:(ASCollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
|
||||
return UIEdgeInsetsMake(kVerticalSectionPadding, kHorizontalSectionPadding, kVerticalSectionPadding, kHorizontalSectionPadding);
|
||||
}
|
||||
|
||||
- (CGSize)collectionView:(ASCollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
|
||||
- (ASSizeRange)collectionNode:(ASCollectionNode *)collectionNode referenceConstrainedSizeForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
if (section == 0) {
|
||||
CGFloat width = CGRectGetWidth(self.view.frame) - 2 * kHorizontalSectionPadding;
|
||||
return CGSizeMake(width, [BlurbNode desiredHeightForWidth:width]);
|
||||
return ASSizeRangeUnconstrained;
|
||||
} else {
|
||||
return ASSizeRangeZero;
|
||||
}
|
||||
return CGSizeZero;
|
||||
}
|
||||
|
||||
- (CGSize)collectionView:(ASCollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
|
||||
- (ASSizeRange)collectionNode:(ASCollectionNode *)collectionNode referenceConstrainedSizeForFooterInSection:(NSInteger)section
|
||||
{
|
||||
if (section == 0) {
|
||||
CGFloat width = CGRectGetWidth(self.view.frame);
|
||||
return CGSizeMake(width, [LoadingNode desiredHeightForWidth:width]);
|
||||
return ASSizeRangeUnconstrained;
|
||||
} else {
|
||||
return ASSizeRangeZero;
|
||||
}
|
||||
return CGSizeZero;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user