68 Commits

Author SHA1 Message Date
Adlai Holler
b4b88da8cd Merge branch 'master' into update-objc
Conflicts:
	AsyncDisplayKit/ASCellNode.h
2015-11-02 09:36:46 -08:00
Adlai Holler
82c1549d8f Fix nullability of ASDisplayNode.name 2015-10-29 09:57:27 -07:00
Huy Nguyen
00400e166f Introduce ASCellNodeDelegate
- Cell node automatically notifies the delegate after a relayout (via -setNeedsLayout) that results in a new size. Confirming to ASCellNodeDelegate; ASTableView and ASCollectionView reload the calling cell upon notifications. These views automatically set themselves as delegate of every node.
- The result is that ASCellNode subclasses don't need to manually notify the containing view. Thus, `-relayoutItemAtIndexPath` and `-relayoutRowAtIndexPath` are removed.
- Kittens example is updated to reflect the change.
2015-10-29 16:59:46 +02:00
Adlai Holler
8e104f4887 Merge branch 'master' into update-objc
Conflicts:
	AsyncDisplayKit/ASCollectionView.h
	AsyncDisplayKit/ASDisplayNode.h
	AsyncDisplayKit/Details/ASDataController.h
	AsyncDisplayKit/Details/UIView+ASConvenience.h
	AsyncDisplayKit/Layout/ASLayoutSpec.h
2015-10-28 21:10:27 -07:00
appleguy
6c0818790c Merge pull request #774 from nguyenhuy/FixFailingTestsRelatedToDisplayNodeName
Fix failing tests related to ASDisplayNode name
2015-10-25 23:26:53 -07:00
Huy Nguyen
53a3b76d6d Add read-only names to UIView and CALayer
- Backed by name of the underlying ASDisplayNode.
- Remove goofy usages of `setValue:forKey:` in ASDisplayNodeTests and ASDisplayNodeAppearanceTests.
2015-10-26 07:44:05 +02:00
Huy Nguyen
fd0b3aaf52 Revert "Revert "Make ASDisplayNode.name Thread Safe""
This reverts commit 906d7c759b471eda67b95574199b6f91d46b6782.
2015-10-26 06:29:01 +02:00
appleguy
7e616756a7 Merge pull request #722 from nguyenhuy/RelayoutCellAPI
Add relayout item/row APIs to ASTableView and ASCollectionView
2015-10-25 21:28:20 -07:00
rcancro
5a3b021510 fixed build 2015-10-19 08:57:17 -07:00
rcancro
f164b97700 Put all ascii box methods into a Debugging category. 2015-10-19 08:32:14 -07:00
rcancro
3b983c5a50 Ascii art for layoutables 2015-10-16 16:15:29 -07:00
Huy Nguyen
f13f61c2f0 Add relayout item/row APIs to ASTableView and ASCollectionView. 2015-10-07 21:25:07 +03:00
Adlai Holler
a7240bac27 More objective-C cleanup 2015-09-16 15:41:56 -07:00
Adlai Holler
814f72535c Add nullability annotations for public API 2015-09-16 15:21:35 -07:00
rcancro
3b4055fcd3 few more doc changes. 2015-09-15 12:38:41 -07:00
rcancro
2f3562fa09 scott's comments 2015-09-15 09:11:19 -07:00
rcancro
01be5acece added a callback for initWithViewBlock/initWithLayerBlock 2015-09-14 20:36:08 -07:00
rcancro
15b3fd6eab Moved ASLayoutable* properties into ASLayoutOptions class 2015-09-08 09:50:27 -07:00
ricky cancro
ef89f758bc flailing 2015-08-22 19:03:54 -07:00
ricky cancro
3bc692c938 comments 2015-08-12 15:29:26 -07:00
ricky cancro
b58e8344c0 Add expectedSize to ASNetworkImageNode
ASNetworkImageNode defers to ASImageNode to return its calculatedSize. ASImageNode returns the size of its image. There is a good chance that ASNetworkImageNode hasn't downloaded its image yet when calculatedSize is called, so it returns a size of CGSizeZero.

On top of that, it is possible that the size of the image is not actually the size that we wish to display in our node.

