mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-01 10:23:15 +00:00
Move ASSectionController and ASSupplementaryNodeSource method to be optional (#1302)
This commit is contained in:
parent
d4a1242052
commit
8edb5a45d3
@ -16,13 +16,14 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
@class ASBatchContext;
|
@class ASBatchContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A protocol that your section controllers should conform to,
|
* A protocol that your section controllers should conform to, in order to be used with Texture.
|
||||||
* in order to be used with AsyncDisplayKit.
|
|
||||||
*
|
*
|
||||||
* @note Your supplementary view source should conform to @c ASSupplementaryNodeSource.
|
* @note Your supplementary view source should conform to @c ASSupplementaryNodeSource.
|
||||||
*/
|
*/
|
||||||
@protocol ASSectionController <NSObject>
|
@protocol ASSectionController <NSObject>
|
||||||
|
|
||||||
|
@optional
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A method to provide the node block for the item at the given index.
|
* A method to provide the node block for the item at the given index.
|
||||||
* The node block you return will be run asynchronously off the main thread,
|
* The node block you return will be run asynchronously off the main thread,
|
||||||
@ -48,8 +49,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
*/
|
*/
|
||||||
- (ASCellNode *)nodeForItemAtIndex:(NSInteger)index;
|
- (ASCellNode *)nodeForItemAtIndex:(NSInteger)index;
|
||||||
|
|
||||||
@optional
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asks the section controller whether it should batch fetch because the user is
|
* Asks the section controller whether it should batch fetch because the user is
|
||||||
* near the end of the current data set.
|
* near the end of the current data set.
|
||||||
|
@ -15,6 +15,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
@protocol ASSupplementaryNodeSource <NSObject>
|
@protocol ASSupplementaryNodeSource <NSObject>
|
||||||
|
|
||||||
|
@optional
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A method to provide the node-block for the supplementary element.
|
* A method to provide the node-block for the supplementary element.
|
||||||
*
|
*
|
||||||
@ -33,8 +35,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
*/
|
*/
|
||||||
- (ASCellNode *)nodeForSupplementaryElementOfKind:(NSString *)kind atIndex:(NSInteger)index;
|
- (ASCellNode *)nodeForSupplementaryElementOfKind:(NSString *)kind atIndex:(NSInteger)index;
|
||||||
|
|
||||||
@optional
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A method to provide the size range used for measuring the supplementary
|
* A method to provide the size range used for measuring the supplementary
|
||||||
* element of the given kind at the given index.
|
* element of the given kind at the given index.
|
||||||
|
@ -215,12 +215,16 @@ typedef struct {
|
|||||||
|
|
||||||
- (ASCellNodeBlock)collectionNode:(ASCollectionNode *)collectionNode nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath
|
- (ASCellNodeBlock)collectionNode:(ASCollectionNode *)collectionNode nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
return [[self sectionControllerForSection:indexPath.section] nodeBlockForItemAtIndex:indexPath.item];
|
ASIGSectionController *ctrl = [self sectionControllerForSection:indexPath.section];
|
||||||
|
ASDisplayNodeAssert([ctrl respondsToSelector:@selector(nodeBlockForItemAtIndex:)], @"Expected section controller to respond to to %@. Controller: %@", NSStringFromSelector(@selector(nodeBlockForItemAtIndex:)), ctrl);
|
||||||
|
return [ctrl nodeBlockForItemAtIndex:indexPath.item];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ASCellNode *)collectionNode:(ASCollectionNode *)collectionNode nodeForItemAtIndexPath:(NSIndexPath *)indexPath
|
- (ASCellNode *)collectionNode:(ASCollectionNode *)collectionNode nodeForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
return [[self sectionControllerForSection:indexPath.section] nodeForItemAtIndex:indexPath.item];
|
ASIGSectionController *ctrl = [self sectionControllerForSection:indexPath.section];
|
||||||
|
ASDisplayNodeAssert([ctrl respondsToSelector:@selector(nodeForItemAtIndex:)], @"Expected section controller to respond to to %@. Controller: %@", NSStringFromSelector(@selector(nodeForItemAtIndex:)), ctrl);
|
||||||
|
return [ctrl nodeForItemAtIndex:indexPath.item];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ASSizeRange)collectionNode:(ASCollectionNode *)collectionNode constrainedSizeForItemAtIndexPath:(NSIndexPath *)indexPath
|
- (ASSizeRange)collectionNode:(ASCollectionNode *)collectionNode constrainedSizeForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||||
@ -235,12 +239,16 @@ typedef struct {
|
|||||||
|
|
||||||
- (ASCellNodeBlock)collectionNode:(ASCollectionNode *)collectionNode nodeBlockForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
|
- (ASCellNodeBlock)collectionNode:(ASCollectionNode *)collectionNode nodeBlockForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
return [[self supplementaryElementSourceForSection:indexPath.section] nodeBlockForSupplementaryElementOfKind:kind atIndex:indexPath.item];
|
id<ASSupplementaryNodeSource> ctrl = [self supplementaryElementSourceForSection:indexPath.section];
|
||||||
|
ASDisplayNodeAssert([ctrl respondsToSelector:@selector(nodeBlockForSupplementaryElementOfKind:atIndex:)], @"Expected section controller to respond to to %@. Controller: %@", NSStringFromSelector(@selector(nodeBlockForSupplementaryElementOfKind:atIndex:)), ctrl);
|
||||||
|
return [ctrl nodeBlockForSupplementaryElementOfKind:kind atIndex:indexPath.item];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ASCellNode *)collectionNode:(ASCollectionNode *)collectionNode nodeForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
|
- (ASCellNode *)collectionNode:(ASCollectionNode *)collectionNode nodeForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
return [[self supplementaryElementSourceForSection:indexPath.section] nodeForSupplementaryElementOfKind:kind atIndex:indexPath.item];
|
id<ASSupplementaryNodeSource> ctrl = [self supplementaryElementSourceForSection:indexPath.section];
|
||||||
|
ASDisplayNodeAssert([ctrl respondsToSelector:@selector(nodeForSupplementaryElementOfKind:atIndex:)], @"Expected section controller to respond to to %@. Controller: %@", NSStringFromSelector(@selector(nodeForSupplementaryElementOfKind:atIndex:)), ctrl);
|
||||||
|
return [ctrl nodeForSupplementaryElementOfKind:kind atIndex:indexPath.item];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray<NSString *> *)collectionNode:(ASCollectionNode *)collectionNode supplementaryElementKindsInSection:(NSInteger)section
|
- (NSArray<NSString *> *)collectionNode:(ASCollectionNode *)collectionNode supplementaryElementKindsInSection:(NSInteger)section
|
||||||
|
Loading…
x
Reference in New Issue
Block a user