mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-15 16:36:36 +00:00
Add constrainedSizeForNodeAtIndexPath to ASPagerNodeDataSource
This commit is contained in:
parent
5cccc0f432
commit
3e56a327c7
@ -50,6 +50,17 @@
|
|||||||
*/
|
*/
|
||||||
- (ASCellNodeBlock)pagerNode:(ASPagerNode *)pagerNode nodeBlockAtIndex:(NSInteger)index;
|
- (ASCellNodeBlock)pagerNode:(ASPagerNode *)pagerNode nodeBlockAtIndex:(NSInteger)index;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the constrained size range for measuring the node at the index path.
|
||||||
|
*
|
||||||
|
* @param collectionView The sender.
|
||||||
|
*
|
||||||
|
* @param indexPath The index path of the node.
|
||||||
|
*
|
||||||
|
* @returns A constrained size range for layout the node at this index path.
|
||||||
|
*/
|
||||||
|
- (ASSizeRange)pagerNode:(ASPagerNode *)pagerNode constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface ASPagerNode : ASCollectionNode
|
@interface ASPagerNode : ASCollectionNode
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
ASPagerNodeProxy *_proxy;
|
ASPagerNodeProxy *_proxy;
|
||||||
__weak id <ASPagerNodeDataSource> _pagerDataSource;
|
__weak id <ASPagerNodeDataSource> _pagerDataSource;
|
||||||
BOOL _pagerDataSourceImplementsNodeBlockAtIndex;
|
BOOL _pagerDataSourceImplementsNodeBlockAtIndex;
|
||||||
|
BOOL _pagerDataSourceImplementsConstrainedSizeForNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@ -101,7 +102,10 @@
|
|||||||
|
|
||||||
- (ASSizeRange)collectionView:(ASCollectionView *)collectionView constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath
|
- (ASSizeRange)collectionView:(ASCollectionView *)collectionView constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
return ASSizeRangeMake(CGSizeZero, self.view.bounds.size);
|
if (_pagerDataSourceImplementsConstrainedSizeForNode) {
|
||||||
|
return [_pagerDataSource pagerNode:self constrainedSizeForNodeAtIndexPath:indexPath];
|
||||||
|
}
|
||||||
|
return ASSizeRangeMake(CGSizeZero, self.bounds.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Data Source Proxy
|
#pragma mark - Data Source Proxy
|
||||||
@ -115,9 +119,13 @@
|
|||||||
{
|
{
|
||||||
if (pagerDataSource != _pagerDataSource) {
|
if (pagerDataSource != _pagerDataSource) {
|
||||||
_pagerDataSource = pagerDataSource;
|
_pagerDataSource = pagerDataSource;
|
||||||
|
|
||||||
_pagerDataSourceImplementsNodeBlockAtIndex = [_pagerDataSource respondsToSelector:@selector(pagerNode:nodeBlockAtIndex:)];
|
_pagerDataSourceImplementsNodeBlockAtIndex = [_pagerDataSource respondsToSelector:@selector(pagerNode:nodeBlockAtIndex:)];
|
||||||
// Data source must implement pagerNode:nodeBlockAtIndex: or pagerNode:nodeAtIndex:
|
// Data source must implement pagerNode:nodeBlockAtIndex: or pagerNode:nodeAtIndex:
|
||||||
ASDisplayNodeAssertTrue(_pagerDataSourceImplementsNodeBlockAtIndex || [_pagerDataSource respondsToSelector:@selector(pagerNode:nodeAtIndex:)]);
|
ASDisplayNodeAssertTrue(_pagerDataSourceImplementsNodeBlockAtIndex || [_pagerDataSource respondsToSelector:@selector(pagerNode:nodeAtIndex:)]);
|
||||||
|
|
||||||
|
_pagerDataSourceImplementsConstrainedSizeForNode = [_pagerDataSource respondsToSelector:@selector(pagerNode:constrainedSizeForNodeAtIndexPath:)];
|
||||||
|
|
||||||
_proxy = pagerDataSource ? [[ASPagerNodeProxy alloc] initWithTarget:pagerDataSource interceptor:self] : nil;
|
_proxy = pagerDataSource ? [[ASPagerNodeProxy alloc] initWithTarget:pagerDataSource interceptor:self] : nil;
|
||||||
|
|
||||||
super.dataSource = (id <ASCollectionDataSource>)_proxy;
|
super.dataSource = (id <ASCollectionDataSource>)_proxy;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user