mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-13 01:40:12 +00:00
Use collectionView:nodeBlockForItemAtIndexPath: in all examples
This commit is contained in:
parent
f948a807c9
commit
8418d8be24
@ -104,10 +104,12 @@
|
|||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark ASCollectionView data source.
|
#pragma mark ASCollectionView data source.
|
||||||
|
|
||||||
- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForItemAtIndexPath:(NSIndexPath *)indexPath
|
- (ASCellNodeBlock)collectionView:(ASCollectionView *)collectionView nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath;
|
||||||
{
|
{
|
||||||
NSString *text = [NSString stringWithFormat:@"[%zd.%zd] says hi", indexPath.section, indexPath.item];
|
NSString *text = [NSString stringWithFormat:@"[%zd.%zd] says hi", indexPath.section, indexPath.item];
|
||||||
|
return ^{
|
||||||
return [[ItemNode alloc] initWithString:text];
|
return [[ItemNode alloc] initWithString:text];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
|
- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
|
||||||
|
|||||||
@ -159,10 +159,12 @@ static const CGFloat kVerticalSectionPadding = 20.0f;
|
|||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark ASCollectionView data source.
|
#pragma mark ASCollectionView data source.
|
||||||
|
|
||||||
- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForItemAtIndexPath:(NSIndexPath *)indexPath
|
- (ASCellNodeBlock)collectionView:(ASCollectionView *)collectionView nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
ItemViewModel *viewModel = _data[indexPath.item];
|
ItemViewModel *viewModel = _data[indexPath.item];
|
||||||
|
return ^{
|
||||||
return [[ItemNode alloc] initWithViewModel:viewModel];
|
return [[ItemNode alloc] initWithViewModel:viewModel];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ASCellNode *)collectionView:(UICollectionView *)collectionView nodeForSupplementaryElementOfKind:(nonnull NSString *)kind atIndexPath:(nonnull NSIndexPath *)indexPath {
|
- (ASCellNode *)collectionView:(UICollectionView *)collectionView nodeForSupplementaryElementOfKind:(nonnull NSString *)kind atIndexPath:(nonnull NSIndexPath *)indexPath {
|
||||||
|
|||||||
@ -90,16 +90,17 @@ static NSUInteger kNumberOfImages = 14;
|
|||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark ASCollectionView data source.
|
#pragma mark ASCollectionView data source.
|
||||||
|
|
||||||
- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForItemAtIndexPath:(NSIndexPath *)indexPath
|
- (ASCellNodeBlock)collectionView:(ASCollectionView *)collectionView nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
ASCellNode *node = [[ASCellNode alloc] initWithViewControllerBlock:^UIViewController *{
|
UIImage *image = _sections[indexPath.section][indexPath.item];
|
||||||
return [[ImageViewController alloc] initWithImage:_sections[indexPath.section][indexPath.item]];
|
return ^{
|
||||||
} didLoadBlock:nil];
|
return [[ASCellNode alloc] initWithViewControllerBlock:^UIViewController *{
|
||||||
|
return [[ImageViewController alloc] initWithImage:image];
|
||||||
|
} didLoadBlock:^(ASDisplayNode * _Nonnull node) {
|
||||||
node.layer.borderWidth = 1.0;
|
node.layer.borderWidth = 1.0;
|
||||||
node.layer.borderColor = [UIColor blackColor].CGColor;
|
node.layer.borderColor = [UIColor blackColor].CGColor;
|
||||||
|
}];
|
||||||
return node;
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
|
- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
|
||||||
|
|||||||
@ -90,14 +90,18 @@ static NSUInteger kNumberOfImages = 14;
|
|||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark ASCollectionView data source.
|
#pragma mark ASCollectionView data source.
|
||||||
|
|
||||||
- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForItemAtIndexPath:(NSIndexPath *)indexPath
|
- (ASCellNodeBlock)collectionView:(ASCollectionView *)collectionView nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
return [[ImageCellNode alloc] initWithImage:_sections[indexPath.section][indexPath.item]];
|
UIImage *image = _sections[indexPath.section][indexPath.item];
|
||||||
|
return ^{
|
||||||
|
return [[ImageCellNode alloc] initWithImage:image];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
|
- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
NSString *text = [NSString stringWithFormat:@"Section %d", (int)indexPath.section + 1];
|
NSString *text = [NSString stringWithFormat:@"Section %zd", indexPath.section + 1];
|
||||||
return [[SupplementaryNode alloc] initWithText:text];
|
return [[SupplementaryNode alloc] initWithText:text];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -67,11 +67,13 @@ static const CGFloat kInnerPadding = 10.0f;
|
|||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForItemAtIndexPath:(NSIndexPath *)indexPath
|
- (ASCellNodeBlock)collectionView:(ASCollectionView *)collectionView nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
|
return ^{
|
||||||
RandomCoreGraphicsNode *elementNode = [[RandomCoreGraphicsNode alloc] init];
|
RandomCoreGraphicsNode *elementNode = [[RandomCoreGraphicsNode alloc] init];
|
||||||
elementNode.preferredFrameSize = _elementSize;
|
elementNode.preferredFrameSize = _elementSize;
|
||||||
return elementNode;
|
return elementNode;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user