forked from TextureGroup/Texture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_ASCollectionGalleryLayoutItem.mm
More file actions
85 lines (69 loc) · 2.34 KB
/
Copy path_ASCollectionGalleryLayoutItem.mm
File metadata and controls
85 lines (69 loc) · 2.34 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// _ASCollectionGalleryLayoutItem.mm
// Texture
//
// Copyright (c) 2017-present, Pinterest, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
#import <AsyncDisplayKit/_ASCollectionGalleryLayoutItem.h>
#import <AsyncDisplayKit/ASCollectionElement.h>
#import <AsyncDisplayKit/ASLayout.h>
#import <AsyncDisplayKit/ASLayoutElementPrivate.h>
#import <AsyncDisplayKit/ASLayoutElementStylePrivate.h>
#import <AsyncDisplayKit/ASLayoutSpec.h>
@implementation _ASGalleryLayoutItem {
std::atomic<ASPrimitiveTraitCollection> _primitiveTraitCollection;
}
@synthesize style;
- (instancetype)initWithItemSize:(CGSize)itemSize collectionElement:(ASCollectionElement *)collectionElement
{
self = [super init];
if (self) {
ASDisplayNodeAssert(! CGSizeEqualToSize(CGSizeZero, itemSize), @"Item size should not be zero");
ASDisplayNodeAssertNotNil(collectionElement, @"Collection element should not be nil");
_itemSize = itemSize;
_collectionElement = collectionElement;
}
return self;
}
ASLayoutElementStyleExtensibilityForwarding
ASPrimitiveTraitCollectionDefaults
- (ASTraitCollection *)asyncTraitCollection
{
ASDisplayNodeAssertNotSupported();
return nil;
}
- (ASLayoutElementType)layoutElementType
{
return ASLayoutElementTypeLayoutSpec;
}
- (NSArray<id<ASLayoutElement>> *)sublayoutElements
{
ASDisplayNodeAssertNotSupported();
return nil;
}
- (BOOL)implementsLayoutMethod
{
return YES;
}
ASLayoutElementLayoutCalculationDefaults
- (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize
{
ASDisplayNodeAssert(CGSizeEqualToSize(_itemSize, ASSizeRangeClamp(constrainedSize, _itemSize)),
@"Item size %@ can't fit within the bounds of constrained size %@", NSStringFromCGSize(_itemSize), NSStringFromASSizeRange(constrainedSize));
return [ASLayout layoutWithLayoutElement:self size:_itemSize];
}
#pragma mark - ASLayoutElementAsciiArtProtocol
- (NSString *)asciiArtString
{
return [ASLayoutSpec asciiArtStringForChildren:@[] parentName:[self asciiArtName]];
}
- (NSString *)asciiArtName
{
return [NSMutableString stringWithCString:object_getClassName(self) encoding:NSASCIIStringEncoding];
}
@end