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

Commit d326c66

Browse files
author
Dasmer Singh
committed
Merge remote-tracking branch 'upstream/master'
2 parents 31eef22 + b557075 commit d326c66

115 files changed

Lines changed: 4409 additions & 642 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ language: objective-c
22
before_install:
33
- brew update
44
- brew reinstall xctool
5-
- gem update cocoapods
5+
- gem install cocoapods -v 0.37.2
66
- gem install slather
77
- xcrun simctl list
88
install: echo "<3"

AsyncDisplayKit.xcodeproj/project.pbxproj

Lines changed: 150 additions & 20 deletions
Large diffs are not rendered by default.

AsyncDisplayKit/ASCellNode.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ - (instancetype)init
3131
return self;
3232
}
3333

34-
- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock
34+
- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(ASDisplayNodeDidLoadBlock)didLoadBlock
3535
{
3636
ASDisplayNodeAssertNotSupported();
3737
return nil;
3838
}
3939

40-
- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock
40+
- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(ASDisplayNodeDidLoadBlock)didLoadBlock
4141
{
4242
ASDisplayNodeAssertNotSupported();
4343
return nil;
@@ -106,12 +106,12 @@ - (instancetype)init
106106
return self;
107107
}
108108

109-
- (id<ASLayoutable>)layoutSpecThatFits:(ASSizeRange)constrainedSize
109+
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
110110
{
111111
static const CGFloat kHorizontalPadding = 15.0f;
112112
static const CGFloat kVerticalPadding = 11.0f;
113113
UIEdgeInsets insets = UIEdgeInsetsMake(kVerticalPadding, kHorizontalPadding, kVerticalPadding, kHorizontalPadding);
114-
return [ASInsetLayoutSpec newWithInsets:insets child:_textNode];
114+
return [ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:_textNode];
115115
}
116116

117117
- (void)setText:(NSString *)text

AsyncDisplayKit/ASCollectionNode.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// ASCollectionNode.h
3+
// AsyncDisplayKit
4+
//
5+
// Created by Scott Goodson on 9/5/15.
6+
// Copyright (c) 2015 Facebook. All rights reserved.
7+
//
8+
9+
#import <AsyncDisplayKit/AsyncDisplayKit.h>
10+
11+
/**
12+
* ASCollectionNode is a node based class that wraps an ASCollectionView. It can be used
13+
* as a subnode of another node, and provide room for many (great) features and improvements later on.
14+
*/
15+
@interface ASCollectionNode : ASDisplayNode
16+
17+
- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout NS_DESIGNATED_INITIALIZER;
18+
19+
@property (nonatomic, readonly) ASCollectionView *view;
20+
21+
@end

AsyncDisplayKit/ASCollectionNode.m

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// ASCollectionNode.m
3+
// AsyncDisplayKit
4+
//
5+
// Created by Scott Goodson on 9/5/15.
6+
// Copyright (c) 2015 Facebook. All rights reserved.
7+
//
8+
9+
#import "ASCollectionNode.h"
10+
11+
@implementation ASCollectionNode
12+
13+
- (instancetype)init
14+
{
15+
ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER();
16+
self = [self initWithCollectionViewLayout:nil]; // Will throw an exception for lacking a UICV Layout.
17+
return nil;
18+
}
19+
20+
- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout
21+
{
22+
if (self = [super initWithViewBlock:^UIView *{ return [[ASCollectionView alloc] initWithCollectionViewLayout:layout]; }]) {
23+
return self;
24+
}
25+
return nil;
26+
}
27+
28+
- (ASCollectionView *)view
29+
{
30+
return (ASCollectionView *)[super view];
31+
}
32+
33+
@end

AsyncDisplayKit/ASCollectionView.h

Lines changed: 132 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,42 @@
2727
*/
2828
@interface ASCollectionView : UICollectionView
2929

30+
- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout;
31+
3032
@property (nonatomic, weak) id<ASCollectionViewDataSource> asyncDataSource;
3133
@property (nonatomic, weak) id<ASCollectionViewDelegate> asyncDelegate; // must not be nil
3234