I've added an "expectedImageSize" property that can be used to determine the calculatedSize of an ASNetworkImageNode.
2015-08-09 16:34:44 -07:00
Huy Nguyen
77b586a7e6 Improvements on internal relayout. 2015-08-03 06:25:23 +03:00
Huy Nguyen
0acfea234f Update comments of setNeedsLayout and setNeedsDisplay of ASDisplayNode. 2015-08-03 02:30:08 +03:00
Huy Nguyen
56768a837a - Support internal relayout, that is a relayout caused by internal layout changes, like subnodes re-arrangement and/or subnodes' size change. The constrained size applied to root node is unchanged.
- Update Kittens example to show how internal relayout is done.
2015-08-02 17:18:45 +03:00
Huy Nguyen
3992e9b09b [appledoc] Fix all remaining warnings. 2015-07-12 17:27:44 +07:00
Huy Nguyen
75983ca3e5 Merge branch 'master' into clean_up_layout_spec 2015-07-12 08:17:36 +07:00
Huy Nguyen
e1fd58268c Clean up #468:
- -layoutSpecThatFits: must return an ASLayoutSpec.
- Move ASDisplayNode's -measureWithSizeRange: redeclaration to ASDisplayNode.h.
- Rename ASStackLayoutChild.h to ASStackLayoutDefines.h.
- Rename ASStaticLayoutSpecDimension.h to ASRelativeSize.h.
- Don't import ASLayout.h in other headers to prevent circular inclusions.
- Explain use cases of ASLayout's initializers.
- Clean up ASInternalHelpers.h.
2015-07-10 19:41:17 +07:00
Huy Nguyen
cfac6c992a [appledoc] Fix appledoc warnings. (#553) 2015-07-10 19:02:04 +07:00
Huy Nguyen
9678adaa93 Merge branch 'master' into layout_node 2015-07-06 22:21:32 +07:00
Huy Nguyen
51f1ed819f - ASDisplayNode now caches calculated layout requested by layout specs.
- constrainedSizeForCalculatedLayout is of type ASSizeRange.
- calculatedLayout is better explained.
- Since ASLayout is cached and reused, its position property is mutable.
2015-07-06 22:08:01 +07:00
Huy Nguyen
dd29a890df Still support -calculateLayoutThatFits: (and manual layout), for backward compatibility. 2015-06-28 20:31:32 +07:00
Jack Flintermann
540eeec79b move UIresponder methods out of UIView bridging category 2015-06-27 03:19:51 -04:00
Jack Flintermann
0b14d42033 add UIResponder methods to ASDisplayNode 2015-06-27 03:19:51 -04:00
Huy Nguyen
f588bceb4d Introduce ASLayoutable and eliminate ASCompositeNode:
- Both ASDisplayNode and ASLayoutNode conforms to this protocol.
- ASDisplayNode can be embeded directly into layout graph.
- Eliminate ASCompositeNode.
- Fix ASStaticSizeDisplayNode not recpect min constrained size.
- Updated tests.
2015-06-26 09:29:16 +07:00
Huy Nguyen
abe98d5b09 Integrate new layout nodes to the framework.
- Introduce ASLayoutNode and its subclasses.
- ASDisplayNode measures its ASLayoutNode and cache the result (ASLayout). Calculated size and position of each subnode can be retrieved from the calculated layout.
- Custom nodes need to override -layoutNodeThatFits:(CGSize) instead of -calculateSizeThatFits:(CGSize).
- Custom nodes do not need to layout its subnodes (in -layout:) anymore. ASDisplayNode can handle the job most of the time, by walking through its layout tree.
- ASCompositeNode is used to embed (display) subnodes to a node's layout. That way, each subnode will also be measured while the parent node is measuring. And the parent node knows where its subnodes are within its layout.
2015-06-25 11:34:35 +07:00
Victor Mayorov
a299a5b550 Implemented UIAccessibilityIdentification for ASDisplayNode 2015-06-24 11:03:51 -07:00
Scott Goodson
e3f0e66cb3 Updating API names for network range and memory culling before ASDK 1.2 tag. 2015-05-21 22:43:38 -10:00
Ryan Nystrom
5e7755fac0 Range handlers use recursive actions
fixes #363
2015-03-09 12:33:02 -07:00
Ryan Nystrom
4fa03a01d1 Functioning Preload range
Refactor how we do ranges so they can be arbitrarily managed. Introduce the concept of a preload range.
2015-02-26 15:41:32 -08:00
Nadine Salter
8097a6edf1 Merge pull request #323 from facebook/issue-282
Change placeholder boolean to time interval
2015-02-25 20:54:19 -08:00
Ryan Nystrom
ad474fce8e Make project imports consistent 2015-02-23 14:55:15 -08:00
Ryan Nystrom
5d76d6649f Change placeholder boolean to time interval 2015-02-23 14:01:17 -08:00
Nadine Salter
f085f06ff3 -[UIView addSubnode:], -[CALayer addSubnode:].
Bring back this convenience API -- it disappeared somewhere along the
line while we were building Paper.  This is totally trivial, but
conveniently won't break if you layer-back a leaf node.

Closes #278.
2015-02-02 19:59:30 -08:00
Nadine Salter
fab6f623a8 Deprecate -initWith{View,Layer}Class:.
These have been superseded by -[ASDisplayNode initWithViewBlock:] and
-[ASDisplayNode initWithLayerBlock:], respectively -- the new API allows
for custom initialisers, but does not support asynchronous display.

The old initialisers are still available in ASDisplayNodeInternal.h, for
internal subclasses and daring adventurers.
2015-01-24 11:52:27 -08:00
James Ide
1545384c7c Let ASDisplayNode take a block that returns the backing view/layer
This adds new initializer methods to ASDisplayNode:
```objc
initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock
initWithLayerBlock:(ASDisplayNodeLayerBlock)layerBlock
```

Sometimes a view can't be constructed with `-[initWithViewClass:]` but you want to use it with ASDK, so these new methods provide a way to wrap an existing view in a node.

The API is meant to preserve ASDisplayNode's behavior, so you can still construct and set properties on the node on a background queue before its view is loaded; even though the view was created a priori, it is not considered to be loaded until `node.view` is accessed.

Using the API looks like this:

    dispatch_async(backgroundQueue, ^{
        ASDisplayNode *node = [ASDisplayNode alloc] initWithViewBlock:^{
            // Guaranteed to run on the main queue
            UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
            [button sizeToFit];
            node.frame = button.frame;
            return button;
        }];
        // Use `node` as you normally would...
        node.backgroundColor = [UIColor redColor];
    });

