mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-08 21:49:41 +00:00
Implement getter methods for new table / collection delegate / dataSource. Make ASTableView node-backed.
This commit is contained in:
parent
27c151095b
commit
c1640c7f59
@ -84,6 +84,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (id <ASCollectionDelegate>)delegate
|
||||
{
|
||||
if ([self pendingState]) {
|
||||
return _pendingState.delegate;
|
||||
} else {
|
||||
return self.view.asyncDelegate;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setDataSource:(id <ASCollectionDataSource>)dataSource
|
||||
{
|
||||
if ([self pendingState]) {
|
||||
@ -94,6 +103,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (id <ASCollectionDataSource>)dataSource
|
||||
{
|
||||
if ([self pendingState]) {
|
||||
return _pendingState.dataSource;
|
||||
} else {
|
||||
return self.view.asyncDataSource;
|
||||
}
|
||||
}
|
||||
|
||||
- (ASCollectionView *)view
|
||||
{
|
||||
return (ASCollectionView *)[super view];
|
||||
|
@ -20,11 +20,15 @@
|
||||
@property (nonatomic) _ASTablePendingState *pendingState;
|
||||
@end
|
||||
|
||||
@interface ASTableView ()
|
||||
- (instancetype)_initWithFrame:(CGRect)frame style:(UITableViewStyle)style;
|
||||
@end
|
||||
|
||||
@implementation ASTableNode
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewStyle)style
|
||||
{
|
||||
if (self = [super initWithViewBlock:^UIView *{ return [[ASTableView alloc] initWithFrame:CGRectZero style:style]; }]) {
|
||||
if (self = [super initWithViewBlock:^UIView *{ return [[ASTableView alloc] _initWithFrame:CGRectZero style:style]; }]) {
|
||||
return self;
|
||||
}
|
||||
return nil;
|
||||
@ -63,6 +67,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (id <ASTableDelegate>)delegate
|
||||
{
|
||||
if ([self pendingState]) {
|
||||
return _pendingState.delegate;
|
||||
} else {
|
||||
return self.view.asyncDelegate;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setDataSource:(id <ASTableDataSource>)dataSource
|
||||
{
|
||||
if ([self pendingState]) {
|
||||
@ -73,6 +86,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (id <ASTableDataSource>)dataSource
|
||||
{
|
||||
if ([self pendingState]) {
|
||||
return _pendingState.dataSource;
|
||||
} else {
|
||||
return self.view.asyncDataSource;
|
||||
}
|
||||
}
|
||||
|
||||
- (ASTableView *)view
|
||||
{
|
||||
return (ASTableView *)[super view];
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#import "ASTableView.h"
|
||||
#import "ASTableViewInternal.h"
|
||||
#import "ASTableNode.h"
|
||||
|
||||
#import "ASAssert.h"
|
||||
#import "ASBatchFetching.h"
|
||||
@ -159,33 +160,33 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
||||
return [self initWithFrame:frame style:style asyncDataFetching:NO];
|
||||
}
|
||||
|
||||
// FIXME: This method is deprecated and will probably be removed in or shortly after 2.0.
|
||||
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style asyncDataFetching:(BOOL)asyncDataFetchingEnabled
|
||||
{
|
||||
return [self initWithFrame:frame style:style dataControllerClass:[self.class dataControllerClass] asyncDataFetching:asyncDataFetchingEnabled];
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style dataControllerClass:(Class)dataControllerClass asyncDataFetching:(BOOL)asyncDataFetchingEnabled
|
||||
{
|
||||
ASTableNode *tableNode = [[ASTableNode alloc] initWithStyle:style];
|
||||
tableNode.frame = frame;
|
||||
return tableNode.view;
|
||||
}
|
||||
|
||||
- (instancetype)_initWithFrame:(CGRect)frame style:(UITableViewStyle)style
|
||||
{
|
||||
if (!(self = [super initWithFrame:frame style:style]))
|
||||
return nil;
|
||||
|
||||
// FIXME: asyncDataFetching is currently unreliable for some use cases.
|
||||
// https://github.com/facebook/AsyncDisplayKit/issues/385
|
||||
asyncDataFetchingEnabled = NO;
|
||||
|
||||
[self configureWithDataControllerClass:dataControllerClass asyncDataFetching:asyncDataFetchingEnabled];
|
||||
[self configureWithDataControllerClass:[self.class dataControllerClass] asyncDataFetching:NO];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)aDecoder
|
||||
{
|
||||
if (!(self = [super initWithCoder:aDecoder]))
|
||||
return nil;
|
||||
|
||||
[self configureWithDataControllerClass:[self.class dataControllerClass] asyncDataFetching:NO];
|
||||
|
||||
return self;
|
||||
NSLog(@"Warning: AsyncDisplayKit is not designed to be used with Interface Builder. Table properties set in IB will be lost.");
|
||||
return [self initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
|
Loading…
x
Reference in New Issue
Block a user