3335
/**
34-
* Tuning parameters for a range.
36+
* Tuning parameters for a range type.
3537
*
36-
* @param range The range to get the tuning parameters for.
38+
* @param rangeType The range type to get the tuning parameters for.
3739
*
38-
* @returns A tuning parameter value for the given range.
40+
* @returns A tuning parameter value for the given range type.
3941
*
4042
* Defaults to the render range having one sceenful both leading and trailing and the preload range having two
4143
* screenfuls in both directions.
4244
*/
4345
- (ASRangeTuningParameters)tuningParametersForRangeType:(ASLayoutRangeType)rangeType;
4446

4547
/**
46-
* Set the tuning parameters for a range.
48+
* Set the tuning parameters for a range type.
4749
*
48-
* @param tuningParameters The tuning parameters to store for a range.
49-
* @param range The range to set the tuning parameters for.
50+
* @param tuningParameters The tuning parameters to store for a range type.
51+
* @param rangeType The range type to set the tuning parameters for.
5052
*/
5153
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType;
5254

5355
/**
5456
* Initializer.
5557
*
58+
* @param frame The frame rectangle for the collection view, measured in points. The origin of the frame is relative to the superview
59+
* in which you plan to add it. This frame is passed to the superclass during initialization.
60+
*
61+
* @param layout The layout object to use for organizing items. The collection view stores a strong reference to the specified object.
62+
* Must not be nil.
63+
*
64+
* @param asyncDataFetchingEnabled Enable the data fetching in async mode.
65+
*
5666
* @discussion If asyncDataFetching is enabled, the `AScollectionView` will fetch data through `collectionView:numberOfRowsInSection:` and
5767
* `collectionView:nodeForRowAtIndexPath:` in async mode from background thread. Otherwise, the methods will be invoked synchronically
5868
* from calling thread.
@@ -70,6 +80,29 @@
7080
*/
7181
@property (nonatomic, assign) CGFloat leadingScreensForBatching;
7282

83+
/**
84+
* Perform a batch of updates asynchronously, optionally disabling all animations in the batch. This method must be called from the main thread.
85+
* The asyncDataSource must be updated to reflect the changes before the update block completes.
86+
*
87+
* @param animated NO to disable animations for this batch
88+
* @param updates The block that performs the relevant insert, delete, reload, or move operations.
89+
* @param completion A completion handler block to execute when all of the operations are finished. This block takes a single
90+
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
91+
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
92+
*/
93+
- (void)performBatchAnimated:(BOOL)animated updates:(void (^)())updates completion:(void (^)(BOOL))completion;
94+
95+
/**
96+
* Perform a batch of updates asynchronously. This method must be called from the main thread.
97+
* The asyncDataSource must be updated to reflect the changes before update block completes.
98+
*
99+
* @param updates The block that performs the relevant insert, delete, reload, or move operations.
100+
* @param completion A completion handler block to execute when all of the operations are finished. This block takes a single
101+
* Boolean parameter that contains the value YES if all of the related animations completed successfully or
102+
* NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread.
103+
*/
104+
- (void)performBatchUpdates:(void (^)())updates completion:(void (^)(BOOL))completion;
105+
73106
/**
74107
* Reload everything from scratch, destroying the working range and all cached nodes.
75108
*
@@ -87,25 +120,87 @@
87120
- (void)reloadData;
88121

89122
/**
90-
* Section updating.
123+
* Inserts one or more sections.
124+
*
125+
* @param sections An index set that specifies the sections to insert.
91126
*
92-
* All operations are asynchronous and thread safe. You can call it from background thread (it is recommendated) and the UI collection
93-
* view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes before these methods are called.
127+
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
128+
* before this method is called.
94129
*/
95130
- (void)insertSections:(NSIndexSet *)sections;
131+
132+
/**
133+
* Deletes one or more sections.
134+
*
135+
* @param sections An index set that specifies the sections to delete.
136+
*
137+
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
138+
* before this method is called.
139+
*/
96140
- (void)deleteSections:(NSIndexSet *)sections;
141+
142+
/**
143+
* Reloads the specified sections.
144+
*
145+
* @param sections An index set that specifies the sections to reload.
146+
*
147+
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
148+
* before this method is called.
149+
*/
97150
- (void)reloadSections:(NSIndexSet *)sections;
151+
152+
/**
153+
* Moves a section to a new location.
154+
*
155+
* @param section The index of the section to move.
156+
*
157+
* @param newSection The index that is the destination of the move for the section.
158+
*
159+
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
160+
* before this method is called.
161+
*/
98162
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection;
99163

