forked from TextureGroup/Texture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverviewCellNode.m
More file actions
53 lines (43 loc) · 1.98 KB
/
Copy pathOverviewCellNode.m
File metadata and controls
53 lines (43 loc) · 1.98 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
//
// OverviewCellNode.m
// Sample
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import "OverviewCellNode.h"
#import "LayoutExampleNodes.h"
#import "Utilities.h"
@interface OverviewCellNode ()
@property (nonatomic, strong) ASTextNode *titleNode;
@property (nonatomic, strong) ASTextNode *descriptionNode;
@end
@implementation OverviewCellNode
- (instancetype)initWithLayoutExampleClass:(Class)layoutExampleClass
{
self = [super init];
if (self) {
self.automaticallyManagesSubnodes = YES;
_layoutExampleClass = layoutExampleClass;
_titleNode = [[ASTextNode alloc] init];
_titleNode.attributedText = [NSAttributedString attributedStringWithString:[layoutExampleClass title]
fontSize:16
color:[UIColor blackColor]];
_descriptionNode = [[ASTextNode alloc] init];
_descriptionNode.attributedText = [NSAttributedString attributedStringWithString:[layoutExampleClass descriptionTitle]
fontSize:12
color:[UIColor lightGrayColor]];
}
return self;
}
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
{
ASStackLayoutSpec *verticalStackSpec = [ASStackLayoutSpec verticalStackLayoutSpec];
verticalStackSpec.alignItems = ASStackLayoutAlignItemsStart;
verticalStackSpec.spacing = 5.0;
verticalStackSpec.children = @[self.titleNode, self.descriptionNode];
return [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(10, 16, 10, 10) child:verticalStackSpec];
}
@end