Skip to content

Commit f7f5988

Browse files
author
Li Tan
committed
Support editing in table view and collection view
1 parent 5cb261b commit f7f5988

23 files changed

Lines changed: 1443 additions & 861 deletions

AsyncDisplayKit.xcodeproj/project.pbxproj

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
051943151A1575670030A7D0 /* Photos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 051943141A1575670030A7D0 /* Photos.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
1818
052EE0661A159FEF002C6279 /* ASMultiplexImageNodeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 052EE0651A159FEF002C6279 /* ASMultiplexImageNodeTests.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
1919
052EE06B1A15A0D8002C6279 /* TestResources in Resources */ = {isa = PBXBuildFile; fileRef = 052EE06A1A15A0D8002C6279 /* TestResources */; };
20+
0540322B1A37B69C00001D02 /* ASEqualityHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 0540322A1A37B69C00001D02 /* ASEqualityHelpers.h */; settings = {ATTRIBUTES = (Public, ); }; };
2021
054963491A1EA066000F8E56 /* ASBasicImageDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = 054963471A1EA066000F8E56 /* ASBasicImageDownloader.h */; settings = {ATTRIBUTES = (Public, ); }; };
2122
0549634A1A1EA066000F8E56 /* ASBasicImageDownloader.mm in Sources */ = {isa = PBXBuildFile; fileRef = 054963481A1EA066000F8E56 /* ASBasicImageDownloader.mm */; };
2223
055B9FA81A1C154B00035D6D /* ASNetworkImageNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 055B9FA61A1C154B00035D6D /* ASNetworkImageNode.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -134,8 +135,14 @@
134135
05A6D05A19D0EB64002DD95E /* ASDealloc2MainObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 05A6D05819D0EB64002DD95E /* ASDealloc2MainObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
135136
05A6D05B19D0EB64002DD95E /* ASDealloc2MainObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 05A6D05919D0EB64002DD95E /* ASDealloc2MainObject.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
136137
05F20AA41A15733C00DCA68A /* ASImageProtocols.h in Headers */ = {isa = PBXBuildFile; fileRef = 05F20AA31A15733C00DCA68A /* ASImageProtocols.h */; settings = {ATTRIBUTES = (Public, ); }; };
137-
1950C4491A3BB5C1005C8279 /* ASEqualityHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 1950C4481A3BB5C1005C8279 /* ASEqualityHelpers.h */; };
138138
3C9C128519E616EF00E942A0 /* ASTableViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C9C128419E616EF00E942A0 /* ASTableViewTests.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
139+
464052201A3F83C40061C0BA /* ASDataController.h in Headers */ = {isa = PBXBuildFile; fileRef = 464052191A3F83C40061C0BA /* ASDataController.h */; settings = {ATTRIBUTES = (Public, ); }; };
140+
464052211A3F83C40061C0BA /* ASDataController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4640521A1A3F83C40061C0BA /* ASDataController.mm */; };
141+
464052221A3F83C40061C0BA /* ASFlowLayoutController.h in Headers */ = {isa = PBXBuildFile; fileRef = 4640521B1A3F83C40061C0BA /* ASFlowLayoutController.h */; settings = {ATTRIBUTES = (Public, ); }; };
142+
464052231A3F83C40061C0BA /* ASFlowLayoutController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4640521C1A3F83C40061C0BA /* ASFlowLayoutController.mm */; };
143+
464052241A3F83C40061C0BA /* ASLayoutController.h in Headers */ = {isa = PBXBuildFile; fileRef = 4640521D1A3F83C40061C0BA /* ASLayoutController.h */; settings = {ATTRIBUTES = (Public, ); }; };
144+
464052251A3F83C40061C0BA /* ASMultidimensionalArrayUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 4640521E1A3F83C40061C0BA /* ASMultidimensionalArrayUtils.h */; };
145+
464052261A3F83C40061C0BA /* ASMultidimensionalArrayUtils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4640521F1A3F83C40061C0BA /* ASMultidimensionalArrayUtils.mm */; };
139146
6BDC61F61979037800E50D21 /* AsyncDisplayKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BDC61F51978FEA400E50D21 /* AsyncDisplayKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
140147
AC3C4A511A1139C100143C57 /* ASCollectionView.h in Headers */ = {isa = PBXBuildFile; fileRef = AC3C4A4F1A1139C100143C57 /* ASCollectionView.h */; settings = {ATTRIBUTES = (Public, ); }; };
141148
AC3C4A521A1139C100143C57 /* ASCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = AC3C4A501A1139C100143C57 /* ASCollectionView.m */; };
@@ -175,6 +182,7 @@
175182
052EE0651A159FEF002C6279 /* ASMultiplexImageNodeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASMultiplexImageNodeTests.m; sourceTree = "<group>"; };
176183
052EE06A1A15A0D8002C6279 /* TestResources */ = {isa = PBXFileReference; lastKnownFileType = folder; path = TestResources; sourceTree = "<group>"; };
177184
053011A719B9882B00A9F2D0 /* ASRangeControllerInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASRangeControllerInternal.h; sourceTree = "<group>"; };
185+
0540322A1A37B69C00001D02 /* ASEqualityHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASEqualityHelpers.h; sourceTree = "<group>"; };
178186
054963471A1EA066000F8E56 /* ASBasicImageDownloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASBasicImageDownloader.h; sourceTree = "<group>"; };
179187
054963481A1EA066000F8E56 /* ASBasicImageDownloader.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASBasicImageDownloader.mm; sourceTree = "<group>"; };
180188
055B9FA61A1C154B00035D6D /* ASNetworkImageNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASNetworkImageNode.h; sourceTree = "<group>"; };
@@ -269,8 +277,14 @@
269277
05A6D05819D0EB64002DD95E /* ASDealloc2MainObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASDealloc2MainObject.h; path = ../Details/ASDealloc2MainObject.h; sourceTree = "<group>"; };
270278
05A6D05919D0EB64002DD95E /* ASDealloc2MainObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ASDealloc2MainObject.m; path = ../Details/ASDealloc2MainObject.m; sourceTree = "<group>"; };
271279
05F20AA31A15733C00DCA68A /* ASImageProtocols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASImageProtocols.h; sourceTree = "<group>"; };
272-
1950C4481A3BB5C1005C8279 /* ASEqualityHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASEqualityHelpers.h; sourceTree = "<group>"; };
273280
3C9C128419E616EF00E942A0 /* ASTableViewTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASTableViewTests.m; sourceTree = "<group>"; };
281+
464052191A3F83C40061C0BA /* ASDataController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASDataController.h; sourceTree = "<group>"; };
282+
4640521A1A3F83C40061C0BA /* ASDataController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASDataController.mm; sourceTree = "<group>"; };
283+
4640521B1A3F83C40061C0BA /* ASFlowLayoutController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASFlowLayoutController.h; sourceTree = "<group>"; };
284+
4640521C1A3F83C40061C0BA /* ASFlowLayoutController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASFlowLayoutController.mm; sourceTree = "<group>"; };
285+
4640521D1A3F83C40061C0BA /* ASLayoutController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutController.h; sourceTree = "<group>"; };
286+
4640521E1A3F83C40061C0BA /* ASMultidimensionalArrayUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASMultidimensionalArrayUtils.h; sourceTree = "<group>"; };
287+
4640521F1A3F83C40061C0BA /* ASMultidimensionalArrayUtils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASMultidimensionalArrayUtils.mm; sourceTree = "<group>"; };
274288
6BDC61F51978FEA400E50D21 /* AsyncDisplayKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AsyncDisplayKit.h; sourceTree = "<group>"; };
275289
AC3C4A4F1A1139C100143C57 /* ASCollectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASCollectionView.h; sourceTree = "<group>"; };
276290
AC3C4A501A1139C100143C57 /* ASCollectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASCollectionView.m; sourceTree = "<group>"; };
@@ -419,6 +433,13 @@
419433
058D09E1195D050800B7D73C /* Details */ = {
420434
isa = PBXGroup;
421435
children = (
436+
464052191A3F83C40061C0BA /* ASDataController.h */,
437+
4640521A1A3F83C40061C0BA /* ASDataController.mm */,
438+
4640521B1A3F83C40061C0BA /* ASFlowLayoutController.h */,
439+
4640521C1A3F83C40061C0BA /* ASFlowLayoutController.mm */,
440+
4640521D1A3F83C40061C0BA /* ASLayoutController.h */,
441+
4640521E1A3F83C40061C0BA /* ASMultidimensionalArrayUtils.h */,
442+
4640521F1A3F83C40061C0BA /* ASMultidimensionalArrayUtils.mm */,
422443
05F20AA31A15733C00DCA68A /* ASImageProtocols.h */,
423444
058D09E2195D050800B7D73C /* _ASDisplayLayer.h */,
424445
058D09E3195D050800B7D73C /* _ASDisplayLayer.mm */,
@@ -499,7 +520,7 @@
499520
0516FA3A1A15563400B4EBED /* ASAvailability.h */,
500521
058D0A44195D058D00B7D73C /* ASBaseDefines.h */,
501522
058D0A45195D058D00B7D73C /* ASDisplayNodeExtraIvars.h */,
502-
1950C4481A3BB5C1005C8279 /* ASEqualityHelpers.h */,
523+
0540322A1A37B69C00001D02 /* ASEqualityHelpers.h */,
503524
0516FA3B1A15563400B4EBED /* ASLog.h */,
504525
);
505526
path = Base;
@@ -521,13 +542,15 @@
521542
isa = PBXHeadersBuildPhase;
522543
buildActionMask = 2147483647;
523544
files = (
545+
464052221A3F83C40061C0BA /* ASFlowLayoutController.h in Headers */,
546+
464052241A3F83C40061C0BA /* ASLayoutController.h in Headers */,
547+
464052201A3F83C40061C0BA /* ASDataController.h in Headers */,
524548
05A6D05A19D0EB64002DD95E /* ASDealloc2MainObject.h in Headers */,
525549
0516FA401A1563D200B4EBED /* ASMultiplexImageNode.h in Headers */,
526550
058D0A47195D05CB00B7D73C /* ASControlNode.h in Headers */,
527551
058D0A48195D05CB00B7D73C /* ASControlNode.m in Headers */,
528552
058D0A49195D05CB00B7D73C /* ASControlNode+Subclasses.h in Headers */,
529553
058D0A4A195D05CB00B7D73C /* ASDisplayNode.h in Headers */,
530-
1950C4491A3BB5C1005C8279 /* ASEqualityHelpers.h in Headers */,
531554
058D0A4B195D05CB00B7D73C /* ASDisplayNode.mm in Headers */,
532555
058D0A4C195D05CB00B7D73C /* ASDisplayNode+Subclasses.h in Headers */,
533556
058D0A4D195D05CB00B7D73C /* ASDisplayNodeExtras.h in Headers */,
@@ -557,6 +580,7 @@
557580
058D0A61195D05DC00B7D73C /* ASTextNodeTextKitHelpers.h in Headers */,
558581
058D0A62195D05DC00B7D73C /* ASTextNodeTextKitHelpers.mm in Headers */,
559582
058D0A63195D05DC00B7D73C /* ASTextNodeTypes.h in Headers */,
583+
464052251A3F83C40061C0BA /* ASMultidimensionalArrayUtils.h in Headers */,
560584
058D0A64195D05DC00B7D73C /* ASTextNodeWordKerner.h in Headers */,
561585
058D0A65195D05DC00B7D73C /* ASTextNodeWordKerner.m in Headers */,
562586
058D0A66195D05DC00B7D73C /* NSMutableAttributedString+TextKitAdditions.h in Headers */,
@@ -580,6 +604,7 @@
580604
055B9FA81A1C154B00035D6D /* ASNetworkImageNode.h in Headers */,
581605
054963491A1EA066000F8E56 /* ASBasicImageDownloader.h in Headers */,
582606
AC3C4A541A113EEC00143C57 /* ASCollectionViewProtocols.h in Headers */,
607+
0540322B1A37B69C00001D02 /* ASEqualityHelpers.h in Headers */,
583608
05F20AA41A15733C00DCA68A /* ASImageProtocols.h in Headers */,
584609
058D0A71195D05F800B7D73C /* _AS-objc-internal.h in Headers */,
585610
058D0A72195D05F800B7D73C /* _ASCoreAnimationExtras.h in Headers */,
@@ -723,15 +748,18 @@
723748
058D0A1E195D050800B7D73C /* ASTextNodeShadower.m in Sources */,
724749
058D0A18195D050800B7D73C /* _ASDisplayLayer.mm in Sources */,
725750
058D0A2C195D050800B7D73C /* ASSentinel.m in Sources */,
751+
464052211A3F83C40061C0BA /* ASDataController.mm in Sources */,
726752
058D0A15195D050800B7D73C /* ASDisplayNodeExtras.mm in Sources */,
727753
058D0A1F195D050800B7D73C /* ASTextNodeTextKitHelpers.mm in Sources */,
728754
055F1A3519ABD3E3004DAFF1 /* ASTableView.m in Sources */,
755+
464052261A3F83C40061C0BA /* ASMultidimensionalArrayUtils.mm in Sources */,
729756
055B9FA91A1C154B00035D6D /* ASNetworkImageNode.mm in Sources */,
730757
058D0A1D195D050800B7D73C /* ASTextNodeRenderer.mm in Sources */,
731758
058D0A2A195D050800B7D73C /* ASDisplayNode+UIViewBridge.mm in Sources */,
732759
AC3C4A521A1139C100143C57 /* ASCollectionView.m in Sources */,
733760
058D0A20195D050800B7D73C /* ASTextNodeWordKerner.m in Sources */,
734761
058D0A1A195D050800B7D73C /* ASHighlightOverlayLayer.mm in Sources */,
762+
464052231A3F83C40061C0BA /* ASFlowLayoutController.mm in Sources */,
735763
058D0A28195D050800B7D73C /* ASDisplayNode+AsyncDisplay.mm in Sources */,
736764
058D0A21195D050800B7D73C /* NSMutableAttributedString+TextKitAdditions.m in Sources */,
737765
058D0A25195D050800B7D73C /* UIView+ASConvenience.m in Sources */,

AsyncDisplayKit/ASCellNode.m

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,12 @@
99
#import "ASCellNode.h"
1010

1111
#import "ASDisplayNode+Subclasses.h"
12-
#import "ASRangeControllerInternal.h"
1312
#import "ASTextNode.h"
1413

1514

1615
#pragma mark -
1716
#pragma mark ASCellNode
1817

19-
@interface ASCellNode () {
20-
// used by ASRangeController machinery
21-
NSIndexPath *_asyncdisplaykit_indexPath;
22-
}
23-
24-
@end
25-
26-
2718
@implementation ASCellNode
2819

2920
- (instancetype)init
@@ -43,20 +34,6 @@ - (void)setLayerBacked:(BOOL)layerBacked
4334
ASDisplayNodeAssert(!layerBacked, @"ASCellNode does not support layer-backing.");
4435
}
4536

46-
// TODO consider making this property an associated object in ASRangeController.mm
47-
- (NSIndexPath *)asyncdisplaykit_indexPath
48-
{
49-
return _asyncdisplaykit_indexPath;
50-
}
51-
52-
- (void)setAsyncdisplaykit_indexPath:(NSIndexPath *)asyncdisplaykit_indexPath
53-
{
54-
if (_asyncdisplaykit_indexPath == asyncdisplaykit_indexPath)
55-
return;
56-
57-
_asyncdisplaykit_indexPath = [asyncdisplaykit_indexPath copy];
58-
}
59-
6037
@end
6138

6239

AsyncDisplayKit/ASCollectionView.h

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@
3434
*/
3535
@property (nonatomic, assign) ASRangeTuningParameters rangeTuningParameters;
3636

37-
/**
38-
* @abstract An optional block which can perform custom calculation for working range.
39-
*
40-
* @discussion Can be used to provide custom working range logic for custom layouts.
41-
*/
42-
@property (nonatomic, assign) asrangecontroller_working_range_calculation_block_t workingRangeCalculationBlock;
43-
4437
/**
4538
* Reload everything from scratch, destroying the working range and all cached nodes.
4639
*
@@ -49,30 +42,26 @@
4942
- (void)reloadData;
5043

5144
/**
52-
* WARNING: ASCollectionView's update/editing support is not yet implemented. Use of these methods will fire an assertion.
45+
* Section updating.
5346
*
54-
* This initial version of ASCollectionView only supports appending nodes (see below). If you'd like to see full-fledged
55-
* support for data source updates and interactive editing, please file a GitHub issue -- AsyncDisplayKit can do it,
56-
* we just haven't built it out yet. :]
47+
* All operations are asynchronous and thread safe. You can call it from background thread (it is recommendated) and the UI table
48+
* view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes before these methods are called.
5749
*/
58-
//- (void)insertSections:(NSIndexSet *)sections;
59-
//- (void)deleteSections:(NSIndexSet *)sections;
60-
//- (void)reloadSections:(NSIndexSet *)sections;
61-
//- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection;
62-
//
63-
//- (void)insertItemsAtIndexPaths:(NSArray *)indexPaths;
64-
//- (void)deleteItemsAtIndexPaths:(NSArray *)indexPaths;
65-
//- (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths;
66-
//- (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath;
50+
- (void)insertSections:(NSIndexSet *)sections;
51+
- (void)deleteSections:(NSIndexSet *)sections;
52+
- (void)reloadSections:(NSIndexSet *)sections;
53+
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection;
6754

6855
/**
69-
* Append nodes.
70-
*
71-
* As with UICollectionView, the asyncDataSource must be updated to reflect the new nodes before this method is called.
56+
* Items updating.
7257
*
73-
* @param indexPaths Ordered array of index paths corresponding to the nodes to be added.
58+
* All operations are asynchronous and thread safe. You can call it from background thread (it is recommendated) and the UI table
59+
* view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes before these methods are called.
7460
*/
75-
- (void)appendNodesWithIndexPaths:(NSArray *)indexPaths;
61+
- (void)insertItemsAtIndexPaths:(NSArray *)indexPaths;
62+
- (void)deleteItemsAtIndexPaths:(NSArray *)indexPaths;
63+
- (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths;
64+
- (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath;
7665

7766
/**
7867
* Query the sized node at `indexPath` for its calculatedSize.

0 commit comments

Comments
 (0)