Skip to content

Commit

Permalink
SPM number10 - fix the internal build
Browse files Browse the repository at this point in the history
Summary:
Follow up with the PR: Instagram#1487 and to resolve some of the internal build failure.

= Facebook =
This is to follow up with the PR diff: D30428297 to fix the internal BUCK build error.

Differential Revision: D30437725

fbshipit-source-id: 8eb6a48a614a857806ee0ab3152707e9b4fd147a
  • Loading branch information
lorixx authored and facebook-github-bot committed Aug 19, 2021
1 parent 99e5675 commit 0482dc3
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 30 deletions.
5 changes: 5 additions & 0 deletions Source/IGListDiffKit/IGListBatchUpdateData.mm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@

#import <unordered_map>

#if !__has_include(<IGListDiffKit/IGListDiffKit.h>)
#import "IGListAssert.h"
#else
#import <IGListDiffKit/IGListAssert.h>
#endif

#import "IGListCompatibility.h"

// Plucks the given move from available moves and turns it into a delete + insert
Expand Down
4 changes: 4 additions & 0 deletions Source/IGListDiffKit/Internal/IGListIndexSetResultInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

#import <Foundation/Foundation.h>

#if !__has_include(<IGListDiffKit/IGListDiffKit.h>)
#import "IGListIndexSetResult.h"
#else
#import <IGListDiffKit/IGListIndexSetResult.h>
#endif

NS_ASSUME_NONNULL_BEGIN

Expand Down
4 changes: 4 additions & 0 deletions Source/IGListKit/IGListAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

#import "IGListAdapterInternal.h"

#if !__has_include(<IGListDiffKit/IGListDiffKit.h>)
#import "IGListAssert.h"
#else
#import <IGListDiffKit/IGListAssert.h>
#endif
#import "IGListAdapterUpdater.h"
#import "IGListSupplementaryViewSource.h"

Expand Down
5 changes: 5 additions & 0 deletions Source/IGListKit/IGListAdapterDataSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

#import <UIKit/UIKit.h>

#if !__has_include(<IGListDiffKit/IGListDiffKit.h>)
#import "IGListDiffable.h"
#else
#import <IGListDiffKit/IGListDiffable.h>
#endif


@class IGListAdapter;
@class IGListSectionController;
Expand Down
5 changes: 5 additions & 0 deletions Source/IGListKit/IGListBindingSectionController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

#import <Foundation/Foundation.h>

#if !__has_include(<IGListDiffKit/IGListDiffKit.h>)
#import "IGListMacros.h"
#else
#import <IGListDiffKit/IGListMacros.h>
#endif

#import "IGListBindingSectionControllerDataSource.h"
#import "IGListBindingSectionControllerSelectionDelegate.h"
#import "IGListSectionController.h"
Expand Down
4 changes: 4 additions & 0 deletions Source/IGListKit/IGListBindingSectionController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

#import "IGListBindingSectionController.h"

#if !__has_include(<IGListDiffKit/IGListDiffKit.h>)
#import "IGListAssert.h"
#else
#import <IGListDiffKit/IGListAssert.h>
#endif
#import "IGListBindable.h"

#import "IGListArrayUtilsInternal.h"
Expand Down
62 changes: 33 additions & 29 deletions Source/IGListKit/IGListCollectionViewLayout.mm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

#import <vector>

#if !__has_include(<IGListDiffKit/IGListDiffKit.h>)
#import "IGListAssert.h"
#else
#import <IGListDiffKit/IGListAssert.h>
#endif
#import "IGListCollectionViewDelegateLayout.h"

