mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
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
This commit is contained in:
53
examples/LayoutSpecExamples/Sample/OverviewCellNode.m
Normal file
53
examples/LayoutSpecExamples/Sample/OverviewCellNode.m
Normal file
@@ -0,0 +1,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
|
||||
Reference in New Issue
Block a user