mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-01-13 08:49:50 +08:00
Allow public access to completed nodes (dumb name)
This commit is contained in:
@@ -276,14 +276,18 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath;
|
||||
|
||||
/**
|
||||
* Similar to -cellForItemAtIndexPath:.
|
||||
* Retrieves the node for the row at the given index path, in the data source's index space.
|
||||
*
|
||||
* @param indexPath The index path of the requested node.
|
||||
*
|
||||
* @return a node for display at this indexpath or nil
|
||||
*/
|
||||
- (nullable ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath;
|
||||
|
||||
/**
|
||||
* Retrieves the node for the item at the given index path, in UICollectionView's index space.
|
||||
*
|
||||
* @param indexPath The index path of the requested node.
|
||||
*/
|
||||
- (nullable ASCellNode *)nodeForItemAtCompletedIndexPath:(NSIndexPath *)indexPath;
|
||||
|
||||
/**
|
||||
* Similar to -supplementaryViewForElementKind:atIndexPath:
|
||||
@@ -316,13 +320,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
- (NSArray<ASCellNode *> *)visibleNodes;
|
||||
|
||||
/**
|
||||
* Query the sized node at `indexPath` for its calculatedSize.
|
||||
*
|
||||
* @param indexPath The index path for the node of interest.
|
||||
*/
|
||||
- (CGSize)calculatedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath;
|
||||
|
||||
/**
|
||||
* Determines collection view's current scroll direction. Supports 2-axis collection views.
|
||||
*
|
||||
@@ -363,6 +360,19 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@end
|
||||
|
||||
@interface ASCollectionView (Deprecated)
|
||||
|
||||
/**
|
||||
* Query the sized node at `indexPath` for its calculatedSize.
|
||||
*
|
||||
* @param indexPath The index path for the node of interest.
|
||||
*
|
||||
* @deprecated Call @c calculatedSize for the node of interest instead.
|
||||
*/
|
||||
- (CGSize)calculatedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
/**
|
||||
* This is a node-based UICollectionViewDataSource.
|
||||
|
||||
@@ -481,6 +481,11 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
||||
return [_dataController nodeAtIndexPath:indexPath];
|
||||
}
|
||||
|
||||
- (ASCellNode *)nodeForItemAtCompletedIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return [_dataController nodeAtCompletedIndexPath:indexPath];
|
||||
}
|
||||
|
||||
- (ASCellNode *)supplementaryNodeForElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return [_dataController supplementaryNodeOfKind:elementKind atIndexPath:indexPath];
|
||||
|
||||
@@ -272,14 +272,19 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath;
|
||||
|
||||
/**
|
||||
* Similar to -cellForRowAtIndexPath:.
|
||||
* Retrieves the node for the row at the given index path, in the data source's index space.
|
||||
*
|
||||
* @param indexPath The index path of the requested node.
|
||||
*
|
||||
* @return a node for display at this indexpath.
|
||||
*/
|
||||
- (nullable ASCellNode *)nodeForRowAtIndexPath:(NSIndexPath *)indexPath;
|
||||
|
||||
/**
|
||||
* Retrieves the node for the row at the given index path, in UITableView's index space.
|
||||
*
|
||||
* @param indexPath The index path of the requested node.
|
||||
*/
|
||||
- (nullable ASCellNode *)nodeForRowAtCompletedIndexPath:(NSIndexPath *)indexPath;
|
||||
|
||||
/**
|
||||
* Similar to -indexPathForCell:.
|
||||
*
|
||||
|
||||
@@ -414,6 +414,11 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
||||
return [_dataController nodeAtIndexPath:indexPath];
|
||||
}
|
||||
|
||||
- (ASCellNode *)nodeForRowAtCompletedIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return [_dataController nodeAtCompletedIndexPath:indexPath];
|
||||
}
|
||||
|
||||
- (NSIndexPath *)indexPathForNode:(ASCellNode *)cellNode
|
||||
{
|
||||
return [_dataController indexPathForNode:cellNode];
|
||||
|
||||
@@ -181,6 +181,8 @@ FOUNDATION_EXPORT NSString * const ASDataControllerRowNodeKind;
|
||||
|
||||
- (nullable ASCellNode *)nodeAtIndexPath:(NSIndexPath *)indexPath;
|
||||
|
||||
- (nullable ASCellNode *)nodeAtCompletedIndexPath:(NSIndexPath *)indexPath;
|
||||
|
||||
/**
|
||||
* @return The index path, in the data source's index space, for the given node.
|
||||
*/
|
||||
|
||||
@@ -915,6 +915,25 @@ NSString * const ASDataControllerRowNodeKind = @"_ASDataControllerRowNodeKind";
|
||||
return context.node;
|
||||
}
|
||||
|
||||
- (ASCellNode *)nodeAtCompletedIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
NSArray *completedNodes = [self completedNodes];
|
||||
NSInteger section = indexPath.section;
|
||||
NSInteger row = indexPath.row;
|
||||
ASCellNode *node = nil;
|
||||
|
||||
if (section >= 0 && row >= 0 && section < completedNodes.count) {
|
||||
NSArray *completedNodesSection = completedNodes[section];
|
||||
if (row < completedNodesSection.count) {
|
||||
node = completedNodesSection[row];
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
- (NSIndexPath *)indexPathForNode:(ASCellNode *)cellNode;
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
@@ -450,14 +450,14 @@
|
||||
{
|
||||
updateValidationTestPrologue
|
||||
id layout = cv.collectionViewLayout;
|
||||
CGSize initialItemSize = [cv calculatedSizeForNodeAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
|
||||
CGSize initialItemSize = [cv nodeForItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]].calculatedSize;
|
||||
CGSize initialCVSize = cv.bounds.size;
|
||||
|
||||
// Capture the node size before first call to prepareLayout after frame change.
|
||||
__block CGSize itemSizeAtFirstLayout = CGSizeZero;
|
||||
__block CGSize boundsSizeAtFirstLayout = CGSizeZero;
|
||||
[[[[layout expect] andDo:^(NSInvocation *) {
|
||||
itemSizeAtFirstLayout = [cv calculatedSizeForNodeAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
|
||||
itemSizeAtFirstLayout = [cv nodeForItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]].calculatedSize;
|
||||
boundsSizeAtFirstLayout = [cv bounds].size;
|
||||
}] andForwardToRealObject] prepareLayout];
|
||||
|
||||
@@ -465,7 +465,7 @@
|
||||
UIDeviceOrientation oldDeviceOrientation = [[UIDevice currentDevice] orientation];
|
||||
[[UIDevice currentDevice] setValue:@(UIDeviceOrientationLandscapeLeft) forKey:@"orientation"];
|
||||
|
||||
CGSize finalItemSize = [cv calculatedSizeForNodeAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
|
||||
CGSize finalItemSize = [cv nodeForItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]].calculatedSize;
|
||||
CGSize finalCVSize = cv.bounds.size;
|
||||
XCTAssertNotEqualObjects(NSStringFromCGSize(initialItemSize), NSStringFromCGSize(itemSizeAtFirstLayout));
|
||||
XCTAssertNotEqualObjects(NSStringFromCGSize(initialCVSize), NSStringFromCGSize(boundsSizeAtFirstLayout));
|
||||
|
||||
Reference in New Issue
Block a user