forked from TextureGroup/Texture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollectionViewController.m
More file actions
63 lines (53 loc) · 1.8 KB
/
Copy pathCollectionViewController.m
File metadata and controls
63 lines (53 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// CollectionViewController.m
// Texture
//
// Copyright (c) Pinterest, Inc. All rights reserved.
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
//
#import "CollectionViewController.h"
#import "TextCellNode.h"
@interface CollectionViewController() <ASCollectionDataSource, ASCollectionDelegate>
{
ASCollectionNode *_collectionNode;
NSArray<NSString *> *_labels;
TextCellNode *_cellNode;
}
@end
@implementation CollectionViewController
- (instancetype)init
{
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
_collectionNode = [[ASCollectionNode alloc] initWithCollectionViewLayout:flowLayout];
CGRect rect = [[UIApplication sharedApplication] statusBarFrame];
_collectionNode.contentInset = UIEdgeInsetsMake(rect.size.height, 0, 0, 0);
self = [super initWithNode:_collectionNode];
if (self) {
_collectionNode.delegate = self;
_collectionNode.dataSource = self;
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
_collectionNode.backgroundColor = [UIColor whiteColor];
_labels = @[@"Fight of the Living Dead: Experiment Fight of the Living Dead: Experiment", @"S1 • E1"];
}
- (NSInteger)collectionNode:(ASCollectionNode *)collectionNode numberOfItemsInSection:(NSInteger)section
{
return 1;
}
- (ASCellNodeBlock)collectionNode:(ASCollectionNode *)collectionNode nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath
{
return ^{
_cellNode = [[TextCellNode alloc] initWithText1:_labels[0] text2:_labels[1]];
return _cellNode;
};
}
- (ASSizeRange)collectionNode:(ASCollectionNode *)collectionNode constrainedSizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat width = collectionNode.view.bounds.size.width;
return ASSizeRangeMake(CGSizeMake(width, 0.0f), CGSizeMake(width, CGFLOAT_MAX));
}
@end