Hannah Troisi 7a373ac638 Update Layout Examples to ASDK 2.0 (#2551)
* Objective-c project updated to ASDK 2.0

* fix assets error

* [LayoutSpecExamples] Renamed new example project to be easier to type / find.

* [Bulid] Manually create Sample.xcscheme file to hopefully fix complaining bulid :).

* clean up project

* commentary on ASAbsoluteLayoutSpec

* address @maicki's comments
2016-11-06 13:47:48 -08:00

54 lines
2.0 KiB
Objective-C

//
// 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