2849 Commits

Author SHA1 Message Date
Adlai Holler
1d21c0bd55 Clean up actionForLayer:forKey: (#3063) 2017-02-23 11:32:01 -08:00
Adlai Holler
6ab92dbd3f Prevent Adding View-Backed Nodes to Layer-Backed Hierarchies (#3062)
* Prevent adding view-backed nodes to layer-backed nodes

* Do that in a different diff

* Fix the message

* Update tests

* Fix the fix
2017-02-22 17:48:13 -08:00
Adlai Holler
86dd918143 Promote ASIndexedNodeContext -> ASCollectionElement (#3061)
* Remove indexPath field from ASIndexedNodeContext

* Rename ASIndexedNodeContext -> ASCollectionItem

* Name it ASCollectionElement
2017-02-22 16:55:02 -08:00
Huy Nguyen
74c6cca0b6 [ASDataController] Refactor ASDataController (#3017)
* Refactor ASDataController

Check optional methods in ASDataControllerSource

* Reimplement reloadData

* Refactor new code
- No more new/inserted contexts flag
- Encapsulate code shared between reloadData and updateWithChangeSet
- Remove dataControllerWillDeleteAllData delegate method
- Hierarchy changes no longer needs to conform to NSCopying
- Reword TODOs

* Forgot to call completion block of reloadData :P

* Completion block of -[ASDataController reloadDataWithCompletion:] is nullable

* Data queried from ASCollectionNode and ASTableNode should be in UIKit index space
- This helps to avoid immature node allocation, especially when node virtualization is a thing
- However, this means that -reloadDataInitiallyIfNeeded in ASCollectionNode and ASTableNode must wait until all updates are finished.

* ASDataController shouldn't assume that allocated nodes were also laid out

* Revert "Data queried from ASCollectionNode and ASTableNode should be in UIKit index space"

This reverts commit 7bc977b3808a92f484b297781d0f5b30aa258e17.

* -nodeAtIndexPath: of ASDataController now forces node allocation, with the assumption that clients absolutely need it.
- Revisit this when node virtualization is implemented.

* ASDataController only grab changeSet.completionHandler when needed because it'll be niled out

* Fix ASTableViewTests related to reloadData

* Fix testThatDeletedItemsAreMarkedInvisible in ASCollectionViewTests

* Minor changes in ASCollectionView and ASTableView

* ASCollectionView and ASTableView shouldn't call [super reloadData] before their data controller does anything

* Address comments

* Fuse reloadData into -updateWithChangeSet: of ASDataController

* reloadData shouldn't be called as if it's inside a batch
- It can't be used in conjuntion with other updates.
- Calling it inside a batch update during the initial load can cause data inconsistency thrown by UICollectionView/UITableView

* Refactor ASDataControllerDelegate and ASRangeControllerDelegate
- Replace delegate methods in these protocols with -willUpdateWithChangeSet and -didUpdateWithChangeSet.
- ASRangeController, ASCollectionView and ASTableView are simplified because of this.

* Fix mismatch between sorting orders in ASDataController

* Forgot to call completion handler of reload change sets

* Make sure ASCollectionView is compatible with the behavior of UICollectionView's reloadData
- Since UICollectionView's reloadData doesn't requery data source but defers until the next layout pass,  we need to wait until then to update range controller and do batch fetching.
- `-[ASCollectionView waitUntilAllUpdatesAreCommited]` needs to force a layout pass to make sure
everything is ready after it returns.

* testSectionIndexHandling of ASTableViewTests should only check visible nodes. Other nodes will be re-measured later.

* ASTableView is not ready until the first layout pass finished

* Address comments

* Bug fixes
2017-02-22 13:50:07 -08:00
appleguy
36538996c7 [Yoga] Fix ASLayout hierarchy to only include immediate subnodes. (#3054)
This patch also adds ASEdgeInsetsZero, and one fix to passthrough of UIKit Supplementary Views.
2017-02-21 16:47:07 -08:00
Garrett Moon
75fddb1f77 Upgrades to latest PINRemoteImage which should fix GIF rendering. (#3057) 2017-02-21 11:43:36 -08:00
Garrett Moon
4e779eeed8 Need to set defaultImage, not image if we're a network image node. (#3041) 2017-02-17 13:16:57 -08:00
Adlai Holler
b616248c20 Majorly Improve automaticallyAdjustsContentOffset (#3033)
* Majorly improve automaticallyAdjustsContentOffset

* Remove nodes from ASDataControllerDelegate & ASRangeControllerDelegate

* Do it after -endUpdates
2017-02-15 11:57:39 -08:00
Jason Yu
8e18f1562c [TextKit] Fix text layout issue for CJK laungages (#3026)
* [TextKit] Fix text layout issue for CJK laungages

* [ASTextKitContext] Delay filling _textStorage with attributedString until calling addLayoutManager.
2017-02-15 11:54:55 -08:00
Garrett Moon
a6e74900c0 Hopefully this makes the comment clearer (#3036) 2017-02-15 10:56:33 -08:00
Vadim Novoseltsev
b6935448d6 selectedBackgroundView (#2875) 2017-02-15 10:37:45 -08:00
Adlai Holler
6af131b093 Undeprecate -[ASCollectionView indexPathForNode:] (#3032) 2017-02-14 22:31:24 -08:00
Adlai Holler
a4c6d8912e Don't Skip Remeasurement On First Layout Pass (#3031)
* Don't Skip Remeasurement if Initial Bounds are Zero

* Remove misleading unit test
2017-02-14 16:28:26 -08:00
Adlai Holler
fab98b32ef Fix Pager Node Issues (#3028)
* Fix pager node and deprecate zeroContentInsets flag

* Do it with the visible state callback

* There we are

* Put viewController in node debug description
2017-02-14 14:10:51 -08:00
Michael Schneider
aecd36a4df [ASViewController] Support optional node (#3021)
* ASViewController can be used without a node
- If a node isn't provided by developers via -initWithNode:, a default one will be created and used internally.
- This allows developers to use ASViewController like a normal UIViewController and as a base class for all view controllers among which some use a node hierarchy and some don't.

* Update ASDKgram to use a shared base ASViewController

* Minor fixes in ASViewController:
- If its node isn't provided by users, don't replace the view controller's view with the default node's view because it might be loaded from a nib.
- Init a vanilla ASDisplayNode if a node isn't provided.

* Some smaller cleanup

* Remove dummy node for ASViewController if it’s used without a node
2017-02-14 13:18:59 -08:00
Adlai Holler
cd448a105e Add lock on ASTextNode.attributedText (#3025) 2017-02-13 15:03:57 -08:00
Rocir Santiago
1bf8488a0f Safer checks in ASDisplayNode’s setFrame before assigning bounds and position (#2773)
* Safer checks in ASDisplayNode’s setFrame before assigning bounds and position

* Consolidate checks in one place

* Assert with ASDisplayNodeNonFatal

* Allow position to be negative
2017-02-13 13:35:37 -08:00
Adlai Holler
bbc1aecf95 Deprecate shouldRasterizeDescendants (#3024)
* Deprecate shouldRasterizeDescendants

* Set superclass right
2017-02-13 13:34:53 -08:00
appleguy
fe0bcec98f [NSArray+Diffing] Use heap-based allocation for array diff. (#2926)
This avoids compiler warnings when using the strictest clang settings.
It also ensures that stack overflow can't occur even with the largest datasets.
2017-02-13 10:43:46 -08:00
Adlai Holler
0badff651a Revert "Route setDelegate: to setAsyncDelegate: (#3007)" (#3023)
This reverts commit 5c8818d107252da8eb6a91cf88237916ec26f5ed.
2017-02-13 10:38:19 -08:00
Michael Schneider
2dca7a0c8d [Debug] Remove not used code around visualizing layout specs (#2991)
* Remove not used code around visualizing layout specs

* This is sad to see but let’s remove the LayoutSpecPlayground for now
2017-02-10 13:09:09 -08:00
Michael Schneider
77f29a8b7b Fix CI that broke due to Yoga merge (#3012)
* Fix CI that broke due to Yoga merge

* Next round

* Add clean before building

* Try something else

* Some more burritos
2017-02-10 11:17:25 -08:00
appleguy
f91265757e [Yoga] Initial commit for supporting Yoga-powered layout calculation. (#2982)
* [Yoga + AsyncDisplayKit] Initial commit for supporting Yoga-powered layout calculation.

Because this results in ASLayout objects, it preserve support for automaticallyManagesSubnodes
as well as the animated transition system. More work remains to vet performance of the new mode,
and it will remain in +Beta for the forseeable future.

I'm not sure that this should ever be used as the primary ASDK layout system, but it should remain an
option for some apps to experiment with if they require an implementation that more strictly mirrors
W3C standard Flexbox.

* [Yoga] Improve usage of ASHierarchyState to ensure simultaneous yoga layouts can't happen.

* [Yoga] Strictly minimize the impact of the Yoga integration on existing code.

Created new file ASDisplayNode+Yoga.mm, reduced size and number of integration points in core code.

* [Yoga] Figured out how to further reduce ASDisplayNode.mm impact by allocating _yogaNode in property accessor, and changing all accesses to use the property.
2017-02-09 16:10:29 -08:00
Adlai Holler
5c8818d107 Route setDelegate: to setAsyncDelegate: (#3007)
* Make ASTableView/ASCollectionView delegate/dataSource unavailable, route setDelegate: to setAsyncDelegate:

* Remove deprecated method from example

* Drop down from unavailable to deprecated
2017-02-09 15:20:26 -08:00
Adlai Holler
e338098e4f Have ASVideoNode override its superclass's designated initializer (#3009) 2017-02-09 14:59:37 -08:00
appleguy
1ec69221e3 [UIImage+ASConvenience] Reorder header and add more documentation. (#3004)
Order the methods so the most valuable one, as_imageNamed, is more immediately noticeable.
Also added a block comment describing its purpose and usage suggestions.
Separated @implementation for fairly unrelated methods by categories.
2017-02-09 13:52:36 -08:00
Garrett Moon
6d9f12c7e9 [ASNetworkImageNode] Assert if both URL and image are set (#2782)
* [ASNetworkImageNode] Assert if both URL and image are set

Here's one other idea for addressing this problem. Essentially,
we assert if you've set both the URL and the image. I've played around
with Pinterest and there's only one case where we hit this (the transition).

So I've also added another method (which is a bummer, it's weird I know)
but there's one good reason to add this method, ephemeralImage, which is
the user doesn't have to manually clear it out like they would if they
used defaultImage to save memory.

Putting this up for discussion.

* Fix comment

* Oh yeah, @dynamic, thanks @adlai

* Remove ephemeralImage
2017-02-09 13:23:44 -08:00
Adlai Holler
0bda7ee230 Repeal and replace ASControlState (#3005) 2017-02-09 13:10:10 -08:00
Adlai Holler
a13b36d63f Allow UICollectionViewLayout to Provide Layout Inspector, Always Update Delegate (#3003)
* Allow UICollectionViewLayout to give us a layout inspector, always call the didChangeDelegate/didChangeDataSource on binding

* Make an assertion

* Update the tests

* Tests use actual layout inspector

* Be more consistent
2017-02-08 22:03:13 -08:00
Scott Goodson
1adfb005ca [Build] Tiny fix to cast intValue to the enume type we're using it as (strict compiler settings can fail without the cast). 2017-02-08 20:30:28 -08:00
appleguy
ca8fcdfe49 [ASScrollNode] Add .scrollDirection property so that internal content sizing can be easily "unlimited" in the direction of scrolling. (#3001) 2017-02-08 16:39:05 -08:00
Adlai Holler
ada553c5a7 Avoid Measuring Cell Nodes with Empty Size Range (#3000)
* Always avoid measuring cell nodes with empty bounds

* Be lenient

* Add required assertion comment

* Avoid importing non-modular header publicly
2017-02-08 13:58:22 -08:00
Rocir Santiago
b33cced1eb [ASDisplayNode] Add support for setting non-fatal error block (#2993)
* Add support for setting non-fatal error block

* Better documentation and fix typos

* Added ASDisplayNodeAssertNonFatal macro that asserts in dev and call block in prod

* Make non fatal error code equals to 1

* Add support for condition in ASDisplayNodeAssertNonFatal

* Only call non fatal block if condition isn’t satisfied
2017-02-07 17:13:33 -08:00
Michael Schneider
f21254593d [Layout] Add extensibility support to ASLayoutElementStyle (#2975)
* Add extensibility support to ASLayoutElementStyle

* Fix some typo
2017-02-07 10:34:09 -08:00
Michael Schneider
d2da941960 Fix some static analyzer warnings (#2999) 2017-02-07 10:33:34 -08:00
Michael Schneider
7e4bf953b1 Move debugName into it’s own protocol out of the ASLayoutElement protocol (#2994) 2017-02-06 20:02:21 -08:00
Michael Schneider
aedac5c299 Remove legacy parent pointer of ASLayoutSpec (#2987) 2017-02-06 20:01:37 -08:00
Adlai Holler
abd9851ddd Restore IGListKit Build & Function (#2988) 2017-02-06 20:00:22 -08:00
Michael Schneider
42b53c9331 [ASLayoutTransition] Remove taking a snapshot in the default layout transition code (#2940)
* Remove taking a snapshot in the default default layout transition code

* Set groupOpacity for root node of animation to true before and restore after animation finished
2017-02-06 15:29:37 -08:00
Adlai Holler
e4c9878de7 Fix the CI (#2992) 2017-02-06 14:45:07 -08:00
Garrett Moon
4e8a2640db Fix a warning preventing pod spec validation. (#2989)
* Fix a warning preventing pod spec validation.

* Add comment, thanks @adlai.
2017-02-06 13:06:52 -08:00
Scott Goodson
9b77f77656 [Build] Fix typo in capitalization of import, which causes build failure on case-sensitive filesystems. 2017-02-05 19:39:44 -08:00
Adlai Holler
86b669dc38 Improve TableLayoutController: Simplify, Fix Crash & Improve Perf (#2969)
* Refactor FlowLayoutController -> TableLayoutController

* Use most conservative row index path
2017-02-05 18:24:15 -08:00
Scott Goodson
f71eba77af [ASCollectionView] Finish support for interoperability with base-class UICollectionViewCells.
This also supports supplementary nodes. It builds off of Adlai's .interop flag but makes necessary
improvements for all of the delegate methods to work in practice with heterogenous cell types.
2017-02-04 20:40:44 -08:00
Michael Schneider
12e4e5b048 [Layout] Improve Layout System Abstraction (#2941)
* Improve Layout Abstraction

* Address naming comments

- Rename ASPrimitiveTraitEnvironment to ASTraitEnvironment
- Rename ASPrimitiveTraitCollectionPropagateDown to ASTraitCollectionPropagateDown
- Rename progagateNewPrimitiveTraitCollection: to propagateNewTraitCollection:
2017-02-03 13:04:20 -08:00
Adlai Holler
a2ff2b9900 Force ASPagerNode pages to be bounds-sized (#2973) 2017-02-03 10:29:15 -08:00
Michael Schneider
d42dcfefc1 [ASNodeController] Move ASNodeController to beta header (#2966)
* Move ASNodeController to beta header

* Make it public

* Change ASNodeController+Beta to .mm
2017-02-02 12:51:33 -08:00
Adlai Holler
404795dc02 Remove Support for iOS 7 (#2930)
* Drop support for iOS 7

* Copy reference images

* Update deployment for sample projects

* Update version

* Update "Life Without Cocoapods"
2017-02-01 14:40:37 -08:00
ricky
39298f6694 [ASIndexedNodeContext] Do not cache the envTraitCollection, use the delegate to request it when needed (#2963)
Caching the envTraitCollection upon creation of `ASIndexedNodeContext` can lead to it becoming out of date. Ask the `id<ASEnvironment>` object for the trait collection when we need it.
2017-02-01 13:38:52 -08:00
Adlai Holler
d7670780b2 Fix Deleting Sections Issue (#2962)
* Add data source to main project

* Remove the idea of deletingSectionsOfKind – always delete all kinds

* Move comment into assertion
2017-01-31 15:39:10 -08:00