#import "UIScrollView+IGListKit.h"
Expand Down Expand Up @@ -500,32 +504,32 @@ - (void)_calculateLayoutIfNeeded {
const UIEdgeInsets insets = [delegate collectionView:collectionView layout:self insetForSectionAtIndex:section];
const CGFloat lineSpacing = [delegate collectionView:collectionView layout:self minimumLineSpacingForSectionAtIndex:section];
const CGFloat interitemSpacing = [delegate collectionView:collectionView layout:self minimumInteritemSpacingForSectionAtIndex:section];

const CGSize paddedCollectionViewSize = UIEdgeInsetsInsetRect(contentInsetAdjustedCollectionViewBounds, insets).size;
const UICollectionViewScrollDirection fixedDirection = self.scrollDirection == UICollectionViewScrollDirectionHorizontal ? UICollectionViewScrollDirectionVertical : UICollectionViewScrollDirectionHorizontal;
const CGFloat paddedLengthInFixedDirection = CGSizeGetLengthInDirection(paddedCollectionViewSize, fixedDirection);
const CGFloat headerLengthInScrollDirection = hideHeaderWhenItemsEmpty ? 0 : CGSizeGetLengthInDirection(headerSize, self.scrollDirection);
const CGFloat footerLengthInScrollDirection = hideHeaderWhenItemsEmpty ? 0 : CGSizeGetLengthInDirection(footerSize, self.scrollDirection);
const BOOL headerExists = headerLengthInScrollDirection > 0;
const BOOL footerExists = footerLengthInScrollDirection > 0;

// start the section accounting for the header size
// header length in scroll direction is subtracted from the sectionBounds when calculating the header bounds after items are done
// this bumps the first row of items over enough to make room for the header
itemCoordInScrollDirection += headerLengthInScrollDirection;
nextRowCoordInScrollDirection += headerLengthInScrollDirection;

// add the leading inset in fixed direction in case the section falls on the same row as the previous
// if the section is newlined then the coord in fixed direction is reset
itemCoordInFixedDirection += UIEdgeInsetsLeadingInsetInDirection(insets, fixedDirection);

// the farthest in the fixed direction the frame of an item in this section can go
const CGFloat maxCoordinateInFixedDirection = CGRectGetLengthInDirection(contentInsetAdjustedCollectionViewBounds, fixedDirection) - UIEdgeInsetsTrailingInsetInDirection(insets, fixedDirection);

for (NSInteger item = 0; item < itemCount; item++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:item inSection:section];
const CGSize size = [delegate collectionView:collectionView layout:self sizeForItemAtIndexPath:indexPath];

IGAssert(CGSizeGetLengthInDirection(size, fixedDirection) <= paddedLengthInFixedDirection
|| fabs(CGSizeGetLengthInDirection(size, fixedDirection) - paddedLengthInFixedDirection) < FLT_EPSILON,
@"%@ of item %li in section %li (%.0f pt) must be less than or equal to container (%.0f pt) accounting for section insets %@",
Expand All @@ -535,9 +539,9 @@ - (void)_calculateLayoutIfNeeded {
CGSizeGetLengthInDirection(size, fixedDirection),
CGRectGetLengthInDirection(contentInsetAdjustedCollectionViewBounds, fixedDirection),
NSStringFromUIEdgeInsets(insets));

CGFloat itemLengthInFixedDirection = MIN(CGSizeGetLengthInDirection(size, fixedDirection), paddedLengthInFixedDirection);

// if the origin and length in fixed direction of the item busts the size of the container
// or if this is the first item and the header has a non-zero size
// newline to the next row and reset
Expand All @@ -547,19 +551,19 @@ - (void)_calculateLayoutIfNeeded {
|| (item == 0 && headerExists)) {
itemCoordInScrollDirection = nextRowCoordInScrollDirection;
itemCoordInFixedDirection = UIEdgeInsetsLeadingInsetInDirection(insets, fixedDirection);


// if newlining, always append line spacing unless its the very first item of the section
if (item > 0) {
itemCoordInScrollDirection += lineSpacing;
}
}

const CGFloat distanceToEdge = paddedLengthInFixedDirection - (itemCoordInFixedDirection + itemLengthInFixedDirection);
if (self.stretchToEdge && distanceToEdge > 0 && distanceToEdge <= epsilon) {
itemLengthInFixedDirection = paddedLengthInFixedDirection - itemCoordInFixedDirection;
}

const CGRect rawFrame = (self.scrollDirection == UICollectionViewScrollDirectionVertical) ?
CGRectMake(itemCoordInFixedDirection,
itemCoordInScrollDirection + insets.top,
Expand All @@ -570,23 +574,23 @@ - (void)_calculateLayoutIfNeeded {
size.width,
itemLengthInFixedDirection);
const CGRect frame = IGListRectIntegralScaled(rawFrame);

_sectionData[section].itemBounds[item] = frame;

// track the max size of the row to find the coord of the next row, adjust for leading inset while iterating items
nextRowCoordInScrollDirection = MAX(CGRectGetMaxInDirection(frame, self.scrollDirection) - UIEdgeInsetsLeadingInsetInDirection(insets, self.scrollDirection), nextRowCoordInScrollDirection);

// increase the rolling coord in fixed direction appropriately and add item spacing for all items on the same row
itemCoordInFixedDirection += itemLengthInFixedDirection + interitemSpacing;

// union the rolling section bounds
if (item == 0) {
rollingSectionBounds = frame;
} else {
rollingSectionBounds = CGRectUnion(rollingSectionBounds, frame);
}
}

const CGRect headerBounds = self.scrollDirection == UICollectionViewScrollDirectionVertical ?
CGRectMake(insets.left,
itemsEmpty ? CGRectGetMaxY(rollingSectionBounds) : CGRectGetMinY(rollingSectionBounds) - headerSize.height,
Expand All @@ -596,13 +600,13 @@ - (void)_calculateLayoutIfNeeded {
insets.top,
hideHeaderWhenItemsEmpty ? 0 : headerSize.width,
paddedLengthInFixedDirection);

_sectionData[section].headerBounds = headerBounds;

if (itemsEmpty) {
rollingSectionBounds = headerBounds;
}

const CGRect footerBounds = (self.scrollDirection == UICollectionViewScrollDirectionVertical) ?
CGRectMake(insets.left,
CGRectGetMaxY(rollingSectionBounds),
Expand All @@ -612,9 +616,9 @@ - (void)_calculateLayoutIfNeeded {
insets.top,
hideHeaderWhenItemsEmpty ? 0 : footerSize.width,
paddedLengthInFixedDirection);

_sectionData[section].footerBounds = footerBounds;

// union the header before setting the bounds of the section
// only do this when the header has a size, otherwise the union stretches to box empty space
if (headerExists) {
Expand All @@ -623,28 +627,28 @@ - (void)_calculateLayoutIfNeeded {
if (footerExists) {
rollingSectionBounds = CGRectUnion(rollingSectionBounds, footerBounds);
}

_sectionData[section].bounds = rollingSectionBounds;
_sectionData[section].insets = insets;

// bump the coord for the next section with the right insets
itemCoordInFixedDirection += UIEdgeInsetsTrailingInsetInDirection(insets, fixedDirection);

// find the farthest point in the section and add the trailing inset to find the next row's coord
nextRowCoordInScrollDirection = MAX(nextRowCoordInScrollDirection, CGRectGetMaxInDirection(rollingSectionBounds, self.scrollDirection) + UIEdgeInsetsTrailingInsetInDirection(insets, self.scrollDirection));

// keep track of coordinates for partial invalidation
_sectionData[section].lastItemCoordInScrollDirection = itemCoordInScrollDirection;
_sectionData[section].lastItemCoordInFixedDirection = itemCoordInFixedDirection;
_sectionData[section].lastNextRowCoordInScrollDirection = nextRowCoordInScrollDirection;
}

_minimumInvalidatedSection = NSNotFound;
}

- (NSRange)_rangeOfSectionsInRect:(CGRect)rect {
NSRange result = NSMakeRange(NSNotFound, 0);

const NSInteger sectionCount = _sectionData.size();
for (NSInteger section = 0; section < sectionCount; section++) {
IGListSectionEntry entry = _sectionData[section];
Expand All @@ -657,7 +661,7 @@ - (NSRange)_rangeOfSectionsInRect:(CGRect)rect {
}
}
}

return result;
}

Expand Down
19 changes: 18 additions & 1 deletion Source/IGListKit/IGListKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/

#if !__has_include(<IGListDiffKit/IGListDiffKit.h>)
#import "IGListCompatibility.h"
#else
#import <IGListDiffKit/IGListCompatibility.h>
#endif

/**
* Project version number for IGListKit.
Expand Down Expand Up @@ -52,6 +56,7 @@ FOUNDATION_EXPORT const unsigned char IGListKitVersionString[];

// Shared (iOS, tvOS, macOS compatible):

#if !__has_include(<IGListDiffKit/IGListDiffKit.h>)
#import "IGListAssert.h"
#import "IGListBatchUpdateData.h"
#import "IGListDiff.h"
Expand All @@ -63,4 +68,16 @@ FOUNDATION_EXPORT const unsigned char IGListKitVersionString[];
#import "IGListMoveIndexPath.h"
#import "NSNumber+IGListDiffable.h"
#import "NSString+IGListDiffable.h"

#else
#import <IGListDiffKit/IGListAssert.h>
#import <IGListDiffKit/IGListBatchUpdateData.h>
#import <IGListDiffKit/IGListDiff.h>
#import <IGListDiffKit/IGListDiffable.h>
#import <IGListDiffKit/IGListExperiments.h>
#import <IGListDiffKit/IGListIndexPathResult.h>
#import <IGListDiffKit/IGListIndexSetResult.h>
#import <IGListDiffKit/IGListMoveIndex.h>
#import <IGListDiffKit/IGListMoveIndexPath.h>
#import <IGListDiffKit/NSNumber+IGListDiffable.h>
#import <IGListDiffKit/NSString+IGListDiffable.h>
#endif
5 changes: 5 additions & 0 deletions Source/IGListKit/IGListSingleSectionController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

#import "IGListSingleSectionController.h"

#if !__has_include(<IGListDiffKit/IGListDiffKit.h>)
#import "IGListAssert.h"
#else
#import <IGListDiffKit/IGListAssert.h>
#endif


@interface IGListSingleSectionController ()

Expand Down
4 changes: 4 additions & 0 deletions Source/IGListKit/Internal/IGListAdapter+UICollectionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

#import "IGListAdapter+UICollectionView.h"

#if !__has_include(<IGListDiffKit/IGListDiffKit.h>)
#import "IGListAssert.h"
#else
#import <IGListDiffKit/IGListAssert.h>
#endif
#import "IGListAdapterInternal.h"
#import "IGListSectionController.h"
#import "IGListSectionControllerInternal.h"
Expand Down
4 changes: 4 additions & 0 deletions Source/IGListKit/Internal/IGListAdapterProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

#import "IGListAdapterProxy.h"

#if !__has_include(<IGListDiffKit/IGListDiffKit.h>)
#import "IGListAssert.h"
#else
#import <IGListDiffKit/IGListAssert.h>
#endif

#import "IGListCollectionViewDelegateLayout.h"

Expand Down
4 changes: 4 additions & 0 deletions Source/IGListKit/Internal/IGListDisplayHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

#import "IGListDisplayHandler.h"

#if !__has_include(<IGListDiffKit/IGListDiffKit.h>)
#import "IGListAssert.h"
#else
#import <IGListDiffKit/IGListAssert.h>
#endif
#import "IGListAdapter.h"
#import "IGListDisplayDelegate.h"
#import "IGListSectionController.h"
Expand Down
4 changes: 4 additions & 0 deletions Source/IGListKit/Internal/IGListSectionMap.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

#import "IGListSectionMap.h"

#if !__has_include(<IGListDiffKit/IGListDiffKit.h>)
#import "IGListAssert.h"
#else
#import <IGListDiffKit/IGListAssert.h>
#endif

#import "IGListSectionControllerInternal.h"

Expand Down
4 changes: 4 additions & 0 deletions Source/IGListKit/Internal/IGListWorkingRangeHandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
#import <set>
#import <unordered_set>

#if !__has_include(<IGListDiffKit/IGListDiffKit.h>)
#import "IGListAssert.h"
#else
#import <IGListDiffKit/IGListAssert.h>
#endif
#import "IGListAdapter.h"
#import "IGListSectionController.h"

Expand Down

0 comments on commit 0482dc3

Please sign in to comment.