1414#import " ASDisplayNodeInternal.h"
1515#import " ASDataController+Subclasses.h"
1616
17+ @interface ASCollectionDataController ()
18+
19+ - (id <ASCollectionDataControllerSource>)collectionDataSource ;
20+
21+ @end
22+
1723@implementation ASCollectionDataController {
1824 NSMutableDictionary *_completedSupplementaryNodes;
1925 NSMutableDictionary *_editingSupplementaryNodes;
@@ -24,21 +30,23 @@ - (void)initialSupplementaryLoading
2430 [self performEditCommandWithBlock: ^{
2531 ASDisplayNodeAssertMainThread ();
2632 [self accessDataSourceWithBlock: ^{
27- NSArray *elementKinds = [self .collectionDataSource supplementaryKindsInDataController :self ];
33+ NSArray *elementKinds = [self .collectionDataSource supplementaryNodeKindsInDataController :self ];
2834 [elementKinds enumerateObjectsUsingBlock: ^(NSString *kind, NSUInteger idx, BOOL * _Nonnull stop) {
2935 _completedSupplementaryNodes[kind] = [NSMutableArray array ];
3036 _editingSupplementaryNodes[kind] = [NSMutableArray array ];
3137
3238 NSMutableArray *indexPaths = [NSMutableArray array ];
3339 NSMutableArray *nodes = [NSMutableArray array ];
34- [self _populateAllNodesOfKind: kind withMutableNodes: nodes mutableIndexPaths: indexPaths];
35- [self batchLayoutNodes: nodes atIndexPaths: indexPaths completion: nil ];
40+ [self _populateSupplementaryNodesOfKind: kind withMutableNodes: nodes mutableIndexPaths: indexPaths];
41+ [self batchLayoutNodes: nodes atIndexPaths: indexPaths constrainedSize: ^ASSizeRange (NSIndexPath *indexPath) {
42+ return [self .collectionDataSource dataController: self constrainedSizeForSupplementaryNodeOfKind: kind atIndexPath: indexPath];
43+ } completion: nil ];
3644 }];
3745 }];
3846 }];
3947}
4048
41- - (void )_populateAllNodesOfKind : (NSString *)kind withMutableNodes : (NSMutableArray *)nodes mutableIndexPaths : (NSMutableArray *)indexPaths
49+ - (void )_populateSupplementaryNodesOfKind : (NSString *)kind withMutableNodes : (NSMutableArray *)nodes mutableIndexPaths : (NSMutableArray *)indexPaths
4250{
4351 NSUInteger sectionCount = [self .collectionDataSource dataController: self numberOfSectionsForSupplementaryKind: kind];
4452 for (NSUInteger i = 0 ; i < sectionCount; i++) {
@@ -65,6 +73,7 @@ - (ASDisplayNode *)supplementaryNodeOfKind:(NSString *)kind atIndexPath:(NSIndex
6573
6674#pragma mark - Internal Data Querying
6775
76+ // TODO: Reduce code duplication by exposing generic insert/delete helpers from ASDataController
6877- (void )_insertNodes : (NSArray *)nodes ofKind : (NSString *)kind atIndexPaths : (NSArray *)indexPaths
6978{
7079 if (indexPaths.count == 0 )
@@ -78,6 +87,7 @@ - (void)_insertNodes:(NSArray *)nodes ofKind:(NSString *)kind atIndexPaths:(NSAr
7887 });
7988}
8089
90+ // TODO: Reduce code duplication by exposing generic insert/delete helpers from ASDataController
8191- (void )_deleteNodesOfKind : (NSString *)kind atIndexPaths : (NSArray *)indexPaths
8292{
8393 if (indexPaths.count == 0 )
0 commit comments