Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit fff8a0b

Browse files
committed
Merge pull request #653 from rcancro/documentation
Added missing Appledoc documentation
2 parents a9f2bda + 3b4055f commit fff8a0b

7 files changed

Lines changed: 65 additions & 10 deletions

File tree

AsyncDisplayKit/ASDisplayNode.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ typedef UIView *(^ASDisplayNodeViewBlock)();
2828
typedef CALayer *(^ASDisplayNodeLayerBlock)();
2929

3030
/**
31-
* ASDisplayNode loaded callback block. Used for any additional setup after node's layer/view has been loaded
31+
* ASDisplayNode loaded callback block. This block is called BEFORE the -didLoad method and is always called on the main thread.
3232
*/
3333
typedef void (^ASDisplayNodeDidLoadBlock)(ASDisplayNode *node);
3434

@@ -87,7 +87,7 @@ typedef void (^ASDisplayNodeDidLoadBlock)(ASDisplayNode *node);
8787
/**
8888
* @abstract Alternative initializer with a block to create the backing layer.
8989
*
90-
* @param viewBlock The block that will be used to create the backing layer.
90+
* @param layerBlock The block that will be used to create the backing layer.
9191
*
9292
* @return An ASDisplayNode instance that loads its layer with the given block that is guaranteed to run on the main
9393
* queue. The layer will render synchronously and -layout and touch handling methods on the node will not be called.
@@ -97,7 +97,7 @@ typedef void (^ASDisplayNodeDidLoadBlock)(ASDisplayNode *node);
9797
/**
9898
* @abstract Alternative initializer with a block to create the backing layer.
9999
*
100-
* @param viewBlock The block that will be used to create the backing layer.
100+
* @param layerBlock The block that will be used to create the backing layer.
101101
* @param didLoadBlock The block that will be called after the layer created by the layerBlock is loaded
102102
*
103103
* @return An ASDisplayNode instance that loads its layer with the given block that is guaranteed to run on the main

AsyncDisplayKit/Layout/ASLayoutOptions.h

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,58 @@
1313

1414
@protocol ASLayoutable;
1515

16+
/**
17+
* A store for all of the options defined by ASLayoutSpec subclasses. All implementors of ASLayoutable own a
18+
* ASLayoutOptions. When certain layoutSpecs need option values, they are read from this class.
19+
*
20+
* Unless you wish to create a custom layout spec, ASLayoutOptions can largerly be ignored. Instead you can access
21+
* the layout option properties exposed in ASLayoutable directly, which will set the values in ASLayoutOptions
22+
* behind the scenes.
23+
*/
1624
@interface ASLayoutOptions : NSObject <ASStackLayoutable, ASStaticLayoutable, NSCopying>
1725

26+
/**
27+
* Sets the class name for the ASLayoutOptions subclasses that will be created when a node or layoutSpec's options
28+
* are first accessed.
29+
*
30+
* If you create a custom layoutSpec that includes new options, you will want to subclass ASLayoutOptions to add
31+
* the new layout options for your layoutSpec(s). In order to make sure your subclass is created instead of an
32+
* instance of ASLayoutOptions, call setDefaultLayoutOptionsClass: early in app launch (applicationDidFinishLaunching:)
33+
* with your subclass's class.
34+
*
35+
* @param defaultLayoutOptionsClass The class of ASLayoutOptions that will be lazily created for a node or layout spec.
36+
*/
1837
+ (void)setDefaultLayoutOptionsClass:(Class)defaultLayoutOptionsClass;
38+
39+
/**
40+
* @return the Class of ASLayoutOptions that will be created for a node or layoutspec. Defaults to [ASLayoutOptions class];
41+
*/
1942
+ (Class)defaultLayoutOptionsClass;
2043

44+
#pragma mark - Subclasses should implement these!
45+
/**
46+
* Initializes a new ASLayoutOptions using the given layoutable to assign any intrinsic option values.
47+
* This init function sets a sensible default value for each layout option. If you create a subclass of
48+
* ASLayoutOptions, your subclass should do the same.
49+
*
50+
* @param layoutable The layoutable that will own these options. The layoutable will be used to set any intrinsic
51+
* layoutOptions. For example, if the layoutable is an ASTextNode the ascender/descender values will get set.
52+
*
53+
* @return a new instance of ASLayoutOptions
54+
*/
2155
- (instancetype)initWithLayoutable:(id<ASLayoutable>)layoutable;
22-
- (void)setValuesFromLayoutable:(id<ASLayoutable>)layoutable;
2356

