Skip to content
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

Merged
merged 6 commits into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Source/ASCollectionNode+Beta.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,23 @@ NS_ASSUME_NONNULL_BEGIN
@property (nullable, nonatomic, weak) id<ASBatchFetchingDelegate> batchFetchingDelegate;

/**
* When this mode is enabled, ASCollectionView matches the timing of UICollectionView as closely as possible,
* ensuring that all reload and edit operations are performed on the main thread as blocking calls.
* When this mode is enabled, ASCollectionView matches the timing of UICollectionView as closely as
* possible, ensuring that all reload and edit operations are performed on the main thread as
* blocking calls.
*
* This mode is useful for applications that are debugging issues with their collection view implementation.
* In particular, some applications do not properly conform to the API requirement of UICollectionView, and these
* applications may experience difficulties with ASCollectionView. Providing this mode allows for developers to
* work towards resolving technical debt in their collection view data source, while ramping up asynchronous
* collection layout.
* This mode is useful for applications that are debugging issues with their collection view
* implementation. In particular, some applications do not properly conform to the API requirement
* of UICollectionView, and these applications may experience difficulties with ASCollectionView.
* Providing this mode allows for developers to work towards resolving technical debt in their
* collection view data source, while ramping up asynchronous collection layout.
*
* NOTE: Because this mode results in expensive operations like cell layout being performed on the main thread,
* it should be used as a tool to resolve data source conformance issues with Apple collection view API.
* NOTE: Because this mode results in expensive operations like cell layout being performed on the
* main thread, it should be used as a tool to resolve data source conformance issues with Apple
* collection view API.
*
* @default defaults to NO.
* @default defaults to ASCellLayoutModeNone.
*/
@property (nonatomic) BOOL usesSynchronousDataLoading;
@property (nonatomic) ASCellLayoutMode cellLayoutMode;

/**
* Returns YES if the ASCollectionNode contents are completely synchronized with the underlying collection-view layout.
Expand All @@ -72,8 +74,6 @@ NS_ASSUME_NONNULL_BEGIN

- (void)endUpdatesAnimated:(BOOL)animated completion:(nullable void (^)(BOOL))completion ASDISPLAYNODE_DEPRECATED_MSG("Use -performBatchUpdates:completion: instead.");

- (void)invalidateFlowLayoutDelegateMetrics;

@end

NS_ASSUME_NONNULL_END
16 changes: 8 additions & 8 deletions Source/ASCollectionNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ @interface _ASCollectionPendingState : NSObject {
@property (nonatomic) BOOL allowsSelection; // default is YES
@property (nonatomic) BOOL allowsMultipleSelection; // default is NO
@property (nonatomic) BOOL inverted; //default is NO
@property (nonatomic) BOOL usesSynchronousDataLoading;
@property (nonatomic) ASCellLayoutMode cellLayoutMode;
@property (nonatomic) CGFloat leadingScreensForBatching;
@property (nonatomic, weak) id <ASCollectionViewLayoutInspecting> layoutInspector;
@property (nonatomic) BOOL alwaysBounceVertical;
Expand Down Expand Up @@ -193,7 +193,7 @@ - (void)didLoad
view.inverted = pendingState.inverted;
view.allowsSelection = pendingState.allowsSelection;
view.allowsMultipleSelection = pendingState.allowsMultipleSelection;
view.usesSynchronousDataLoading = pendingState.usesSynchronousDataLoading;
view.cellLayoutMode = pendingState.cellLayoutMode;
view.layoutInspector = pendingState.layoutInspector;
view.showsVerticalScrollIndicator = pendingState.showsVerticalScrollIndicator;
view.showsHorizontalScrollIndicator = pendingState.showsHorizontalScrollIndicator;
Expand Down Expand Up @@ -628,21 +628,21 @@ - (void)setBatchFetchingDelegate:(id<ASBatchFetchingDelegate>)batchFetchingDeleg
return _batchFetchingDelegate;
}

- (BOOL)usesSynchronousDataLoading
- (ASCellLayoutMode)cellLayoutMode
{
if ([self pendingState]) {
return _pendingState.usesSynchronousDataLoading;
return _pendingState.cellLayoutMode;
} else {
return self.view.usesSynchronousDataLoading;
return self.view.cellLayoutMode;
}
}

- (void)setUsesSynchronousDataLoading:(BOOL)usesSynchronousDataLoading
- (void)setCellLayoutMode:(ASCellLayoutMode)cellLayoutMode
{
if ([self pendingState]) {
_pendingState.usesSynchronousDataLoading = usesSynchronousDataLoading;
_pendingState.cellLayoutMode = cellLayoutMode;
} else {
self.view.usesSynchronousDataLoading = usesSynchronousDataLoading;
self.view.cellLayoutMode = cellLayoutMode;
}
}

Expand Down
Loading