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:
Adlai Holler
2017-01-27 15:58:43 -08:00
committed by GitHub
parent 7d68ce33bb
commit 295ed22c23
13 changed files with 156 additions and 108 deletions

View File

@@ -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