mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-19 21:00:10 +00:00
Merge pull request #1571 from maicki/FixASPagerNodeDataSourceSourceInconsistency
[ASPagerNode] Fix ASPagerNode data source and delegate inconsistencies
This commit is contained in:
commit
a1d2f8ccc6
@ -342,7 +342,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
* This is a node-based UICollectionViewDataSource.
|
||||
*/
|
||||
#define ASCollectionViewDataSource ASCollectionDataSource
|
||||
@protocol ASCollectionDataSource <ASCommonCollectionViewDataSource, NSObject>
|
||||
@protocol ASCollectionDataSource <ASCommonCollectionViewDataSource>
|
||||
|
||||
@optional
|
||||
|
||||
|
||||
@ -11,7 +11,8 @@
|
||||
@class ASPagerNode;
|
||||
@class ASPagerFlowLayout;
|
||||
|
||||
@protocol ASPagerNodeDataSource <NSObject>
|
||||
#define ASPagerNodeDataSource ASPagerDataSource
|
||||
@protocol ASPagerDataSource <NSObject>
|
||||
|
||||
/**
|
||||
* This method replaces -collectionView:numberOfItemsInSection:
|
||||
@ -65,25 +66,30 @@
|
||||
|
||||
@end
|
||||
|
||||
@protocol ASPagerDelegate <ASCollectionDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@interface ASPagerNode : ASCollectionNode
|
||||
|
||||
// Configures a default horizontal, paging flow layout with 0 inter-item spacing.
|
||||
/// Configures a default horizontal, paging flow layout with 0 inter-item spacing.
|
||||
- (instancetype)init;
|
||||
|
||||
// Initializer with custom-configured flow layout properties.
|
||||
/// Initializer with custom-configured flow layout properties.
|
||||
- (instancetype)initWithCollectionViewLayout:(ASPagerFlowLayout *)flowLayout;
|
||||
|
||||
// Data Source is required, and uses a different protocol from ASCollectionNode.
|
||||
- (void)setDataSource:(id <ASPagerNodeDataSource>)dataSource;
|
||||
- (id <ASPagerNodeDataSource>)dataSource;
|
||||
/// Data Source is required, and uses a different protocol from ASCollectionNode.
|
||||
- (void)setDataSource:(id <ASPagerDataSource>)dataSource;
|
||||
- (id <ASPagerDataSource>)dataSource;
|
||||
|
||||
// Delegate is optional, and uses the same protocol as ASCollectionNode.
|
||||
// This includes UIScrollViewDelegate as well as most methods from UICollectionViewDelegate, like willDisplay...
|
||||
@property (nonatomic, weak) id <ASCollectionDelegate> delegate;
|
||||
@property (nonatomic, weak) id <ASPagerDelegate> delegate;
|
||||
|
||||
// The underlying ASCollectionView object.
|
||||
/// The underlying ASCollectionView object.
|
||||
@property (nonatomic, readonly) ASCollectionView *view;
|
||||
|
||||
/// Scroll the contents of the receiver to ensure that the page is visible.
|
||||
- (void)scrollToPageAtIndex:(NSInteger)index animated:(BOOL)animated;
|
||||
|
||||
@end
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
{
|
||||
ASPagerFlowLayout *_flowLayout;
|
||||
ASPagerNodeProxy *_proxy;
|
||||
__weak id <ASPagerNodeDataSource> _pagerDataSource;
|
||||
__weak id <ASPagerDataSource> _pagerDataSource;
|
||||
BOOL _pagerDataSourceImplementsNodeBlockAtIndex;
|
||||
BOOL _pagerDataSourceImplementsConstrainedSizeForNode;
|
||||
}
|
||||
@ -111,12 +111,12 @@
|
||||
|
||||
#pragma mark - Data Source Proxy
|
||||
|
||||
- (id <ASPagerNodeDataSource>)dataSource
|
||||
- (id <ASPagerDataSource>)dataSource
|
||||
{
|
||||
return _pagerDataSource;
|
||||
}
|
||||
|
||||
- (void)setDataSource:(id <ASPagerNodeDataSource>)pagerDataSource
|
||||
- (void)setDataSource:(id <ASPagerDataSource>)pagerDataSource
|
||||
{
|
||||
if (pagerDataSource != _pagerDataSource) {
|
||||
_pagerDataSource = pagerDataSource;
|
||||
|
||||
@ -77,7 +77,7 @@
|
||||
- (BOOL)interceptsSelector:(SEL)selector
|
||||
{
|
||||
return (
|
||||
// handled by ASPagerNodeDataSource node<->cell machinery
|
||||
// handled by ASPagerDataSource node<->cell machinery
|
||||
selector == @selector(collectionView:nodeForItemAtIndexPath:) ||
|
||||
selector == @selector(collectionView:nodeBlockForItemAtIndexPath:) ||
|
||||
selector == @selector(collectionView:numberOfItemsInSection:) ||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user