mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Allow UICollectionViewLayout to Provide Layout Inspector, Always Update Delegate (#3003)
* Allow UICollectionViewLayout to give us a layout inspector, always call the didChangeDelegate/didChangeDataSource on binding * Make an assertion * Update the tests * Tests use actual layout inspector * Be more consistent
This commit is contained in:
@@ -533,19 +533,14 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
|
||||
- (id<ASCollectionViewLayoutInspecting>)layoutInspector
|
||||
{
|
||||
if (_layoutInspector == nil) {
|
||||
UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionViewLayout;
|
||||
UICollectionViewLayout *layout = self.collectionViewLayout;
|
||||
if (layout == nil) {
|
||||
// Layout hasn't been set yet, we're still init'ing
|
||||
return nil;
|
||||
}
|
||||
|
||||
if ([layout asdk_isFlowLayout]) {
|
||||
// Register the default layout inspector delegate for flow layouts only
|
||||
_defaultLayoutInspector = [[ASCollectionViewFlowLayoutInspector alloc] initWithCollectionView:self flowLayout:layout];
|
||||
} else {
|
||||
// Register the default layout inspector delegate for custom collection view layouts
|
||||
_defaultLayoutInspector = [[ASCollectionViewLayoutInspector alloc] initWithCollectionView:self];
|
||||
}
|
||||
|
||||
_defaultLayoutInspector = [layout asdk_layoutInspector];
|
||||
ASDisplayNodeAssertNotNil(_defaultLayoutInspector, @"You must not return nil from -asdk_layoutInspector. Return [super asdk_layoutInspector] if you have to! Layout: %@", layout);
|
||||
|
||||
// Explicitly call the setter to wire up the _layoutInspectorFlags
|
||||
self.layoutInspector = _defaultLayoutInspector;
|
||||
@@ -560,6 +555,13 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
|
||||
|
||||
_layoutInspectorFlags.didChangeCollectionViewDataSource = [_layoutInspector respondsToSelector:@selector(didChangeCollectionViewDataSource:)];
|
||||
_layoutInspectorFlags.didChangeCollectionViewDelegate = [_layoutInspector respondsToSelector:@selector(didChangeCollectionViewDelegate:)];
|
||||
|
||||
if (_layoutInspectorFlags.didChangeCollectionViewDataSource) {
|
||||
[_layoutInspector didChangeCollectionViewDataSource:self.asyncDataSource];
|
||||
}
|
||||
if (_layoutInspectorFlags.didChangeCollectionViewDelegate) {
|
||||
[_layoutInspector didChangeCollectionViewDelegate:self.asyncDelegate];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType
|
||||
|
||||
Reference in New Issue
Block a user