24-
#pragma mark - Subclasses should implement these!
25-
- (void)propagateOptionsFromLayoutOptions:(ASLayoutOptions *)layoutOptions;
57+
/**
58+
* Copies the values of layoutOptions into self. This is useful when placing a layoutable inside of another. Consider
59+
* an ASTextNode that you want to align to the baseline by putting it in an ASStackLayoutSpec. Before that, you want
60+
* to inset the ASTextNode by placing it in an ASInsetLayoutSpec. An ASInsetLayoutSpec will not have any information
61+
* about the ASTextNode's ascender/descender unless we copy over the layout options from ASTextNode to ASInsetLayoutSpec.
62+
* This is done automatically and should not need to be called directly. It is listed here to make sure that any
63+
* ASLayoutOptions subclass implements the method.
64+
*
65+
* @param layoutOptions The layoutOptions to copy from
66+
*/
67+
- (void)copyIntoOptions:(ASLayoutOptions *)layoutOptions;
2668

2769
#pragma mark - ASStackLayoutable
2870

AsyncDisplayKit/Layout/ASLayoutOptions.mm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ - (instancetype)initWithLayoutable:(id<ASLayoutable>)layoutable;
8686
- (id)copyWithZone:(NSZone *)zone
8787
{
8888
ASLayoutOptions *copy = [[[self class] alloc] init];
89-
[copy propagateOptionsFromLayoutOptions:self];
89+
[copy copyIntoOptions:self];
9090
return copy;
9191
}
9292

93-
- (void)propagateOptionsFromLayoutOptions:(ASLayoutOptions *)layoutOptions
93+
- (void)copyIntoOptions:(ASLayoutOptions *)layoutOptions
9494
{
9595
ASDN::MutexLocker l(_propertyLock);
9696
self.flexBasis = layoutOptions.flexBasis;
@@ -125,7 +125,6 @@ - (void)setValuesFromLayoutable:(id<ASLayoutable>)layoutable
125125
if ([layoutable isKindOfClass:[ASDisplayNode class]]) {
126126
ASDisplayNode *displayNode = (ASDisplayNode *)layoutable;
127127
self.sizeRange = ASRelativeSizeRangeMake(ASRelativeSizeMakeWithCGSize(displayNode.preferredFrameSize), ASRelativeSizeMakeWithCGSize(displayNode.preferredFrameSize));
128-
self.layoutPosition = displayNode.frame.origin;
129128

130129
if ([layoutable isKindOfClass:[ASTextNode class]]) {
131130
ASTextNode *textNode = (ASTextNode *)layoutable;

AsyncDisplayKit/Layout/ASLayoutSpec.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ - (void)setChild:(id<ASLayoutable>)child;
8282

8383
id<ASLayoutable> finalLayoutable = [child finalLayoutable];
8484
if (finalLayoutable != child) {
85-
[finalLayoutable.layoutOptions propagateOptionsFromLayoutOptions:child.layoutOptions];
85+
[finalLayoutable.layoutOptions copyIntoOptions:child.layoutOptions];
8686
return finalLayoutable;
8787
}
8888
}

AsyncDisplayKit/Layout/ASLayoutablePrivate.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
@class ASLayoutOptions;
1515
@protocol ASLayoutable;
1616

17+
/**
18+
* The base protocol for ASLayoutable. Generally the methods/properties in this class do not need to be
19+
* called by the end user and are only called internally. However, there may be a case where the methods are useful.
20+
*/
1721
@protocol ASLayoutablePrivate <NSObject>
1822

1923
/**
@@ -35,5 +39,9 @@
3539
*/
3640
@property (nonatomic, assign) BOOL isFinalLayoutable;
3741

42+
43+
/**
44+
* The class that holds all of the layoutOptions set on an ASLayoutable.
45+
*/
3846
@property (nonatomic, strong, readonly) ASLayoutOptions *layoutOptions;
3947
@end

AsyncDisplayKit/Layout/ASStackLayoutable.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#import <AsyncDisplayKit/ASDimension.h>
1212
#import <AsyncDisplayKit/ASStackLayoutDefines.h>
1313

14+
/**
15+
* Layout options that can be defined for an ASLayoutable being added to a ASStackLayoutSpec.
16+
*/
1417
@protocol ASStackLayoutable <NSObject>
1518

1619
/**

AsyncDisplayKit/Layout/ASStaticLayoutable.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
#import <AsyncDisplayKit/ASRelativeSize.h>
1212

13+
/**
14+
* Layout options that can be defined for an ASLayoutable being added to a ASStaticLayoutSpec.
15+
*/
1316
@protocol ASStaticLayoutable
1417

1518
/**

0 commit comments

Comments
 (0)