mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-14 18:29:51 +00:00
Handle initial sizing delegate implementation in flow layout inspector
This commit is contained in:
parent
34f3065825
commit
8efca60bac
@ -228,12 +228,7 @@ static BOOL _isInterceptedSelector(SEL sel)
|
|||||||
|
|
||||||
// Register the default layout inspector delegate for flow layouts, custom layouts
|
// Register the default layout inspector delegate for flow layouts, custom layouts
|
||||||
// will need to roll their own ASCollectionViewLayoutInspecting implementation.
|
// will need to roll their own ASCollectionViewLayoutInspecting implementation.
|
||||||
if ([layout asdk_isFlowLayout]) {
|
_layoutDelegate = [self flowLayoutInspector];
|
||||||
_flowLayoutInspector = [[ASCollectionViewFlowLayoutInspector alloc] init];
|
|
||||||
_flowLayoutInspector.layout = (UICollectionViewFlowLayout *)layout;
|
|
||||||
_flowLayoutInspector.collectionView = self;
|
|
||||||
_layoutDelegate = _flowLayoutInspector;
|
|
||||||
}
|
|
||||||
|
|
||||||
_registeredSupplementaryKinds = [NSMutableArray array];
|
_registeredSupplementaryKinds = [NSMutableArray array];
|
||||||
|
|
||||||
@ -252,6 +247,21 @@ static BOOL _isInterceptedSelector(SEL sel)
|
|||||||
super.dataSource = nil;
|
super.dataSource = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A layout inspector implementation specific for the sizing behavior of UICollectionViewFlowLayouts
|
||||||
|
*
|
||||||
|
* @discussion Will return nil if the current layout is not a flow layout
|
||||||
|
*/
|
||||||
|
- (ASCollectionViewFlowLayoutInspector *)flowLayoutInspector
|
||||||
|
{
|
||||||
|
if (_flowLayoutInspector == nil) {
|
||||||
|
UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionViewLayout;
|
||||||
|
_flowLayoutInspector = [[ASCollectionViewFlowLayoutInspector alloc] initWithCollectionView:self
|
||||||
|
flowLayout:layout];
|
||||||
|
}
|
||||||
|
return _flowLayoutInspector;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark Overrides.
|
#pragma mark Overrides.
|
||||||
|
|
||||||
@ -326,6 +336,8 @@ static BOOL _isInterceptedSelector(SEL sel)
|
|||||||
super.delegate = (id<UICollectionViewDelegate>)_proxyDelegate;
|
super.delegate = (id<UICollectionViewDelegate>)_proxyDelegate;
|
||||||
_asyncDelegateImplementsInsetSection = ([_asyncDelegate respondsToSelector:@selector(collectionView:layout:insetForSectionAtIndex:)] ? 1 : 0);
|
_asyncDelegateImplementsInsetSection = ([_asyncDelegate respondsToSelector:@selector(collectionView:layout:insetForSectionAtIndex:)] ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_flowLayoutInspector.collectionView = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType
|
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType
|
||||||
|
|||||||
@ -33,8 +33,10 @@
|
|||||||
|
|
||||||
@interface ASCollectionViewFlowLayoutInspector : NSObject <ASCollectionViewLayoutInspecting>
|
@interface ASCollectionViewFlowLayoutInspector : NSObject <ASCollectionViewLayoutInspecting>
|
||||||
|
|
||||||
@property (nonatomic, weak) ASCollectionView *collectionView;
|
|
||||||
@property (nonatomic, weak) UICollectionViewFlowLayout *layout;
|
@property (nonatomic, weak) UICollectionViewFlowLayout *layout;
|
||||||
|
@property (nonatomic, weak) ASCollectionView *collectionView;
|
||||||
|
|
||||||
|
- (instancetype)initWithCollectionView:(ASCollectionView *)collectionView flowLayout:(UICollectionViewFlowLayout *)flowLayout;
|
||||||
|
|
||||||
- (ASSizeRange)collectionView:(ASCollectionView *)collectionView constrainedSizeForSupplementaryNodeOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath;
|
- (ASSizeRange)collectionView:(ASCollectionView *)collectionView constrainedSizeForSupplementaryNodeOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath;
|
||||||
|
|
||||||
|
|||||||
@ -19,11 +19,25 @@
|
|||||||
|
|
||||||
#pragma mark - Accessors
|
#pragma mark - Accessors
|
||||||
|
|
||||||
- (void)setLayout:(UICollectionViewFlowLayout *)layout
|
- (instancetype)initWithCollectionView:(ASCollectionView *)collectionView flowLayout:(UICollectionViewFlowLayout *)flowLayout
|
||||||
{
|
{
|
||||||
_layout = layout;
|
if (flowLayout == nil) {
|
||||||
_delegateImplementsReferenceSizeForHeader = [[self layoutDelegate] respondsToSelector:@selector(collectionView:layout:referenceSizeForHeaderInSection:)];
|
return nil;
|
||||||
_delegateImplementsReferenceSizeForFooter = [[self layoutDelegate] respondsToSelector:@selector(collectionView:layout:referenceSizeForFooterInSection:)];
|
}
|
||||||
|
|
||||||
|
self = [super init];
|
||||||
|
if (self != nil) {
|
||||||
|
self.collectionView = collectionView;
|
||||||
|
_layout = flowLayout;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setCollectionView:(ASCollectionView *)collectionView
|
||||||
|
{
|
||||||
|
_collectionView = collectionView;
|
||||||
|
_delegateImplementsReferenceSizeForHeader = [[self layoutDelegate] respondsToSelector:@selector(collectionView:layout:referenceSizeForHeaderInSection:)];
|
||||||
|
_delegateImplementsReferenceSizeForFooter = [[self layoutDelegate] respondsToSelector:@selector(collectionView:layout:referenceSizeForFooterInSection:)];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - ASCollectionViewLayoutInspecting
|
#pragma mark - ASCollectionViewLayoutInspecting
|
||||||
@ -94,9 +108,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id<UICollectionViewDelegateFlowLayout>)layoutDelegate
|
- (id<ASCollectionViewDelegateFlowLayout>)layoutDelegate
|
||||||
{
|
{
|
||||||
return (id<UICollectionViewDelegateFlowLayout>)self.collectionView.delegate;
|
return (id<ASCollectionViewDelegateFlowLayout>)_collectionView.asyncDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user