mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
[Umbrella] ASCollectionView -> ASCollectionNode Migration, Separate Index Spaces (#2372)
* Separate dataSource & UIKit index spaces Beef up our supplementary node support Make the API way better Go nuts Add a unit test for UICollectionView's handling of reloadData inside batch updates Wrap indexPathForNode: in a cache Convert index paths in delegate methods Go back on table view Put collection view back Switch up the API Move most ASCollectionView API to ASCollectionNode Move most table logic over to ASTableNode Do the things More conversion work Keep on keepin' on Get table view delegate API done More porting Simplify Clear the delegate More cleanup Move more stuff around Remove pointless file Re-add some API Put back more API Use the right flag * Some cleanup * Remove incorrect comment * Tweak the API * Put back a couple methods * update example projects (note: ASCollectionView deprecation warnings expected) * change reloadDataWithCompletion:nil --> reloadData * Clean up rebase * Make deprecated numberOfItemsInSection methods optional * Use the right flag * Address nits * update ASDKTube, ASDKgram & ASViewController examples
This commit is contained in:
@@ -38,32 +38,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
@interface ASCollectionView : UICollectionView
|
||||
|
||||
/**
|
||||
* Initializes an ASCollectionView
|
||||
*
|
||||
* @discussion Initializes and returns a newly allocated collection view object with the specified layout.
|
||||
*
|
||||
* @param layout The layout object to use for organizing items. The collection view stores a strong reference to the specified object. Must not be nil.
|
||||
*/
|
||||
- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout;
|
||||
|
||||
/**
|
||||
* Initializes an ASCollectionView
|
||||
*
|
||||
* @discussion Initializes and returns a newly allocated collection view object with the specified frame and layout.
|
||||
*
|
||||
* @param frame The frame rectangle for the collection view, measured in points. The origin of the frame is relative to the superview in which you plan to add it. This frame is passed to the superclass during initialization.
|
||||
* @param layout The layout object to use for organizing items. The collection view stores a strong reference to the specified object. Must not be nil.
|
||||
*/
|
||||
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout;
|
||||
|
||||
/**
|
||||
* Returns the corresponding ASCollectionNode
|
||||
*
|
||||
* @return collectionNode The corresponding ASCollectionNode which exists even if directly allocating & handling the view class.
|
||||
*/
|
||||
@property (nonatomic, weak, readonly) ASCollectionNode *collectionNode;
|
||||
|
||||
/**
|
||||
* The object that acts as the asynchronous delegate of the collection view
|
||||
*
|
||||
@@ -83,52 +57,11 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic, weak) id<ASCollectionDataSource> asyncDataSource;
|
||||
|
||||
/**
|
||||
* Tuning parameters for a range type in full mode.
|
||||
* Returns the corresponding ASCollectionNode
|
||||
*
|
||||
* @param rangeType The range type to get the tuning parameters for.
|
||||
*
|
||||
* @return A tuning parameter value for the given range type in full mode.
|
||||
*
|
||||
* @see ASLayoutRangeMode
|
||||
* @see ASLayoutRangeType
|
||||
* @return collectionNode The corresponding ASCollectionNode, if one exists.
|
||||
*/
|
||||
- (ASRangeTuningParameters)tuningParametersForRangeType:(ASLayoutRangeType)rangeType AS_WARN_UNUSED_RESULT;
|
||||
|
||||
/**
|
||||
* Set the tuning parameters for a range type in full mode.
|
||||
*
|
||||
* @param tuningParameters The tuning parameters to store for a range type.
|
||||
* @param rangeType The range type to set the tuning parameters for.
|
||||
*
|
||||
* @see ASLayoutRangeMode
|
||||
* @see ASLayoutRangeType
|
||||
*/
|
||||
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType;
|
||||
|
||||
/**
|
||||
* Tuning parameters for a range type in the specified mode.
|
||||
*
|
||||
* @param rangeMode The range mode to get the running parameters for.
|
||||
* @param rangeType The range type to get the tuning parameters for.
|
||||
*
|
||||
* @return A tuning parameter value for the given range type in the given mode.
|
||||
*
|
||||
* @see ASLayoutRangeMode
|
||||
* @see ASLayoutRangeType
|
||||
*/
|
||||
- (ASRangeTuningParameters)tuningParametersForRangeMode:(ASLayoutRangeMode)rangeMode rangeType:(ASLayoutRangeType)rangeType AS_WARN_UNUSED_RESULT;
|
||||
|
||||
/**
|
||||
* Set the tuning parameters for a range type in the specified mode.
|
||||
*
|
||||
* @param tuningParameters The tuning parameters to store for a range type.
|
||||
* @param rangeMode The range mode to set the running parameters for.
|
||||
* @param rangeType The range type to set the tuning parameters for.
|
||||
*
|
||||
* @see ASLayoutRangeMode
|
||||
* @see ASLayoutRangeType
|
||||
*/
|
||||
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeMode:(ASLayoutRangeMode)rangeMode rangeType:(ASLayoutRangeType)rangeType;
|
||||
@property (nonatomic, weak, readonly) ASCollectionNode *collectionNode;
|
||||
|
||||
/**
|
||||
* The number of screens left to scroll before the delegate -collectionView:beginBatchFetchingWithContext: is called.
|
||||
@@ -150,204 +83,32 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic, weak) id<ASCollectionViewLayoutInspecting> layoutInspector;
|
||||
|
||||
/**
|
||||
* Perform a batch of updates asynchronously, optionally disabling all animations in the batch. This method must be called from the main thread.
|
||||
* The asyncDataSource must be updated to reflect the changes before the update block completes.
|
||||
*
|
||||
* @param animated NO to disable animations for this batch
|
||||
* @param updates The block that performs the relevant insert, delete, reload, or move operations.
|
||||
* @param completion A completion handler block to execute when all of the operations are finished. This block takes a single
|
||||
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
|
||||
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
|
||||
*/
|
||||
- (void)performBatchAnimated:(BOOL)animated updates:(nullable __attribute((noescape)) void (^)())updates completion:(nullable void (^)(BOOL finished))completion;
|
||||
|
||||
/**
|
||||
* Perform a batch of updates asynchronously. This method must be called from the main thread.
|
||||
* The asyncDataSource must be updated to reflect the changes before update block completes.
|
||||
*
|
||||
* @param updates The block that performs the relevant insert, delete, reload, or move operations.
|
||||
* @param completion A completion handler block to execute when all of the operations are finished. This block takes a single
|
||||
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
|
||||
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
|
||||
*/
|
||||
- (void)performBatchUpdates:(nullable __attribute((noescape)) void (^)())updates completion:(nullable void (^)(BOOL finished))completion;
|
||||
|
||||
/**
|
||||
* Reload everything from scratch, destroying the working range and all cached nodes.
|
||||
*
|
||||
* @param completion block to run on completion of asynchronous loading or nil. If supplied, the block is run on
|
||||
* the main thread.
|
||||
* @warning This method is substantially more expensive than UICollectionView's version.
|
||||
*/
|
||||
- (void)reloadDataWithCompletion:(nullable void (^)())completion;
|
||||
|
||||
/**
|
||||
* Reload everything from scratch, destroying the working range and all cached nodes.
|
||||
*
|
||||
* @warning This method is substantially more expensive than UICollectionView's version.
|
||||
*/
|
||||
- (void)reloadData;
|
||||
|
||||
/**
|
||||
* Reload everything from scratch entirely on the main thread, destroying the working range and all cached nodes.
|
||||
*
|
||||
* @warning This method is substantially more expensive than UICollectionView's version and will block the main thread
|
||||
* while all the cells load.
|
||||
*/
|
||||
- (void)reloadDataImmediately;
|
||||
|
||||
/**
|
||||
* Triggers a relayout of all nodes.
|
||||
*
|
||||
* @discussion This method invalidates and lays out every cell node in the collection view.
|
||||
*/
|
||||
- (void)relayoutItems;
|
||||
|
||||
/**
|
||||
* Blocks execution of the main thread until all section and row updates are committed. This method must be called from the main thread.
|
||||
*/
|
||||
- (void)waitUntilAllUpdatesAreCommitted;
|
||||
|
||||
/**
|
||||
* Registers the given kind of supplementary node for use in creating node-backed supplementary views.
|
||||
*
|
||||
* @param elementKind The kind of supplementary node that will be requested through the data source.
|
||||
*
|
||||
* @discussion Use this method to register support for the use of supplementary nodes in place of the default
|
||||
* `registerClass:forSupplementaryViewOfKind:withReuseIdentifier:` and `registerNib:forSupplementaryViewOfKind:withReuseIdentifier:`
|
||||
* methods. This method will register an internal backing view that will host the contents of the supplementary nodes
|
||||
* returned from the data source.
|
||||
*/
|
||||
- (void)registerSupplementaryNodeOfKind:(NSString *)elementKind;
|
||||
|
||||
/**
|
||||
* Inserts one or more sections.
|
||||
*
|
||||
* @param sections An index set that specifies the sections to insert.
|
||||
*
|
||||
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
|
||||
* before this method is called.
|
||||
*/
|
||||
- (void)insertSections:(NSIndexSet *)sections;
|
||||
|
||||
/**
|
||||
* Deletes one or more sections.
|
||||
*
|
||||
* @param sections An index set that specifies the sections to delete.
|
||||
*
|
||||
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
|
||||
* before this method is called.
|
||||
*/
|
||||
- (void)deleteSections:(NSIndexSet *)sections;
|
||||
|
||||
/**
|
||||
* Reloads the specified sections.
|
||||
*
|
||||
* @param sections An index set that specifies the sections to reload.
|
||||
*
|
||||
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
|
||||
* before this method is called.
|
||||
*/
|
||||
- (void)reloadSections:(NSIndexSet *)sections;
|
||||
|
||||
/**
|
||||
* Moves a section to a new location.
|
||||
*
|
||||
* @param section The index of the section to move.
|
||||
*
|
||||
* @param newSection The index that is the destination of the move for the section.
|
||||
*
|
||||
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
|
||||
* before this method is called.
|
||||
*/
|
||||
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection;
|
||||
|
||||
- (nullable id<ASSectionContext>)contextForSection:(NSInteger)section AS_WARN_UNUSED_RESULT;
|
||||
|
||||
/**
|
||||
* Inserts items at the locations identified by an array of index paths.
|
||||
*
|
||||
* @param indexPaths An array of NSIndexPath objects, each representing an item index and section index that together identify an item.
|
||||
*
|
||||
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
|
||||
* before this method is called.
|
||||
*/
|
||||
- (void)insertItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths;
|
||||
|
||||
/**
|
||||
* Deletes the items specified by an array of index paths.
|
||||
*
|
||||
* @param indexPaths An array of NSIndexPath objects identifying the items to delete.
|
||||
*
|
||||
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
|
||||
* before this method is called.
|
||||
*/
|
||||
- (void)deleteItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths;
|
||||
|
||||
/**
|
||||
* Reloads the specified items.
|
||||
*
|
||||
* @param indexPaths An array of NSIndexPath objects identifying the items to reload.
|
||||
*
|
||||
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
|
||||
* before this method is called.
|
||||
*/
|
||||
- (void)reloadItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths;
|
||||
|
||||
/**
|
||||
* Moves the item at a specified location to a destination location.
|
||||
*
|
||||
* @param indexPath The index path identifying the item to move.
|
||||
*
|
||||
* @param newIndexPath The index path that is the destination of the move for the item.
|
||||
*
|
||||
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
|
||||
* before this method is called.
|
||||
*/
|
||||
- (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath;
|
||||
|
||||
/**
|
||||
* Similar to -cellForItemAtIndexPath:.
|
||||
* Retrieves the node for the item at the given index path.
|
||||
*
|
||||
* @param indexPath The index path of the requested node.
|
||||
*
|
||||
* @return a node for display at this indexpath or nil
|
||||
* @return The node at the given index path, or @c nil if no item exists at the specified path.
|
||||
*/
|
||||
- (nullable ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath AS_WARN_UNUSED_RESULT;
|
||||
|
||||
|
||||
/**
|
||||
* Similar to -supplementaryViewForElementKind:atIndexPath:
|
||||
*
|
||||
* @param elementKind The kind of supplementary node to locate.
|
||||
* @param indexPath The index path of the requested supplementary node.
|
||||
*
|
||||
* @return The specified supplementary node or nil
|
||||
* @return The specified supplementary node or @c nil.
|
||||
*/
|
||||
- (nullable ASCellNode *)supplementaryNodeForElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath AS_WARN_UNUSED_RESULT;
|
||||
|
||||
/**
|
||||
* Similar to -indexPathForCell:.
|
||||
* Retrieves the context object for the given section, as provided by the data source in
|
||||
* the @c collectionNode:contextForSection: method. This method must be called on the main thread.
|
||||
*
|
||||
* @param cellNode a cellNode part of the table view
|
||||
* @param section The section to get the context for.
|
||||
*
|
||||
* @return an indexPath for this cellNode
|
||||
* @return The context object, or @c nil if no context was provided.
|
||||
*/
|
||||
- (NSIndexPath *)indexPathForNode:(ASCellNode *)cellNode AS_WARN_UNUSED_RESULT;
|
||||
|
||||
/**
|
||||
* Similar to -visibleCells.
|
||||
*
|
||||
* @return an array containing the nodes being displayed on screen.
|
||||
*/
|
||||
- (NSArray<__kindof ASCellNode *> *)visibleNodes AS_WARN_UNUSED_RESULT;
|
||||
|
||||
/**
|
||||
* Query the sized node at `indexPath` for its calculatedSize.
|
||||
*
|
||||
* @param indexPath The index path for the node of interest.
|
||||
*/
|
||||
- (CGSize)calculatedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath AS_WARN_UNUSED_RESULT;
|
||||
- (nullable id<ASSectionContext>)contextForSection:(NSInteger)section AS_WARN_UNUSED_RESULT;
|
||||
|
||||
/**
|
||||
* Determines collection view's current scroll direction. Supports 2-axis collection views.
|
||||
@@ -363,20 +124,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
@property (nonatomic, readonly) ASScrollDirection scrollableDirections;
|
||||
|
||||
/**
|
||||
* Triggers all loaded ASCellNodes to destroy displayed contents (freeing a lot of memory).
|
||||
*
|
||||
* @discussion This method should only be called by ASCollectionNode. To be removed in a later release.
|
||||
*/
|
||||
- (void)clearContents;
|
||||
|
||||
/**
|
||||
* Triggers all loaded ASCellNodes to purge any data fetched from the network or disk (freeing memory).
|
||||
*
|
||||
* @discussion This method should only be called by ASCollectionNode. To be removed in a later release.
|
||||
*/
|
||||
- (void)clearFetchedData;
|
||||
|
||||
/**
|
||||
* Forces the .contentInset to be UIEdgeInsetsZero.
|
||||
*
|
||||
@@ -389,173 +136,274 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@end
|
||||
|
||||
@interface ASCollectionView (Deprecated)
|
||||
|
||||
/**
|
||||
* This is a node-based UICollectionViewDataSource.
|
||||
* Initializes an ASCollectionView
|
||||
*
|
||||
* @discussion Initializes and returns a newly allocated collection view object with the specified layout.
|
||||
*
|
||||
* @param layout The layout object to use for organizing items. The collection view stores a strong reference to the specified object. Must not be nil.
|
||||
*/
|
||||
#define ASCollectionViewDataSource ASCollectionDataSource
|
||||
@protocol ASCollectionDataSource <ASCommonCollectionViewDataSource>
|
||||
|
||||
@optional
|
||||
- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Similar to -collectionView:cellForItemAtIndexPath:.
|
||||
* Initializes an ASCollectionView
|
||||
*
|
||||
* @param collectionView The sender.
|
||||
* @discussion Initializes and returns a newly allocated collection view object with the specified frame and layout.
|
||||
*
|
||||
* @param indexPath The index path of the requested node.
|
||||
*
|
||||
* @return a node for display at this indexpath. This will be called on the main thread and should
|
||||
* not implement reuse (it will be called once per row). Unlike UICollectionView's version,
|
||||
* this method is not called when the row is about to display.
|
||||
* @param frame The frame rectangle for the collection view, measured in points. The origin of the frame is relative to the superview in which you plan to add it. This frame is passed to the superclass during initialization.
|
||||
* @param layout The layout object to use for organizing items. The collection view stores a strong reference to the specified object. Must not be nil.
|
||||
*/
|
||||
- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForItemAtIndexPath:(NSIndexPath *)indexPath;
|
||||
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Similar to -collectionView:nodeForItemAtIndexPath:
|
||||
* This method takes precedence over collectionView:nodeForItemAtIndexPath: if implemented.
|
||||
* Tuning parameters for a range type in full mode.
|
||||
*
|
||||
* @param collectionView The sender.
|
||||
* @param rangeType The range type to get the tuning parameters for.
|
||||
*
|
||||
* @param indexPath The index path of the requested node.
|
||||
* @return A tuning parameter value for the given range type in full mode.
|
||||
*
|
||||
* @return a block that creates the node for display at this indexpath.
|
||||
* Must be thread-safe (can be called on the main thread or a background
|
||||
* queue) and should not implement reuse (it will be called once per row).
|
||||
* @see ASLayoutRangeMode
|
||||
* @see ASLayoutRangeType
|
||||
*/
|
||||
- (ASCellNodeBlock)collectionView:(ASCollectionView *)collectionView nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath;
|
||||
- (ASRangeTuningParameters)tuningParametersForRangeType:(ASLayoutRangeType)rangeType AS_WARN_UNUSED_RESULT ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Asks the collection view to provide a supplementary node to display in the collection view.
|
||||
* Set the tuning parameters for a range type in full mode.
|
||||
*
|
||||
* @param collectionView An object representing the collection view requesting this information.
|
||||
* @param kind The kind of supplementary node to provide.
|
||||
* @param indexPath The index path that specifies the location of the new supplementary node.
|
||||
* @param tuningParameters The tuning parameters to store for a range type.
|
||||
* @param rangeType The range type to set the tuning parameters for.
|
||||
*
|
||||
* @see ASLayoutRangeMode
|
||||
* @see ASLayoutRangeType
|
||||
*/
|
||||
- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath;
|
||||
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Indicator to lock the data source for data fetching in async mode.
|
||||
* We should not update the data source until the data source has been unlocked. Otherwise, it will incur data inconsistency or exception
|
||||
* due to the data access in async mode.
|
||||
* Tuning parameters for a range type in the specified mode.
|
||||
*
|
||||
* @param collectionView The sender.
|
||||
* @deprecated The data source is always accessed on the main thread, and this method will not be called.
|
||||
* @param rangeMode The range mode to get the running parameters for.
|
||||
* @param rangeType The range type to get the tuning parameters for.
|
||||
*
|
||||
* @return A tuning parameter value for the given range type in the given mode.
|
||||
*
|
||||
* @see ASLayoutRangeMode
|
||||
* @see ASLayoutRangeType
|
||||
*/
|
||||
- (void)collectionViewLockDataSource:(ASCollectionView *)collectionView ASDISPLAYNODE_DEPRECATED;
|
||||
- (ASRangeTuningParameters)tuningParametersForRangeMode:(ASLayoutRangeMode)rangeMode rangeType:(ASLayoutRangeType)rangeType AS_WARN_UNUSED_RESULT ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Indicator to unlock the data source for data fetching in async mode.
|
||||
* We should not update the data source until the data source has been unlocked. Otherwise, it will incur data inconsistency or exception
|
||||
* due to the data access in async mode.
|
||||
* Set the tuning parameters for a range type in the specified mode.
|
||||
*
|
||||
* @param collectionView The sender.
|
||||
* @deprecated The data source is always accessed on the main thread, and this method will not be called.
|
||||
* @param tuningParameters The tuning parameters to store for a range type.
|
||||
* @param rangeMode The range mode to set the running parameters for.
|
||||
* @param rangeType The range type to set the tuning parameters for.
|
||||
*
|
||||
* @see ASLayoutRangeMode
|
||||
* @see ASLayoutRangeType
|
||||
*/
|
||||
- (void)collectionViewUnlockDataSource:(ASCollectionView *)collectionView ASDISPLAYNODE_DEPRECATED;
|
||||
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeMode:(ASLayoutRangeMode)rangeMode rangeType:(ASLayoutRangeType)rangeType ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
- (nullable id<ASSectionContext>)collectionView:(ASCollectionView *)collectionView contextForSection:(NSInteger)section;
|
||||
/**
|
||||
* Perform a batch of updates asynchronously, optionally disabling all animations in the batch. This method must be called from the main thread.
|
||||
* The asyncDataSource must be updated to reflect the changes before the update block completes.
|
||||
*
|
||||
* @param animated NO to disable animations for this batch
|
||||
* @param updates The block that performs the relevant insert, delete, reload, or move operations.
|
||||
* @param completion A completion handler block to execute when all of the operations are finished. This block takes a single
|
||||
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
|
||||
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
|
||||
*/
|
||||
- (void)performBatchAnimated:(BOOL)animated updates:(nullable __attribute((noescape)) void (^)())updates completion:(nullable void (^)(BOOL finished))completion ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Perform a batch of updates asynchronously. This method must be called from the main thread.
|
||||
* The asyncDataSource must be updated to reflect the changes before update block completes.
|
||||
*
|
||||
* @param updates The block that performs the relevant insert, delete, reload, or move operations.
|
||||
* @param completion A completion handler block to execute when all of the operations are finished. This block takes a single
|
||||
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
|
||||
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
|
||||
*/
|
||||
- (void)performBatchUpdates:(nullable __attribute((noescape)) void (^)())updates completion:(nullable void (^)(BOOL finished))completion ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Reload everything from scratch, destroying the working range and all cached nodes.
|
||||
*
|
||||
* @param completion block to run on completion of asynchronous loading or nil. If supplied, the block is run on
|
||||
* the main thread.
|
||||
* @warning This method is substantially more expensive than UICollectionView's version.
|
||||
*/
|
||||
- (void)reloadDataWithCompletion:(nullable void (^)())completion ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Reload everything from scratch, destroying the working range and all cached nodes.
|
||||
*
|
||||
* @warning This method is substantially more expensive than UICollectionView's version.
|
||||
*/
|
||||
- (void)reloadData ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Reload everything from scratch entirely on the main thread, destroying the working range and all cached nodes.
|
||||
*
|
||||
* @warning This method is substantially more expensive than UICollectionView's version and will block the main thread
|
||||
* while all the cells load.
|
||||
*/
|
||||
- (void)reloadDataImmediately ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Triggers a relayout of all nodes.
|
||||
*
|
||||
* @discussion This method invalidates and lays out every cell node in the collection.
|
||||
*/
|
||||
- (void)relayoutItems ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Blocks execution of the main thread until all section and row updates are committed. This method must be called from the main thread.
|
||||
*/
|
||||
- (void)waitUntilAllUpdatesAreCommitted ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Registers the given kind of supplementary node for use in creating node-backed supplementary views.
|
||||
*
|
||||
* @param elementKind The kind of supplementary node that will be requested through the data source.
|
||||
*
|
||||
* @discussion Use this method to register support for the use of supplementary nodes in place of the default
|
||||
* `registerClass:forSupplementaryViewOfKind:withReuseIdentifier:` and `registerNib:forSupplementaryViewOfKind:withReuseIdentifier:`
|
||||
* methods. This method will register an internal backing view that will host the contents of the supplementary nodes
|
||||
* returned from the data source.
|
||||
*/
|
||||
- (void)registerSupplementaryNodeOfKind:(NSString *)elementKind ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Inserts one or more sections.
|
||||
*
|
||||
* @param sections An index set that specifies the sections to insert.
|
||||
*
|
||||
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
|
||||
* before this method is called.
|
||||
*/
|
||||
- (void)insertSections:(NSIndexSet *)sections ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Deletes one or more sections.
|
||||
*
|
||||
* @param sections An index set that specifies the sections to delete.
|
||||
*
|
||||
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
|
||||
* before this method is called.
|
||||
*/
|
||||
- (void)deleteSections:(NSIndexSet *)sections ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Reloads the specified sections.
|
||||
*
|
||||
* @param sections An index set that specifies the sections to reload.
|
||||
*
|
||||
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
|
||||
* before this method is called.
|
||||
*/
|
||||
- (void)reloadSections:(NSIndexSet *)sections ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Moves a section to a new location.
|
||||
*
|
||||
* @param section The index of the section to move.
|
||||
*
|
||||
* @param newSection The index that is the destination of the move for the section.
|
||||
*
|
||||
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
|
||||
* before this method is called.
|
||||
*/
|
||||
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Inserts items at the locations identified by an array of index paths.
|
||||
*
|
||||
* @param indexPaths An array of NSIndexPath objects, each representing an item index and section index that together identify an item.
|
||||
*
|
||||
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
|
||||
* before this method is called.
|
||||
*/
|
||||
- (void)insertItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Deletes the items specified by an array of index paths.
|
||||
*
|
||||
* @param indexPaths An array of NSIndexPath objects identifying the items to delete.
|
||||
*
|
||||
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
|
||||
* before this method is called.
|
||||
*/
|
||||
- (void)deleteItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Reloads the specified items.
|
||||
*
|
||||
* @param indexPaths An array of NSIndexPath objects identifying the items to reload.
|
||||
*
|
||||
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
|
||||
* before this method is called.
|
||||
*/
|
||||
- (void)reloadItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Moves the item at a specified location to a destination location.
|
||||
*
|
||||
* @param indexPath The index path identifying the item to move.
|
||||
*
|
||||
* @param newIndexPath The index path that is the destination of the move for the item.
|
||||
*
|
||||
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
|
||||
* before this method is called.
|
||||
*/
|
||||
- (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Query the sized node at @c indexPath for its calculatedSize.
|
||||
*
|
||||
* @param indexPath The index path for the node of interest.
|
||||
*
|
||||
* This method is deprecated. Call @c calculatedSize on the node of interest instead. First deprecated in version 2.0.
|
||||
*/
|
||||
- (CGSize)calculatedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Similar to -visibleCells.
|
||||
*
|
||||
* @return an array containing the nodes being displayed on screen.
|
||||
*/
|
||||
- (NSArray<__kindof ASCellNode *> *)visibleNodes AS_WARN_UNUSED_RESULT ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Similar to -indexPathForCell:.
|
||||
*
|
||||
* @param cellNode a cellNode in the collection view
|
||||
*
|
||||
* @return The index path for this cell node.
|
||||
*
|
||||
* @discussion This index path returned by this method is in the _view's_ index space
|
||||
* and should only be used with @c ASCollectionView directly. To get an index path suitable
|
||||
* for use with your data source and @c ASCollectionNode, call @c indexPathForNode: on the
|
||||
* collection node instead.
|
||||
*/
|
||||
- (nullable NSIndexPath *)indexPathForNode:(ASCellNode *)cellNode AS_WARN_UNUSED_RESULT ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
@end
|
||||
|
||||
ASDISPLAYNODE_DEPRECATED
|
||||
@protocol ASCollectionViewDataSource <ASCollectionDataSource>
|
||||
@end
|
||||
|
||||
/**
|
||||
* This is a node-based UICollectionViewDelegate.
|
||||
*/
|
||||
#define ASCollectionViewDelegate ASCollectionDelegate
|
||||
@protocol ASCollectionDelegate <ASCommonCollectionViewDelegate, NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
/**
|
||||
* Provides the constrained size range for measuring the node at the index path.
|
||||
*
|
||||
* @param collectionView The sender.
|
||||
*
|
||||
* @param indexPath The index path of the node.
|
||||
*
|
||||
* @return A constrained size range for layout the node at this index path.
|
||||
*/
|
||||
- (ASSizeRange)collectionView:(ASCollectionView *)collectionView constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath;
|
||||
|
||||
/**
|
||||
* Informs the delegate that the collection view will add the given node
|
||||
* at the given index path to the view hierarchy.
|
||||
*
|
||||
* @param collectionView The sender.
|
||||
* @param node The node that will be displayed.
|
||||
* @param indexPath The index path of the item that will be displayed.
|
||||
*
|
||||
* @warning AsyncDisplayKit processes collection view edits asynchronously. The index path
|
||||
* passed into this method may not correspond to the same item in your data source
|
||||
* if your data source has been updated since the last edit was processed.
|
||||
*/
|
||||
- (void)collectionView:(ASCollectionView *)collectionView willDisplayNode:(ASCellNode *)node forItemAtIndexPath:(NSIndexPath *)indexPath;
|
||||
|
||||
/**
|
||||
* Informs the delegate that the collection view did remove the provided node from the view hierarchy.
|
||||
* This may be caused by the node scrolling out of view, or by deleting the item
|
||||
* or its containing section with @c deleteItemsAtIndexPaths: or @c deleteSections: .
|
||||
*
|
||||
* @param collectionView The sender.
|
||||
* @param node The node which was removed from the view hierarchy.
|
||||
* @param indexPath The index path at which the node was located before it was removed.
|
||||
*
|
||||
* @warning AsyncDisplayKit processes collection view edits asynchronously. The index path
|
||||
* passed into this method may not correspond to the same item in your data source
|
||||
* if your data source has been updated since the last edit was processed.
|
||||
*/
|
||||
- (void)collectionView:(ASCollectionView *)collectionView didEndDisplayingNode:(ASCellNode *)node forItemAtIndexPath:(NSIndexPath *)indexPath;
|
||||
|
||||
/**
|
||||
* Receive a message that the collectionView is near the end of its data set and more data should be fetched if
|
||||
* necessary.
|
||||
*
|
||||
* @param collectionView The sender.
|
||||
* @param context A context object that must be notified when the batch fetch is completed.
|
||||
*
|
||||
* @discussion You must eventually call -completeBatchFetching: with an argument of YES in order to receive future
|
||||
* notifications to do batch fetches. This method is called on a background queue.
|
||||
*
|
||||
* UICollectionView currently only supports batch events for tail loads. If you require a head load, consider
|
||||
* implementing a UIRefreshControl.
|
||||
*/
|
||||
- (void)collectionView:(ASCollectionView *)collectionView willBeginBatchFetchWithContext:(ASBatchContext *)context;
|
||||
|
||||
/**
|
||||
* Tell the collectionView if batch fetching should begin.
|
||||
*
|
||||
* @param collectionView The sender.
|
||||
*
|
||||
* @discussion Use this method to conditionally fetch batches. Example use cases are: limiting the total number of
|
||||
* objects that can be fetched or no network connection.
|
||||
*
|
||||
* If not implemented, the collectionView assumes that it should notify its asyncDelegate when batch fetching
|
||||
* should occur.
|
||||
*/
|
||||
- (BOOL)shouldBatchFetchForCollectionView:(ASCollectionView *)collectionView;
|
||||
|
||||
/**
|
||||
* Informs the delegate that the collection view will add the node
|
||||
* at the given index path to the view hierarchy.
|
||||
*
|
||||
* @param collectionView The sender.
|
||||
* @param indexPath The index path of the item that will be displayed.
|
||||
*
|
||||
* @warning AsyncDisplayKit processes collection view edits asynchronously. The index path
|
||||
* passed into this method may not correspond to the same item in your data source
|
||||
* if your data source has been updated since the last edit was processed.
|
||||
*
|
||||
* This method is deprecated. Use @c collectionView:willDisplayNode:forItemAtIndexPath: instead.
|
||||
*/
|
||||
- (void)collectionView:(ASCollectionView *)collectionView willDisplayNodeForItemAtIndexPath:(NSIndexPath *)indexPath ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
ASDISPLAYNODE_DEPRECATED
|
||||
@protocol ASCollectionViewDelegate <ASCollectionDelegate>
|
||||
@end
|
||||
|
||||
/**
|
||||
* Defines methods that let you coordinate with a `UICollectionViewFlowLayout` in combination with an `ASCollectionView`.
|
||||
*/
|
||||
@protocol ASCollectionViewDelegateFlowLayout <ASCollectionViewDelegate>
|
||||
@protocol ASCollectionViewDelegateFlowLayout <ASCollectionDelegate>
|
||||
|
||||
@optional
|
||||
|
||||
|
||||
Reference in New Issue
Block a user