mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Add support to move supplementary nodes with section position changes
This commit is contained in:
@@ -141,7 +141,20 @@
|
||||
|
||||
- (void)willMoveSection:(NSInteger)section toSection:(NSInteger)newSection
|
||||
{
|
||||
// TODO: Implement
|
||||
NSArray *elementKinds = [self.collectionDataSource supplementaryNodeKindsInDataController:self];
|
||||
[elementKinds enumerateObjectsUsingBlock:^(NSString *kind, NSUInteger idx, BOOL *stop) {
|
||||
NSArray *indexPaths = ASIndexPathsForMultidimensionalArrayAtIndexSet([self editingNodesOfKind:kind], [NSIndexSet indexSetWithIndex:section]);
|
||||
NSArray *nodes = ASFindElementsInMultidimensionalArrayAtIndexPaths([self editingNodesOfKind:kind], indexPaths);
|
||||
[self deleteNodesOfKind:kind atIndexPaths:indexPaths completion:nil];
|
||||
|
||||
// update the section of indexpaths
|
||||
NSIndexPath *sectionIndexPath = [[NSIndexPath alloc] initWithIndex:newSection];
|
||||
NSMutableArray *updatedIndexPaths = [[NSMutableArray alloc] initWithCapacity:indexPaths.count];
|
||||
[indexPaths enumerateObjectsUsingBlock:^(NSIndexPath *indexPath, NSUInteger idx, BOOL *stop) {
|
||||
[updatedIndexPaths addObject:[sectionIndexPath indexPathByAddingIndex:[indexPath indexAtPosition:indexPath.length - 1]]];
|
||||
}];
|
||||
[self insertNodes:nodes ofKind:kind atIndexPaths:indexPaths completion:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)_populateSupplementaryNodesOfKind:(NSString *)kind withMutableNodes:(NSMutableArray *)nodes mutableIndexPaths:(NSMutableArray *)indexPaths
|
||||
|
||||
@@ -59,12 +59,12 @@
|
||||
/**
|
||||
* Read-only access to the underlying editing nodes of the given kind
|
||||
*/
|
||||
- (NSArray *)editingNodesOfKind:(NSString *)kind;
|
||||
- (NSMutableArray *)editingNodesOfKind:(NSString *)kind;
|
||||
|
||||
/**
|
||||
* Read only access to the underlying completed nodes of the given kind
|
||||
*/
|
||||
- (NSArray *)completedNodesOfKind:(NSString *)kind;
|
||||
- (NSMutableArray *)completedNodesOfKind:(NSString *)kind;
|
||||
|
||||
/**
|
||||
* Measure and layout the given nodes in optimized batches, constraining each to a given size in `constrainedSizeForNodeOfKind:atIndexPath:`.
|
||||
|
||||
@@ -849,12 +849,12 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
||||
return _editingNodes[kind] != nil ? ASIndexPathsForMultidimensionalArray(_editingNodes[kind]) : [NSArray array];
|
||||
}
|
||||
|
||||
- (NSArray *)editingNodesOfKind:(NSString *)kind
|
||||
- (NSMutableArray *)editingNodesOfKind:(NSString *)kind
|
||||
{
|
||||
return _editingNodes[kind] != nil ? _editingNodes[kind] : [NSArray array];
|
||||
return _editingNodes[kind] != nil ? _editingNodes[kind] : [NSMutableArray array];
|
||||
}
|
||||
|
||||
- (NSArray *)completedNodesOfKind:(NSString *)kind
|
||||
- (NSMutableArray *)completedNodesOfKind:(NSString *)kind
|
||||
{
|
||||
return _completedNodes[kind];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user