-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce ASCellLayoutMode #1273
Conversation
@@ -10,6 +10,41 @@ | |||
#import <UIKit/UIKit.h> | |||
#import <AsyncDisplayKit/ASBaseDefines.h> | |||
|
|||
typedef NS_OPTIONS(NSUInteger, ASCellLayoutMode) { | |||
/** No options set. Default value. */ | |||
ASCellLayoutModeNone = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the default behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried to clarify the default values for ASCellLayoutMode
flags a bit better.
Source/ASCollectionView.mm
Outdated
} | ||
} else { | ||
[super performBatchUpdates:updates completion:completion]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have this fork in two places i.e. here and also below at 1750 and 2214?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the two places we have a different logic when to perform a batch update or reload data. In rangeController:updateWithChangeSet:updates
: besides checking for the ASCellLayoutModeAlwaysReloadData
flag we also checking some more conditions to decide if we should reload data or batch update.
That said I removed the "automatic" behavior within _superPerformBatchUpdates:completion:
and we are now explicitly calling if else in places where we would like to differentiate between the calls. It was not really obvious from a caller perspective that this automatic behavior exists in the first place.
7ca9f6b
to
ff65dcb
Compare
@Adlai-Holler Can you please give it another look. Thanks! |
@@ -869,17 +846,29 @@ - (CGSize)_sizeForUIKitCellWithKind:(NSString *)kind atIndexPath:(NSIndexPath *) | |||
return size; | |||
} | |||
|
|||
- (void)_superReloadData:(void(^)())updates completion:(void(^)(BOOL finished))completion | |||
{ | |||
if (updates) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the updates
block should be non-nil. At the very least, we want to swap the maps. If it's non-nil, we can mark it that way and skip the nil check? The main point is I don't want people to think that it can ever be nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be nil, if you just would like to call [super reloadData]
with a completion block. I actually replaced all places where we call [super reloadData]
with the call to _superReloadData
so we have one central point to call in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, I overlooked those calls. 👍
Tests/ASCollectionViewTests.mm
Outdated
@@ -1049,6 +1049,7 @@ - (void)testInitialRangeBounds | |||
UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; | |||
ASCollectionViewTestController *testController = [[ASCollectionViewTestController alloc] initWithNibName:nil bundle:nil]; | |||
ASCollectionNode *cn = testController.collectionNode; | |||
cn.cellLayoutMode = ASCellLayoutModeAlwaysAsync; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we test the default behavior? Maybe add another test case if need to for this new mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! Added a test.
@@ -869,17 +846,29 @@ - (CGSize)_sizeForUIKitCellWithKind:(NSString *)kind atIndexPath:(NSIndexPath *) | |||
return size; | |||
} | |||
|
|||
- (void)_superReloadData:(void(^)())updates completion:(void(^)(BOOL finished))completion | |||
{ | |||
if (updates) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, I overlooked those calls. 👍
604776f
to
3502636
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More than a year in the making! Thanks a lot for cleaning this up before upstreaming...there was a lot of complexity you were able to drop, @maicki. Hopefully we'll thin this down even more in the coming months, but for now it is a great feeling to be fully (or very nearly) in sync with upstream.
* Introduce ASCellLayoutMode * Some smaller improvements * Improve logic around _superPerformBatchUpdates:completion: * Add comment about default values for ASCellLayoutModeNone * Always call _superReloadData:completion: within UICollectionView * Add initial range test for ASCellLayoutModeNone
* Introduce ASCellLayoutMode * Some smaller improvements * Improve logic around _superPerformBatchUpdates:completion: * Add comment about default values for ASCellLayoutModeNone * Always call _superReloadData:completion: within UICollectionView * Add initial range test for ASCellLayoutModeNone
ASCellLayoutMode
s are flexible settings for applications to improve the flexibility of integrating Texture within an app.Providing this mode allows for developers to debug potential issues or work towards resolving technical debt in their collection view data source, while ramping up asynchronous collection layout.