From 29a12834b0d64b36a366c171d3270f06c0cbf09c Mon Sep 17 00:00:00 2001 From: Samuel Hsiung Date: Thu, 29 Oct 2015 19:39:32 -0700 Subject: [PATCH] adds convenience methods to return a vertical and horizontal stack spec --- AsyncDisplayKit/Layout/ASStackLayoutSpec.h | 10 ++++++++++ AsyncDisplayKit/Layout/ASStackLayoutSpec.mm | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/AsyncDisplayKit/Layout/ASStackLayoutSpec.h b/AsyncDisplayKit/Layout/ASStackLayoutSpec.h index dd331f1405..ebf7130bfe 100644 --- a/AsyncDisplayKit/Layout/ASStackLayoutSpec.h +++ b/AsyncDisplayKit/Layout/ASStackLayoutSpec.h @@ -57,4 +57,14 @@ */ + (instancetype)stackLayoutSpecWithDirection:(ASStackLayoutDirection)direction spacing:(CGFloat)spacing justifyContent:(ASStackLayoutJustifyContent)justifyContent alignItems:(ASStackLayoutAlignItems)alignItems children:(NSArray *)children; +/** + * @return A stack layout spec with direction of ASStackLayoutDirectionVertical + **/ ++ (instancetype)verticalStackLayoutSpec; + +/** + * @return A stack layout spec with direction of ASStackLayoutDirectionHorizontal + **/ ++ (instancetype)horizontalStackLayoutSpec; + @end diff --git a/AsyncDisplayKit/Layout/ASStackLayoutSpec.mm b/AsyncDisplayKit/Layout/ASStackLayoutSpec.mm index 2269ffffeb..0763bf2615 100644 --- a/AsyncDisplayKit/Layout/ASStackLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASStackLayoutSpec.mm @@ -38,6 +38,20 @@ return [[self alloc] initWithDirection:direction spacing:spacing justifyContent:justifyContent alignItems:alignItems children:children]; } ++ (instancetype)verticalStackLayoutSpec +{ + ASStackLayoutSpec *stackLayoutSpec = [[self alloc] init]; + stackLayoutSpec.direction = ASStackLayoutDirectionVertical; + return stackLayoutSpec; +} + ++ (instancetype)horizontalStackLayoutSpec +{ + ASStackLayoutSpec *stackLayoutSpec = [[self alloc] init]; + stackLayoutSpec.direction = ASStackLayoutDirectionHorizontal; + return stackLayoutSpec; +} + - (instancetype)initWithDirection:(ASStackLayoutDirection)direction spacing:(CGFloat)spacing justifyContent:(ASStackLayoutJustifyContent)justifyContent alignItems:(ASStackLayoutAlignItems)alignItems children:(NSArray *)children { if (!(self = [super init])) {