mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-19 12:49:02 +00:00
* Refactor ASDataController Check optional methods in ASDataControllerSource * Reimplement reloadData * Refactor new code - No more new/inserted contexts flag - Encapsulate code shared between reloadData and updateWithChangeSet - Remove dataControllerWillDeleteAllData delegate method - Hierarchy changes no longer needs to conform to NSCopying - Reword TODOs * Forgot to call completion block of reloadData :P * Completion block of -[ASDataController reloadDataWithCompletion:] is nullable * Data queried from ASCollectionNode and ASTableNode should be in UIKit index space - This helps to avoid immature node allocation, especially when node virtualization is a thing - However, this means that -reloadDataInitiallyIfNeeded in ASCollectionNode and ASTableNode must wait until all updates are finished. * ASDataController shouldn't assume that allocated nodes were also laid out * Revert "Data queried from ASCollectionNode and ASTableNode should be in UIKit index space" This reverts commit 7bc977b3808a92f484b297781d0f5b30aa258e17. * -nodeAtIndexPath: of ASDataController now forces node allocation, with the assumption that clients absolutely need it. - Revisit this when node virtualization is implemented. * ASDataController only grab changeSet.completionHandler when needed because it'll be niled out * Fix ASTableViewTests related to reloadData * Fix testThatDeletedItemsAreMarkedInvisible in ASCollectionViewTests * Minor changes in ASCollectionView and ASTableView * ASCollectionView and ASTableView shouldn't call [super reloadData] before their data controller does anything * Address comments * Fuse reloadData into -updateWithChangeSet: of ASDataController * reloadData shouldn't be called as if it's inside a batch - It can't be used in conjuntion with other updates. - Calling it inside a batch update during the initial load can cause data inconsistency thrown by UICollectionView/UITableView * Refactor ASDataControllerDelegate and ASRangeControllerDelegate - Replace delegate methods in these protocols with -willUpdateWithChangeSet and -didUpdateWithChangeSet. - ASRangeController, ASCollectionView and ASTableView are simplified because of this. * Fix mismatch between sorting orders in ASDataController * Forgot to call completion handler of reload change sets * Make sure ASCollectionView is compatible with the behavior of UICollectionView's reloadData - Since UICollectionView's reloadData doesn't requery data source but defers until the next layout pass, we need to wait until then to update range controller and do batch fetching. - `-[ASCollectionView waitUntilAllUpdatesAreCommited]` needs to force a layout pass to make sure everything is ready after it returns. * testSectionIndexHandling of ASTableViewTests should only check visible nodes. Other nodes will be re-measured later. * ASTableView is not ready until the first layout pass finished * Address comments * Bug fixes
86 lines
3.0 KiB
Objective-C
86 lines
3.0 KiB
Objective-C
//
|
|
// ASCollectionViewLayoutInspector.h
|
|
// AsyncDisplayKit
|
|
//
|
|
// Created by Garrett Moon on 11/19/16.
|
|
// Copyright © 2016 Facebook. All rights reserved.
|
|
//
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import <AsyncDisplayKit/ASDimension.h>
|
|
#import <AsyncDisplayKit/ASScrollDirection.h>
|
|
|
|
@class ASCollectionView;
|
|
@protocol ASCollectionDataSource;
|
|
@protocol ASCollectionDelegate;
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
extern ASSizeRange NodeConstrainedSizeForScrollDirection(ASCollectionView *collectionView);
|
|
|
|
@protocol ASCollectionViewLayoutInspecting <NSObject>
|
|
|
|
/**
|
|
* Asks the inspector to provide a constrained size range for the given collection view node.
|
|
*/
|
|
- (ASSizeRange)collectionView:(ASCollectionView *)collectionView constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath;
|
|
|
|
/**
|
|
* Return the directions in which your collection view can scroll
|
|
*/
|
|
- (ASScrollDirection)scrollableDirections;
|
|
|
|
@optional
|
|
|
|
/**
|
|
* Asks the inspector to provide a constrained size range for the given supplementary node.
|
|
*/
|
|
- (ASSizeRange)collectionView:(ASCollectionView *)collectionView constrainedSizeForSupplementaryNodeOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath;
|
|
|
|
/**
|
|
* Asks the inspector for the number of supplementary views for the given kind in the specified section.
|
|
*/
|
|
- (NSUInteger)collectionView:(ASCollectionView *)collectionView supplementaryNodesOfKind:(NSString *)kind inSection:(NSUInteger)section;
|
|
|
|
/**
|
|
* Allow the inspector to respond to delegate changes.
|
|
*
|
|
* @discussion A great time to update perform selector caches!
|
|
*/
|
|
- (void)didChangeCollectionViewDelegate:(nullable id<ASCollectionDelegate>)delegate;
|
|
|
|
/**
|
|
* Allow the inspector to respond to dataSource changes.
|
|
*
|
|
* @discussion A great time to update perform selector caches!
|
|
*/
|
|
- (void)didChangeCollectionViewDataSource:(nullable id<ASCollectionDataSource>)dataSource;
|
|
|
|
#pragma mark Deprecated Methods
|
|
|
|
/**
|
|
* Asks the inspector for the number of supplementary sections in the collection view for the given kind.
|
|
*
|
|
* @deprecated This method will not be called, and it is only deprecated as a reminder to remove it.
|
|
* Supplementary elements must exist in the same sections as regular collection view items i.e. -numberOfSectionsInCollectionView:
|
|
*/
|
|
- (NSUInteger)collectionView:(ASCollectionView *)collectionView numberOfSectionsForSupplementaryNodeOfKind:(NSString *)kind ASDISPLAYNODE_DEPRECATED_MSG("Use ASCollectionNode's method instead.");
|
|
|
|
@end
|
|
|
|
/**
|
|
* A layout inspector for non-flow layouts that returns a constrained size to let the cells layout itself as
|
|
* far as possible based on the scrollable direction of the collection view.
|
|
* It doesn't support supplementary nodes and therefore doesn't implement delegate methods
|
|
* that are related to supplementary node's management.
|
|
*
|
|
* @warning This class is not meant to be subclassed and will be restricted in the future.
|
|
*/
|
|
@interface ASCollectionViewLayoutInspector : NSObject <ASCollectionViewLayoutInspecting>
|
|
|
|
- (instancetype)initWithCollectionView:(ASCollectionView *)collectionView ASDISPLAYNODE_DEPRECATED_MSG("Use -init instead.");
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|