mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Improvements for automatic range mode
- Only update range mode if visibility changes if the node is not range controlled - Only change explicitly set range mode if ASRangeController becomes visible - Return interface state for range controller in ASCollectionView and ASTableView based on if the containing node is range managed
This commit is contained in:
@@ -918,14 +918,15 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
||||
- (ASInterfaceState)interfaceStateForRangeController:(ASRangeController *)rangeController
|
||||
{
|
||||
ASCollectionNode *collectionNode = self.collectionNode;
|
||||
if (collectionNode) {
|
||||
if (collectionNode && [collectionNode supportsRangeManagedInterfaceState]) {
|
||||
// Only use the interfaceStatate of nodes that are range managed
|
||||
return collectionNode.interfaceState;
|
||||
} else {
|
||||
// Until we can always create an associated ASCollectionNode without a retain cycle,
|
||||
// we might be on our own to try to guess if we're visible. The node normally
|
||||
// handles this even if it is the root / directly added to the view hierarchy.
|
||||
return (self.window != nil ? ASInterfaceStateVisible : ASInterfaceStateNone);
|
||||
}
|
||||
|
||||
// For not range managed nodes or until we can always create an associated ASCollectionNode
|
||||
// without a retain cycle, we might be on our own to try to guess if we're visible. The node normally
|
||||
// handles this even if it is the root / directly added to the view hierarchy.
|
||||
return (self.window != nil ? ASInterfaceStateVisible : ASInterfaceStateNone);
|
||||
}
|
||||
|
||||
- (NSArray *)rangeController:(ASRangeController *)rangeController nodesAtIndexPaths:(NSArray *)indexPaths
|
||||
@@ -1144,9 +1145,12 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
||||
if (!visible && node.inHierarchy) {
|
||||
[node __exitHierarchy];
|
||||
}
|
||||
|
||||
// Trigger updating interfaceState for cells in case ASCollectionView becomes visible or invisible
|
||||
[_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:self.scrollDirection];
|
||||
|
||||
// Updating the visible node index paths only for range managed nodes. Not range managed nodes will get their
|
||||
// their update in the layout pass
|
||||
if (![node supportsRangeManagedInterfaceState]) {
|
||||
[_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:self.scrollDirection];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UICollectionView dead-end intercepts
|
||||
|
||||
Reference in New Issue
Block a user