mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
[ASCollectionView] Improve interop to silence invalid layout warnings, fix supplementary passthrough. (#3178)
* [ASCollectionView] Improve interop to silence invalid layout warnings, fix supplementary passthrough. Before this change, passthrough of supplementary elements didn't work properly -- it would get rehosted into the blank ASCellNode. * [ASCollectionView] Ensure that IGListKit-handled supplementary views are sent through ASRangeController. * [ASCellNode] When .shouldUseUIKitCell == YES, don't remove the subviews of the .contentView
This commit is contained in:
@@ -924,7 +924,9 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
|
||||
ASCellNode *cell = [self nodeForItemAtIndexPath:indexPath];
|
||||
if (cell.shouldUseUIKitCell) {
|
||||
if ([_asyncDelegate respondsToSelector:@selector(collectionView:layout:sizeForItemAtIndexPath:)]) {
|
||||
return [(id)_asyncDelegate collectionView:collectionView layout:collectionViewLayout sizeForItemAtIndexPath:indexPath];
|
||||
CGSize size = [(id)_asyncDelegate collectionView:collectionView layout:collectionViewLayout sizeForItemAtIndexPath:indexPath];
|
||||
cell.style.preferredSize = size;
|
||||
return size;
|
||||
}
|
||||
}
|
||||
ASCollectionElement *e = [_dataController.visibleMap elementForItemAtIndexPath:indexPath];
|
||||
@@ -972,13 +974,11 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
|
||||
|
||||
BOOL shouldDequeueExternally = _asyncDataSourceFlags.interopViewForSupplementaryElement && (_asyncDataSourceFlags.interopAlwaysDequeue || node.shouldUseUIKitCell);
|
||||
if (shouldDequeueExternally) {
|
||||
// This codepath is used for both IGListKit mode, and app-level UICollectionView interop.
|
||||
view = [(id<ASCollectionDataSourceInterop>)_asyncDataSource collectionView:collectionView viewForSupplementaryElementOfKind:kind atIndexPath:indexPath];
|
||||
} else {
|
||||
view = [self dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:kReuseIdentifier forIndexPath:indexPath];
|
||||
}
|
||||
|
||||
if (!node.shouldUseUIKitCell) {
|
||||
ASDisplayNodeAssert(node != nil, @"Supplementary node should exist. Kind = %@, indexPath = %@, collectionDataSource = %@", kind, indexPath, self);
|
||||
view = [self dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:kReuseIdentifier forIndexPath:indexPath];
|
||||
}
|
||||
|
||||
if (node) {
|
||||
|
||||
Reference in New Issue
Block a user