100164
/**
101-
* Items updating.
165+
* Inserts items at the locations identified by an array of index paths.
166+
*
167+
* @param indexPaths An array of NSIndexPath objects, each representing an item index and section index that together identify an item.
102168
*
103-
* All operations are asynchronous and thread safe. You can call it from background thread (it is recommendated) and the UI collection
104-
* view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes before these methods are called.
169+
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
170+
* before this method is called.
105171
*/
106172
- (void)insertItemsAtIndexPaths:(NSArray *)indexPaths;
173+
174+
/**
175+
* Deletes the items specified by an array of index paths.
176+
*
177+
* @param indexPaths An array of NSIndexPath objects identifying the items to delete.
178+
*
179+
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
180+
* before this method is called.
181+
*/
107182
- (void)deleteItemsAtIndexPaths:(NSArray *)indexPaths;
183+
184+
/**
185+
* Reloads the specified items.
186+
*
187+
* @param indexPaths An array of NSIndexPath objects identifying the items to reload.
188+
*
189+
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
190+
* before this method is called.
191+
*/
108192
- (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths;
193+
194+
/**
195+
* Moves the item at a specified location to a destination location.
196+
*
197+
* @param indexPath The index path identifying the item to move.
198+
*
199+
* @param newIndexPath The index path that is the destination of the move for the item.
200+
*
201+
* @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes
202+
* before this method is called.
203+
*/
109204
- (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath;
110205

111206
/**
@@ -156,7 +251,7 @@
156251
/**
157252
* Similar to -collectionView:cellForItemAtIndexPath:.
158253
*
159-
* @param collection The sender.
254+
* @param collectionView The sender.
160255
*
161256
* @param indexPath The index path of the requested node.
162257
*
@@ -168,6 +263,17 @@
168263

169264
@optional
170265

266+
/**
267+
* Provides the constrained size range for measuring the node at the index path.
268+
*
269+
* @param collectionView The sender.
270+
*
271+
* @param indexPath The index path of the node.
272+
*
273+
* @returns A constrained size range for layout the node at this index path.
274+
*/
275+
- (ASSizeRange)collectionView:(ASCollectionView *)collectionView constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath;
276+
171277
/**
172278
* Indicator to lock the data source for data fetching in async mode.
173279
* We should not update the data source until the data source has been unlocked. Otherwise, it will incur data inconsistence or exception
@@ -227,6 +333,19 @@
227333
*/
228334
- (BOOL)shouldBatchFetchForCollectionView:(ASCollectionView *)collectionView;
229335

336+
/**
337+
* Passthrough support to UICollectionViewDelegateFlowLayout sectionInset behavior.
338+
*
339+
* @param collectionView The sender.
340+
* @param collectionViewLayout The layout object requesting the information.
341+
* #param section The index number of the section whose insets are needed.
342+
*
343+
* @discussion The same rules apply as the UICollectionView implementation, but this can also be used without a UICollectionViewFlowLayout.
344+
* https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICollectionViewDelegateFlowLayout_protocol/index.html#//apple_ref/occ/intfm/UICollectionViewDelegateFlowLayout/collectionView:layout:insetForSectionAtIndex:
345+
*
346+
*/
347+
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section;
348+
230349
@end
231350

232351
@interface ASCollectionView (Deprecated)

0 commit comments

Comments
 (0)