The main thing this bridging API doesn't do (can't do?) is layout. Methods like `-[ASDisplayNode calculateSizeThatFits:]` and `-[ASDisplayNode layout]` cannot delegate to `[UIView sizeThatFits:]` and `[UIView layoutSubviews]` since the UIView methods must run on the main thread. If ASDK were internally asynchronous and could dispatch its layout methods to different threads (sort of like how ASTableView computes its cells' layouts) then we could mark nodes with externally provided views/layers as having "main-queue affinity" and delegate its layout to UIKit.

Test cases are included and all existing tests pass.
2015-01-22 16:31:37 -08:00
Ryan Nystrom
912bc9d460 Fade out placeholders
Added an API to fade out a node's placeholder when it is finished rendering.

fixes #156
2014-12-18 12:53:15 -08:00
Ryan Nystrom
d27c8859c7 Node placeholder API
ASDisplayNodes now have an overidable method -placeholderImage that lets you provide a custom UIImage to display while a node is displaying asyncronously. The default implementation of this method returns nil and thus does nothing. A provided example project also demonstrates using the placeholder API.
2014-12-15 17:23:52 -08:00
Ryan Nystrom
36cbea4f8f Update manual display logic
Postpone manual display until a future release when it can be called on any thread. Provide the current node manual display logic as a category on ASDisplayNode only available for ASRangeController. Deprecate -displayImmediately.
2014-12-04 11:55:17 -08:00
Nadine Salter
1103f82a5c .preventOrCancelDisplay -> .displaySuspended.
Rename the ASDisplayNode property to match its _ASDisplayLayer
counterpart -- `displaySuspended` is more succinct and is a more
plausible name for a Cocoa BOOL property.
2014-12-02 18:06:11 -08:00
Nadine Salter
a30c087616 Clean up ASDisplayNode internal flags.
* Reorganise and rename `_flags` for clarity and consistency.
* Remove ambiguity between `implementsDisplay` and `hasClassDisplay`.
* Delete useless `hasWillDisplayAsyncLayer` check -- make it a simple
  subclass override point, as with `didDisplayAsyncLayer:`.
* Minor comment cleanup.
2014-12-02 18:06:11 -08:00