* Implement ASCollectionGalleryLayoutDelegate
- It arranges items of the same size into a multi-line stack (say photo gallery or pager). It takes advantage of the fact that its items always have a fixed size to measure as few items as possible while still being able to track their positions at all time. This helps reduce startup/reloadData time, as well as memory footprint.
- It then uses a measure range, which also works as a allocate range, to figure out which items to measure ahead of time. And it guarantees that each item is scheduled to measure only once.
- Lastly, ASCollectionLayoutDelegate has some new methods that allow delegates to hook up and stay ahead of layout attributes requests from the backing view. ASCollectionGalleryLayoutDelegate for example uses these methods to ensure elements that have their layout attributes requested are always ready for consumption, and to measure more elements in the background.
* Handle items that span multiple pages and other improvements in gallery delegate
* Minor fixes
* Fix failing tests
* Fix custom collection example
* Implement missing method in gallery layout delegate
* Fix warnings
* Some improvements
- Collection layout delegates must have a crollable directions property.
- Simplify gallery delegate by not storing unmeasured attributes since calling measure on already measured elements should be cache hits and super fast.
- Abstact some code in gallery delegate to ASCollectionLayoutState+Private and _ASCollectionGalleryLayoutItem.
- Other improvements in gallery delegate
* Fix file licenses
* Move measure range logic to ASCollectionLayout
* Track unmeasured elements
* Remove pending layout in ASCollectionLayout
* Get back pending layout because the timing to latch new data is not ideal
* Add ASCollectionLayoutCache
* Fix file licenses
* Fix xcodeproj
* Add async collection layout to examples/ASCollectionView
* Measure method in ASCollectionLayout to be a class method
* Encourage more immutable states
- Make -calculateLayoutWithContext: to be class methods in ASDataControllerLayoutDelegate and ASCollectionLayoutDelegate.
- Add layout delegate class and layout cache to ASCollectionLayoutContext+Private, to be use by ASCollectionLayout only.
- ASDataController no longer allocates all nodes but lets ASCollectionLayout determine.
- Add scrollableDirections to the layout context since it's often needed by the layout pass. Otherwise users have to wrap it in an info object.
- Update built-in layout delegates and CustomCollectionView example.
- Publish ASHashing. It might be helpful for clients that implement custom collection info objects.
* Remove additionalInfo property in ASCollectionLayoutState
* ASCollectionLayoutState to correctly filter unmeasured elements
* Add ASHashing to umbrella header
* Fix file licenses
* Add ASDispatchAsync and use it in ASCollectionLayout
* Improve code comment in ASCollectionLayoutState
* [ASTextNode2] Provide compiler flag to enable ASTextNode2 for all usages.
The runtime switch is helpful, but is too slow to be shipped in a large
production application where startup time is carefully optimized.
Although this doesn't pass text-related snapshot tests when enabled, it
does allow apps to rely on built-in components like ASButtonNode using
the same text stack as when they are manually creating ASTextNode2
instances.
A simpler approach would be to use a #define ASTextNode ASTextNode2,
but this would create unusual keyword highlighting in code referencing
ASTextNode. However, because it would be less invasive and this is
not on by default, we could do that instead if preferred.
* Update AsyncDisplayKit.h
* [ASTextNode2] Improve naming and documentation of ASTEXTNODE_EXPERIMENT_GLOBAL_ENABLE
* [ASTextNode2] CHANGELOG.md for #410.
* Implement tests for the layout flattening process
* Refactor the flattening algorithm
- Remove flattened flag
- No more self check
- Stop traversing a layout tree branch when hits a displaynode node.
- Reuse as many existing ASLayout objects as possible
* Update changelog
* Ceil position values before comparing
* Explain why sublayout elements must be retained
* Add support for skipping reload if node decides it is compatible with new view model also
* Sort things right
* Put the order back
* No need for redundant expectation
* Fix license header
* Fix comment
* Update OCMock 2.2 -> 3.4
* Clean up and port ASMultiplexImageNodeTests
* Clean up
* Be stricter about order
* Log change
* Update the licenses #important
* Update the license headers more
* [Yoga] Implement ASYogaLayoutSpec, an experimental alternative to full-tree integration.
This approach allows us to avoid any ASDisplayNode.mm integration points.
However, it is not yet proven to be possible to achieve correctness with this approach.
The entry point (to start calculating), and the measurement function inputs, lack
the full expressiveness of ASSizeRange; we need to make sure that workarounds like
using style.minSize are successful in simulating the behavior of a full Yoga tree.
* [Yoga] Fix file comments, move towards <ASLayoutElement> support.
* [Yoga] Important fix for simplified, non-contiguous Yoga integration.
* [Yoga] Complete implementation of manual memory management (__bridge_transfer, YGNodeFree)
* Add ASBatchFetchingDelegate
- In addition to checking remaining leading screens, ASBatchFetching now also calculates a remaining time and consults its delegate if needed.
- The delegate can override the decision of ASBatchFetching, for example based on remaining time and average time of past batch requests.
* Fix up tests
* Update CHANGELOG
* Add experimental text node implementation, based on YYText
* Fix warnings and alert when unimplemented experimental features are used.
* Address feedback from review
* Extend the cthulog
* Update license headers
* Implement ASPageTable
- It is a screen page table that can be used to quickly filter out objects in a certain rect without checking each and every one of them.
- ASCollectionLayoutState generates and keeps a table that maps page to layout attributes within that page.
- ASCollectionLayout (and later, ASCollectionGalleryLayoutDelegate) consults its layout state for `layoutAttributesForElementsInRect:`. This ensures the method can return as quickly as possible, especially on a large data set (I heard some people have galleries with thousands of photos!).
* Address comments
* Handle items that span multiple pages
* Make danger happy
* Make ASCellNode indexPath and supplementaryElementKind atomic
* Update the change log
* Fix licenses
* Be explicit with atomic
* Rename the protocol
* And the file
* Add _ASCollectionReusableView container for ASCollectionNode supplementary nodes with applyLayoutAttributes support
• Adds support for -[ASCellNode applyLayoutAttributes:] to supplementary nodes
* Ensure _ASCollectionReusableView has layoutAttributes if the collection view doesn’t set them
* Use correct layoutAttributes accessor for supplementary elements
* Introduce ASCollectionViewLayout
- `ASCollectionViewLayout` is an async `UICollectionViewLayout` that encapsulates its layout calculation logic into a separate thread-safe object which can be used ahead of time and/or on multiple threads.
- `ASDataController` now can prepare for a new layout resulted from a change set before `ASCollectionView` even knows about it. By the time the change set it ready to be consumed by `ASCollectionView`, its new layout is also ready.
- New `ASCollectionViewLayoutCalculating` protocol that is simple and generic enough that many types of calculators can be built on top. `ASCollectionViewLayoutSpecCalculator` conforms to `ASCollectionViewLayoutCalculating` protocol and can be backed by any layout spec (e.g `ASStackLayoutSpec`, `PIMasonryLayoutSpec`, etc). We can even build a `ASCollectionViewLayoutYogaCalculator` that uses Yoga internally.
- A built-in `ASCollectionViewFlowLayoutCalculator` that is a subclass of `ASCollectionViewLayoutSpecCalculator` and uses a multi-threaded multi-line `ASStackLayoutSpec` internally. The result is a performant and thread-safe flow layout calculator.
- Finally, `ASCollectionViewLayout` can be subclassed to handle a specific type of calculator with optimizations implemented based on the knowledge of such calculator. For example, `ASCollectionViewFlowLayout` can have a highly optimized implementation of `-layoutAttributesForElementsInRect:`.
Protocolize layout calculator providing and consuming
Add flex wrap documentation
Add a `multithreaded` flag to ASStackLayoutSpec that forces it to dispatch even if it's off main
- Update ASCollectionViewFlowLayoutSpecCalculator to use that flag.
Minor change in ASCollectionViewLayout
Implement Mosaic layout calculator
Minor change
Fix project file
Rename and fix project file
Skip fetching constrained size only if a layout calculator is available
Update examples/ASCollectionView
Remove unnecessary change in ASTableView
Address comments
Rename collection view calculator protocols
Minor changes after rebasing with master
Add ASLegacyCollectionLayoutCalculator for backward compatibility
Remove ASCollectionLayoutSpecCalculator
Remove ASLegacyCollectionLayoutCalculator
Introduce ASCollectionLayout
- A wrapper object that contains content size and an element to rect table.
- Collection layout calculators to return this new object instead of an ASLayout.
Before adding a content cache
Finishing hooking up ASCollectionLayoutDataSource to ASCollectionNode
Stash
Finish ASCollectionLayout
Rough impl of ASCollectionFlowLayout
Revert changes in CustomCollectionView example
Move ASRectTable back to Private
* Rename ASCollectionContentAttributes to ASCollectionLayoutState
* Address other comments
* Introduce ASCollectionLayoutDelegate and make ASCollectionLayout private
* Address comments
* API tweaks:
- Replace `-layoutContextWithElementMap:` in ASCollectionLayoutDelegate with `-additionalInfoForLayoutWithElements:`. The returned object is then stored in ASCollectionLayoutContext for later lookups.
- ASCollectionLayoutContext has no public initializer.
- ASDataControllerLayoutDelegate no longer requires a context of type ASCollectionLayoutContext but simply an `id`. This helps decouple ASDataController and ASCollectionLayout.
- Rename `elementMap` to `elements`.
- Rename `visibleMap` to `visibleElements`.
- Other minor changes.
* Rename ASCGSizeHash to ASHashFromCGSize
* Make sure to call super in -[ASCollectionLayout prepareLayout]
* Update example/ASCollectionView to use ASCollectionFlowLayoutDelegate
* Remove unnecessary change
* Need to check availability before use of macros.
* Get rid of PCH and enforce macro definition.
* Remove prefix
* Switch to global warning instead, much better.
* Clean up snapshot test cases:
- Drop 32bit snapshots
- Update iOS 9 snapshots and move some others to the correct directory
- Remove `setUp` overrides in subclasses of `ASLayoutSpecSnapshotTestCase` that set `recordMode` flag. Doing so in multiple places make it difficult to enable/dis
able the flag for all layout spec test cases. It can always be overridden locally if need
to.
- Fix BUCK build
* Fix testThatOnDidLoadThrowsIfCalledOnLoadedOffMain of ASDisplayNodeTests
* Build ASElementMap and use it
* Keep building!
* Clean up
* Restrict ASDataController subclassing
* Clean up more
* More rearranging
* Dear lord it's time for bed
* Make things clearer
* Sadly remove subclassing restriction for ASDataController
* Remove dead initializer
* 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
* Fix pager node and deprecate zeroContentInsets flag
* Do it with the visible state callback
* There we are
* Put viewController in node debug description
* [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.
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.