mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-23 17:28:22 +00:00
Refactor code syntax in internal classes to be easier to provide code coverage
Summary: Similar to the previous diff, this diff updates some of the code styling and syntax in IGListKit's internal classes to make it much easier to provide test coverage to each method in there. Reviewed By: candance Differential Revision: D45003471 fbshipit-source-id: 1267901fc7a917bf1c30783654a8fd0da941bff1
This commit is contained in:
parent
dfb52ea701
commit
08a1d83652
3 changed files with 20 additions and 15 deletions
|
|
@ -147,7 +147,7 @@ typedef NS_ENUM (NSInteger, IGListUpdateTransactionBuilderMode) {
|
|||
}
|
||||
|
||||
switch (self.mode) {
|
||||
case IGListUpdateTransactionBuilderModeBatchUpdate: {
|
||||
case IGListUpdateTransactionBuilderModeBatchUpdate:
|
||||
return [[IGListBatchUpdateTransaction alloc] initWithCollectionViewBlock:collectionViewBlock
|
||||
updater:updater
|
||||
delegate:delegate
|
||||
|
|
@ -157,7 +157,6 @@ typedef NS_ENUM (NSInteger, IGListUpdateTransactionBuilderMode) {
|
|||
applySectionDataBlock:self.applySectionDataBlock
|
||||
itemUpdateBlocks:self.itemUpdateBlocks
|
||||
completionBlocks:self.completionBlocks];
|
||||
}
|
||||
case IGListUpdateTransactionBuilderModeReload: {
|
||||
IGListReloadUpdateBlock reloadBlock = self.reloadBlock;
|
||||
if (!reloadBlock) {
|
||||
|
|
|
|||
|
|
@ -70,10 +70,8 @@ static void * kIGListAdapterKey = &kIGListAdapterKey;
|
|||
NSIndexPath *updatedTarget = [self updatedTargetForInteractivelyMovingItem:previousIndexPath
|
||||
toIndexPath:originalTarget
|
||||
adapter:adapter];
|
||||
if (updatedTarget) {
|
||||
return updatedTarget;
|
||||
}
|
||||
return originalTarget;
|
||||
|
||||
return updatedTarget ?: originalTarget;
|
||||
}
|
||||
|
||||
- (nullable NSIndexPath *)updatedTargetForInteractivelyMovingItem:(NSIndexPath *)previousIndexPath
|
||||
|
|
@ -177,12 +175,9 @@ static void * kIGListAdapterKey = &kIGListAdapterKey;
|
|||
}
|
||||
|
||||
[modifiedContext invalidateItemsAtIndexPaths:invalidatedItemIndexPaths];
|
||||
[originalContext.invalidatedSupplementaryIndexPaths enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, NSArray<NSIndexPath *> * _Nonnull obj, BOOL * _Nonnull stop) {
|
||||
[modifiedContext invalidateSupplementaryElementsOfKind:key atIndexPaths:obj];
|
||||
}];
|
||||
[originalContext.invalidatedDecorationIndexPaths enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, NSArray<NSIndexPath *> * _Nonnull obj, BOOL * _Nonnull stop) {
|
||||
[modifiedContext invalidateDecorationElementsOfKind:key atIndexPaths:obj];
|
||||
}];
|
||||
[self ig_invalidateAccessoryElementsWithSupplementaryIndexPaths:originalContext.invalidatedSupplementaryIndexPaths
|
||||
decorationIndexPaths:originalContext.invalidatedDecorationIndexPaths
|
||||
inContext:modifiedContext];
|
||||
modifiedContext.contentOffsetAdjustment = originalContext.contentOffsetAdjustment;
|
||||
modifiedContext.contentSizeAdjustment = originalContext.contentSizeAdjustment;
|
||||
|
||||
|
|
@ -192,4 +187,15 @@ static void * kIGListAdapterKey = &kIGListAdapterKey;
|
|||
return originalContext;
|
||||
}
|
||||
|
||||
- (void)ig_invalidateAccessoryElementsWithSupplementaryIndexPaths:(NSDictionary<NSString *, NSArray<NSIndexPath *> *> *)supplementaryIndexPaths
|
||||
decorationIndexPaths:(NSDictionary<NSString *, NSArray<NSIndexPath *> *> *)decorationIndexPaths
|
||||
inContext:(UICollectionViewLayoutInvalidationContext *)context {
|
||||
[supplementaryIndexPaths enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSArray<NSIndexPath *> *obj, BOOL *stop) {
|
||||
[context invalidateSupplementaryElementsOfKind:key atIndexPaths:obj];
|
||||
}];
|
||||
[decorationIndexPaths enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSArray<NSIndexPath *> *obj, BOOL *stop) {
|
||||
[context invalidateDecorationElementsOfKind:key atIndexPaths:obj];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@
|
|||
|
||||
- (UIEdgeInsets) ig_contentInset
|
||||
{
|
||||
UIEdgeInsets contentInset = self.contentInset;
|
||||
if (@available(iOS 11.0, tvOS 11.0, *)) {
|
||||
return self.adjustedContentInset;
|
||||
} else {
|
||||
return self.contentInset;
|
||||
contentInset = self.adjustedContentInset;
|
||||
}
|
||||
return contentInset;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
Loading…
Reference in a new issue