forked from facebookarchive/AsyncDisplayKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASPagerNode.h
More file actions
90 lines (72 loc) · 2.8 KB
/
ASPagerNode.h
File metadata and controls
90 lines (72 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// ASPagerNode.h
// AsyncDisplayKit
//
// Created by Levi McCallum on 12/7/15.
// Copyright © 2015 Facebook. All rights reserved.
//
#import <AsyncDisplayKit/ASCollectionNode.h>
@class ASPagerNode;
@class ASPagerFlowLayout;
@protocol ASPagerNodeDataSource <NSObject>
/**
* This method replaces -collectionView:numberOfItemsInSection:
*
* @param pagerNode The sender.
*
*
* @returns The total number of pages that can display in the pagerNode.
*/
- (NSInteger)numberOfPagesInPagerNode:(ASPagerNode *)pagerNode;
@optional
/**
* This method replaces -collectionView:nodeForItemAtIndexPath:
*
* @param pagerNode The sender.
*
* @param index The index of the requested node.
*
* @returns a node for display at this index. This will be called on the main thread and should
* not implement reuse (it will be called once per row). Unlike UICollectionView's version,
* this method is not called when the row is about to display.
*/
- (ASCellNode *)pagerNode:(ASPagerNode *)pagerNode nodeAtIndex:(NSInteger)index;
/**
* This method replaces -collectionView:nodeBlockForItemAtIndexPath:
* This method takes precedence over pagerNode:nodeAtIndex: if implemented.
*
* @param pagerNode The sender.
*
* @param index The index of the requested node.
*
* @returns a block that creates the node for display at this index.
* Must be thread-safe (can be called on the main thread or a background
* queue) and should not implement reuse (it will be called once per row).
*/
- (ASCellNodeBlock)pagerNode:(ASPagerNode *)pagerNode nodeBlockAtIndex:(NSInteger)index;
/**
* Provides the constrained size range for measuring the node at the index path.
*
* @param pagerNode 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
@interface ASPagerNode : ASCollectionNode
// Configures a default horizontal, paging flow layout with 0 inter-item spacing.
- (instancetype)init;
// 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;
// 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;
// The underlying ASCollectionView object.
@property (nonatomic, readonly) ASCollectionView *view;
- (void)scrollToPageAtIndex:(NSInteger)index animated:(BOOL)animated;
@end