mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Pass the cell node through in willDisplay: table/collection callbacks (#2282)
This commit is contained in:
@@ -443,17 +443,18 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
- (ASSizeRange)collectionView:(ASCollectionView *)collectionView constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath;
|
- (ASSizeRange)collectionView:(ASCollectionView *)collectionView constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Informs the delegate that the collection view will add the node
|
* Informs the delegate that the collection view will add the given node
|
||||||
* at the given index path to the view hierarchy.
|
* at the given index path to the view hierarchy.
|
||||||
*
|
*
|
||||||
* @param collectionView The sender.
|
* @param collectionView The sender.
|
||||||
|
* @param node The node that will be displayed.
|
||||||
* @param indexPath The index path of the item that will be displayed.
|
* @param indexPath The index path of the item that will be displayed.
|
||||||
*
|
*
|
||||||
* @warning AsyncDisplayKit processes collection view edits asynchronously. The index path
|
* @warning AsyncDisplayKit processes collection view edits asynchronously. The index path
|
||||||
* passed into this method may not correspond to the same item in your data source
|
* passed into this method may not correspond to the same item in your data source
|
||||||
* if your data source has been updated since the last edit was processed.
|
* if your data source has been updated since the last edit was processed.
|
||||||
*/
|
*/
|
||||||
- (void)collectionView:(ASCollectionView *)collectionView willDisplayNodeForItemAtIndexPath:(NSIndexPath *)indexPath;
|
- (void)collectionView:(ASCollectionView *)collectionView willDisplayNode:(ASCellNode *)node forItemAtIndexPath:(NSIndexPath *)indexPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Informs the delegate that the collection view did remove the provided node from the view hierarchy.
|
* Informs the delegate that the collection view did remove the provided node from the view hierarchy.
|
||||||
@@ -510,6 +511,21 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
*/
|
*/
|
||||||
- (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNodeForItemAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED;
|
- (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNodeForItemAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Informs the delegate that the collection view will add the node
|
||||||
|
* at the given index path to the view hierarchy.
|
||||||
|
*
|
||||||
|
* @param collectionView The sender.
|
||||||
|
* @param indexPath The index path of the item that will be displayed.
|
||||||
|
*
|
||||||
|
* @warning AsyncDisplayKit processes collection view edits asynchronously. The index path
|
||||||
|
* passed into this method may not correspond to the same item in your data source
|
||||||
|
* if your data source has been updated since the last edit was processed.
|
||||||
|
*
|
||||||
|
* This method is deprecated. Use @c collectionView:willDisplayNode:forItemAtIndexPath: instead.
|
||||||
|
*/
|
||||||
|
- (void)collectionView:(ASCollectionView *)collectionView willDisplayNodeForItemAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
|||||||
unsigned int asyncDelegateScrollViewDidEndDragging:1;
|
unsigned int asyncDelegateScrollViewDidEndDragging:1;
|
||||||
unsigned int asyncDelegateScrollViewWillEndDraggingWithVelocityTargetContentOffset:1;
|
unsigned int asyncDelegateScrollViewWillEndDraggingWithVelocityTargetContentOffset:1;
|
||||||
unsigned int asyncDelegateCollectionViewWillDisplayNodeForItemAtIndexPath:1;
|
unsigned int asyncDelegateCollectionViewWillDisplayNodeForItemAtIndexPath:1;
|
||||||
|
unsigned int asyncDelegateCollectionViewWillDisplayNodeForItemAtIndexPathDeprecated:1;
|
||||||
unsigned int asyncDelegateCollectionViewDidEndDisplayingNodeForItemAtIndexPath:1;
|
unsigned int asyncDelegateCollectionViewDidEndDisplayingNodeForItemAtIndexPath:1;
|
||||||
unsigned int asyncDelegateCollectionViewDidEndDisplayingNodeForItemAtIndexPathDeprecated:1;
|
unsigned int asyncDelegateCollectionViewDidEndDisplayingNodeForItemAtIndexPathDeprecated:1;
|
||||||
unsigned int asyncDelegateCollectionViewWillBeginBatchFetchWithContext:1;
|
unsigned int asyncDelegateCollectionViewWillBeginBatchFetchWithContext:1;
|
||||||
@@ -385,7 +386,10 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
|||||||
|
|
||||||
_asyncDelegateFlags.asyncDelegateScrollViewDidScroll = [_asyncDelegate respondsToSelector:@selector(scrollViewDidScroll:)];
|
_asyncDelegateFlags.asyncDelegateScrollViewDidScroll = [_asyncDelegate respondsToSelector:@selector(scrollViewDidScroll:)];
|
||||||
_asyncDelegateFlags.asyncDelegateScrollViewWillEndDraggingWithVelocityTargetContentOffset = [_asyncDelegate respondsToSelector:@selector(scrollViewWillEndDragging:withVelocity:targetContentOffset:)];
|
_asyncDelegateFlags.asyncDelegateScrollViewWillEndDraggingWithVelocityTargetContentOffset = [_asyncDelegate respondsToSelector:@selector(scrollViewWillEndDragging:withVelocity:targetContentOffset:)];
|
||||||
_asyncDelegateFlags.asyncDelegateCollectionViewWillDisplayNodeForItemAtIndexPath = [_asyncDelegate respondsToSelector:@selector(collectionView:willDisplayNodeForItemAtIndexPath:)];
|
_asyncDelegateFlags.asyncDelegateCollectionViewWillDisplayNodeForItemAtIndexPath = [_asyncDelegate respondsToSelector:@selector(collectionView:willDisplayNode:forItemAtIndexPath:)];
|
||||||
|
if (_asyncDelegateFlags.asyncDelegateCollectionViewWillDisplayNodeForItemAtIndexPath == NO) {
|
||||||
|
_asyncDelegateFlags.asyncDelegateCollectionViewWillDisplayNodeForItemAtIndexPathDeprecated = [_asyncDelegate respondsToSelector:@selector(collectionView:willDisplayNodeForItemAtIndexPath:)];
|
||||||
|
}
|
||||||
_asyncDelegateFlags.asyncDelegateCollectionViewDidEndDisplayingNodeForItemAtIndexPathDeprecated = [_asyncDelegate respondsToSelector:@selector(collectionView:didEndDisplayingNodeForItemAtIndexPath:)];
|
_asyncDelegateFlags.asyncDelegateCollectionViewDidEndDisplayingNodeForItemAtIndexPathDeprecated = [_asyncDelegate respondsToSelector:@selector(collectionView:didEndDisplayingNodeForItemAtIndexPath:)];
|
||||||
_asyncDelegateFlags.asyncDelegateCollectionViewDidEndDisplayingNodeForItemAtIndexPath = [_asyncDelegate respondsToSelector:@selector(collectionView:didEndDisplayingNode:forItemAtIndexPath:)];
|
_asyncDelegateFlags.asyncDelegateCollectionViewDidEndDisplayingNodeForItemAtIndexPath = [_asyncDelegate respondsToSelector:@selector(collectionView:didEndDisplayingNode:forItemAtIndexPath:)];
|
||||||
_asyncDelegateFlags.asyncDelegateCollectionViewWillBeginBatchFetchWithContext = [_asyncDelegate respondsToSelector:@selector(collectionView:willBeginBatchFetchWithContext:)];
|
_asyncDelegateFlags.asyncDelegateCollectionViewWillBeginBatchFetchWithContext = [_asyncDelegate respondsToSelector:@selector(collectionView:willBeginBatchFetchWithContext:)];
|
||||||
@@ -675,9 +679,16 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
|||||||
ASCellNode *cellNode = [cell node];
|
ASCellNode *cellNode = [cell node];
|
||||||
cellNode.scrollView = collectionView;
|
cellNode.scrollView = collectionView;
|
||||||
|
|
||||||
|
ASDisplayNodeAssertNotNil(cellNode, @"Expected node associated with cell that will be displayed not to be nil. indexPath: %@", indexPath);
|
||||||
|
|
||||||
if (_asyncDelegateFlags.asyncDelegateCollectionViewWillDisplayNodeForItemAtIndexPath) {
|
if (_asyncDelegateFlags.asyncDelegateCollectionViewWillDisplayNodeForItemAtIndexPath) {
|
||||||
|
[_asyncDelegate collectionView:self willDisplayNode:cellNode forItemAtIndexPath:indexPath];
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
} else if (_asyncDelegateFlags.asyncDelegateCollectionViewWillDisplayNodeForItemAtIndexPathDeprecated) {
|
||||||
[_asyncDelegate collectionView:self willDisplayNodeForItemAtIndexPath:indexPath];
|
[_asyncDelegate collectionView:self willDisplayNodeForItemAtIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
[_rangeController setNeedsUpdate];
|
[_rangeController setNeedsUpdate];
|
||||||
|
|
||||||
|
|||||||
@@ -383,17 +383,18 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
@optional
|
@optional
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Informs the delegate that the table view will add the node
|
* Informs the delegate that the table view will add the given node
|
||||||
* at the given index path to the view hierarchy.
|
* at the given index path to the view hierarchy.
|
||||||
*
|
*
|
||||||
* @param tableView The sender.
|
* @param tableView The sender.
|
||||||
|
* @param node The node that will be displayed.
|
||||||
* @param indexPath The index path of the row that will be displayed.
|
* @param indexPath The index path of the row that will be displayed.
|
||||||
*
|
*
|
||||||
* @warning AsyncDisplayKit processes table view edits asynchronously. The index path
|
* @warning AsyncDisplayKit processes table view edits asynchronously. The index path
|
||||||
* passed into this method may not correspond to the same item in your data source
|
* passed into this method may not correspond to the same item in your data source
|
||||||
* if your data source has been updated since the last edit was processed.
|
* if your data source has been updated since the last edit was processed.
|
||||||
*/
|
*/
|
||||||
- (void)tableView:(ASTableView *)tableView willDisplayNodeForRowAtIndexPath:(NSIndexPath *)indexPath;
|
- (void)tableView:(ASTableView *)tableView willDisplayNode:(ASCellNode *)node forRowAtIndexPath:(NSIndexPath *)indexPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Informs the delegate that the table view did remove the provided node from the view hierarchy.
|
* Informs the delegate that the table view did remove the provided node from the view hierarchy.
|
||||||
@@ -403,6 +404,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
* @param tableView The sender.
|
* @param tableView The sender.
|
||||||
* @param node The node which was removed from the view hierarchy.
|
* @param node The node which was removed from the view hierarchy.
|
||||||
* @param indexPath The index path at which the node was located before the removal.
|
* @param indexPath The index path at which the node was located before the removal.
|
||||||
|
*
|
||||||
|
* @warning AsyncDisplayKit processes table view edits asynchronously. The index path
|
||||||
|
* passed into this method may not correspond to the same item in your data source
|
||||||
|
* if your data source has been updated since the last edit was processed.
|
||||||
*/
|
*/
|
||||||
- (void)tableView:(ASTableView *)tableView didEndDisplayingNode:(ASCellNode *)node forRowAtIndexPath:(NSIndexPath *)indexPath;
|
- (void)tableView:(ASTableView *)tableView didEndDisplayingNode:(ASCellNode *)node forRowAtIndexPath:(NSIndexPath *)indexPath;
|
||||||
|
|
||||||
@@ -457,6 +462,21 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
*/
|
*/
|
||||||
- (void)tableView:(ASTableView *)tableView didEndDisplayingNodeForRowAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED;
|
- (void)tableView:(ASTableView *)tableView didEndDisplayingNodeForRowAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Informs the delegate that the table view will add the node
|
||||||
|
* at the given index path to the view hierarchy.
|
||||||
|
*
|
||||||
|
* @param tableView The sender.
|
||||||
|
* @param indexPath The index path of the row that will be displayed.
|
||||||
|
*
|
||||||
|
* @warning AsyncDisplayKit processes table view edits asynchronously. The index path
|
||||||
|
* passed into this method may not correspond to the same item in your data source
|
||||||
|
* if your data source has been updated since the last edit was processed.
|
||||||
|
*
|
||||||
|
* This method is deprecated. Use @c tableView:willDisplayNode:forRowAtIndexPath: instead.
|
||||||
|
*/
|
||||||
|
- (void)tableView:(ASTableView *)tableView willDisplayNodeForRowAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@protocol ASTableViewDelegate <ASTableDelegate>
|
@protocol ASTableViewDelegate <ASTableDelegate>
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
|||||||
unsigned int asyncDelegateScrollViewWillBeginDragging:1;
|
unsigned int asyncDelegateScrollViewWillBeginDragging:1;
|
||||||
unsigned int asyncDelegateScrollViewDidEndDragging:1;
|
unsigned int asyncDelegateScrollViewDidEndDragging:1;
|
||||||
unsigned int asyncDelegateTableViewWillDisplayNodeForRowAtIndexPath:1;
|
unsigned int asyncDelegateTableViewWillDisplayNodeForRowAtIndexPath:1;
|
||||||
|
unsigned int asyncDelegateTableViewWillDisplayNodeForRowAtIndexPathDeprecated:1;
|
||||||
unsigned int asyncDelegateTableViewDidEndDisplayingNodeForRowAtIndexPath:1;
|
unsigned int asyncDelegateTableViewDidEndDisplayingNodeForRowAtIndexPath:1;
|
||||||
unsigned int asyncDelegateTableViewDidEndDisplayingNodeForRowAtIndexPathDeprecated:1;
|
unsigned int asyncDelegateTableViewDidEndDisplayingNodeForRowAtIndexPathDeprecated:1;
|
||||||
unsigned int asyncDelegateScrollViewWillEndDraggingWithVelocityTargetContentOffset:1;
|
unsigned int asyncDelegateScrollViewWillEndDraggingWithVelocityTargetContentOffset:1;
|
||||||
@@ -331,7 +332,10 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
|||||||
_proxyDelegate = [[ASTableViewProxy alloc] initWithTarget:_asyncDelegate interceptor:self];
|
_proxyDelegate = [[ASTableViewProxy alloc] initWithTarget:_asyncDelegate interceptor:self];
|
||||||
|
|
||||||
_asyncDelegateFlags.asyncDelegateScrollViewDidScroll = [_asyncDelegate respondsToSelector:@selector(scrollViewDidScroll:)];
|
_asyncDelegateFlags.asyncDelegateScrollViewDidScroll = [_asyncDelegate respondsToSelector:@selector(scrollViewDidScroll:)];
|
||||||
_asyncDelegateFlags.asyncDelegateTableViewWillDisplayNodeForRowAtIndexPath = [_asyncDelegate respondsToSelector:@selector(tableView:willDisplayNodeForRowAtIndexPath:)];
|
_asyncDelegateFlags.asyncDelegateTableViewWillDisplayNodeForRowAtIndexPath = [_asyncDelegate respondsToSelector:@selector(tableView:willDisplayNode:forRowAtIndexPath:)];
|
||||||
|
if (_asyncDelegateFlags.asyncDelegateTableViewWillDisplayNodeForRowAtIndexPath == NO) {
|
||||||
|
_asyncDelegateFlags.asyncDelegateTableViewWillDisplayNodeForRowAtIndexPathDeprecated = [_asyncDelegate respondsToSelector:@selector(tableView:willDisplayNodeForRowAtIndexPath:)];
|
||||||
|
}
|
||||||
_asyncDelegateFlags.asyncDelegateTableViewDidEndDisplayingNodeForRowAtIndexPath = [_asyncDelegate respondsToSelector:@selector(tableView:didEndDisplayingNode:forRowAtIndexPath:)];
|
_asyncDelegateFlags.asyncDelegateTableViewDidEndDisplayingNodeForRowAtIndexPath = [_asyncDelegate respondsToSelector:@selector(tableView:didEndDisplayingNode:forRowAtIndexPath:)];
|
||||||
_asyncDelegateFlags.asyncDelegateTableViewDidEndDisplayingNodeForRowAtIndexPathDeprecated = [_asyncDelegate respondsToSelector:@selector(tableView:didEndDisplayingNodeForRowAtIndexPath:)];
|
_asyncDelegateFlags.asyncDelegateTableViewDidEndDisplayingNodeForRowAtIndexPathDeprecated = [_asyncDelegate respondsToSelector:@selector(tableView:didEndDisplayingNodeForRowAtIndexPath:)];
|
||||||
_asyncDelegateFlags.asyncDelegateScrollViewWillEndDraggingWithVelocityTargetContentOffset = [_asyncDelegate respondsToSelector:@selector(scrollViewWillEndDragging:withVelocity:targetContentOffset:)];
|
_asyncDelegateFlags.asyncDelegateScrollViewWillEndDraggingWithVelocityTargetContentOffset = [_asyncDelegate respondsToSelector:@selector(scrollViewWillEndDragging:withVelocity:targetContentOffset:)];
|
||||||
@@ -689,9 +693,16 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
|||||||
ASCellNode *cellNode = [cell node];
|
ASCellNode *cellNode = [cell node];
|
||||||
cellNode.scrollView = tableView;
|
cellNode.scrollView = tableView;
|
||||||
|
|
||||||
|
ASDisplayNodeAssertNotNil(cellNode, @"Expected node associated with cell that will be displayed not to be nil. indexPath: %@", indexPath);
|
||||||
|
|
||||||
if (_asyncDelegateFlags.asyncDelegateTableViewWillDisplayNodeForRowAtIndexPath) {
|
if (_asyncDelegateFlags.asyncDelegateTableViewWillDisplayNodeForRowAtIndexPath) {
|
||||||
|
[_asyncDelegate tableView:self willDisplayNode:cellNode forRowAtIndexPath:indexPath];
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
} else if (_asyncDelegateFlags.asyncDelegateTableViewWillDisplayNodeForRowAtIndexPathDeprecated) {
|
||||||
[_asyncDelegate tableView:self willDisplayNodeForRowAtIndexPath:indexPath];
|
[_asyncDelegate tableView:self willDisplayNodeForRowAtIndexPath:indexPath];
|
||||||
}
|
}
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
[_rangeController setNeedsUpdate];
|
[_rangeController setNeedsUpdate];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user