187 Commits

Author SHA1 Message Date
appleguy
0598935957 Merge pull request #793 from nguyenhuy/ImproveCellNodeRelayout
ASCellNode delegate to automatically resize in table & collection when -setNeedsLayout called.
2015-11-01 11:11:32 -08:00
Huy Nguyen
fb18e7635b Notify ASCellNodeDelegate even if a relayout doesn't result in a resize
If the delegate is an ASTableView, relayoutAnimation will still be considered for animation.
2015-10-29 21:27:29 +02: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
Huy Nguyen
cd31f884dd Move ASDisplayNodePerformBlockOnMainThread to ASInternalHelpers 2015-10-29 16:09:36 +02:00
Adlai Holler
50485663b9 Never use setAnimationsEnabled: so we don't risk corrupting enabledness 2015-10-28 16:09:56 -07:00
appleguy
2c8626e1f6 Merge pull request #753 from nguyenhuy/DataControllerSortedTransaction
Sort edit commands during batch updating of table and collection views
2015-10-26 13:40:06 -07:00
Huy Nguyen
6644621c04 Revert "Fix unnecessary relayout if table view width is zero initially"
This reverts commit 75331189455af75b2a5c091d7df75380676a47cf.
2015-10-26 14:28:28 +02:00
Huy Nguyen
72fca5395f Inject an ASDataController class to ASTableView, for testing purposes
- Injection can be done via a new internal initializer. The class will be used by ASTableView to create (and configure) a new data controller.
- ASTableViewTests now injects its own type of ASDataController. This facilitates new ways for testing ASTableView-specific behaviours. The first application is counting the number of times relayoutAllNodes is called on the data controller.
2015-10-26 13:52:49 +02:00
Huy Nguyen
1b500e407f Fix comment in ASTableView 2015-10-26 08:37:17 +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
Huy Nguyen
5ea4b1b92d Implement ASChangeSetDataController. 2015-10-26 06:22:30 +02:00
appleguy
8dddcaa74b Merge pull request #766 from levi/levi/synchronous-reloaddata
Add synchronous reloadData methods to ASTableView and ASCollectionView
2015-10-25 21:05:52 -07:00
Huy Nguyen
7533118945 Fix unnecessary relayout if table view width is zero initially
- During initial configuration of a table view with a zero size, for each cell, there is a mismatch between the widths of its content view and constrained size. However, don't relayout the cell immediately because an initial data loading will be performed shortly afterward.
2015-10-25 18:54:11 +02:00
Huy Nguyen
52a259a487 Better names in ASTableView. 2015-10-25 18:30:51 +02:00
Levi McCallum
722b90f1cf Implement basic immediate reloadData method on table and collection view 2015-10-22 21:28:44 -07:00
Levi McCallum
fddb0061b0 Use ASCellNodes for supplementary nodes 2015-10-15 11:40:52 -07:00
Levi McCallum
71966f3549 Relayout all nodes in backing store on relayoutAllNodes 2015-10-15 11:40:51 -07:00
Levi McCallum
1c2046cdf4 Localize debugging LOG definition 2015-10-15 11:40:50 -07:00
Levi McCallum
ed1b737ead Define initial supplementary node creation behavior 2015-10-15 11:40:48 -07:00
Levi McCallum
e9eadac4ae Stub out ASCollectionDataController subclass 2015-10-15 11:40:48 -07:00
Vitaly Baev
03542c5436 Bump the bracket down 2015-10-15 20:01:55 +03:00
Vitaly Baev
8557d65104 ASCellNode selected/highlighted properties 2015-10-15 13:25:12 +03:00
Huy Nguyen
12c087d967 Merge branch 'master' into RelayoutCellAPI 2015-10-12 21:31:49 +03:00
Scott Goodson
a8435b494c Revert "Properly support operating with nil asyncDelegate for Table & Collection."
This reverts commit 77745c55b084c51d57a405073a6e9b00c379f918.

Bug was found / reported in https://github.com/facebook/AsyncDisplayKit/issues/721

Attempting resolution here, but need to fix for current clients now:
https://github.com/facebook/AsyncDisplayKit/pull/724
2015-10-07 14:48:37 -07:00
Huy Nguyen
f13f61c2f0 Add relayout item/row APIs to ASTableView and ASCollectionView. 2015-10-07 21:25:07 +03:00
Scott Goodson
77745c55b0 Properly support operating with nil asyncDelegate for Table & Collection. 2015-10-04 17:11:41 -07:00
Scott Goodson
a58844379c Implementation of Synchronous Concurrency features for AsyncDisplayKit 2.0
This provides internal features on _ASAsyncTransaction and ASDisplayNode to facilitate
implementing public API that allows clients to choose if they would prefer to block
on the completion of unfinished rendering, rather than allow a placeholder state to
become visible.

The internal features are:
-[_ASAsyncTransaction waitUntilComplete]
-[ASDisplayNode recursivelyEnsureDisplay]

Also provided are two such implementations:
-[ASCellNode setNeverShowPlaceholders:], which integrates with both Tables and Collections
-[ASViewController setNeverShowPlaceholders:], which should work with Nav and Tab controllers.

Lastly, on ASDisplayNode, a new property .shouldBypassEnsureDisplay allows individual node types
to exempt themselves from blocking the main thread on their display.

By implementing the feature at the ASCellNode level rather than ASTableView & ASCollectionView,
developers can retain fine-grained control on display characteristics.  For example, certain
cell types may be appropriate to display to the user with placeholders, whereas others may not.

Follow-up work will include unit tests, revisiting names, and the header locations of definitions.
2015-09-27 19:14:36 -07:00
Scott Goodson
ee4b771d5d Fix simple issue with ASTableViewStressTest, make Table / Collection handle changes to dataSource / delegate. 2015-09-24 19:59:12 -07:00
Steven Ramkumar
d09888f9c2 Add a indexPathForNode: to ASTableView 2015-09-22 12:09:56 -07:00
Huy Nguyen
094d2570f5 Force the layout of subviews when _ASTableViewCell transitioned to another state
Relayout will be triggered in layoutSubviews (if needed).
2015-09-16 15:25:40 +03:00
Huy Nguyen
2d575fcafc Relayout table view cell nodes if there is a mismatch between content view size and the node's constrained size
- Above is the generic case. Correctly handling it means relayout when the table view enters or leaves editing mode is solved as well.
- Async data source API removal: In a table view, cell nodes should always fill its content view and table view widths. Thus async data source can no longer provide custom constrained size for cell nodes. This removal allows table view to better handle relayout.
- Some more tests are added to ASTableViewTests to check against use cases handled in this diff.
2015-09-16 11:41:34 +03:00
Huy Nguyen
a8cecbd0ad Avoid doing relayout during initial configuration of table and collection views. 2015-09-08 22:43:28 +03:00
Huy Nguyen
641929c4e5 By default, cell nodes in table view should fill its width. So the min constrained width is updated to enforce this behaviour. 2015-08-21 17:43:40 +03:00
Huy Nguyen
7249661990 Improve relayout when constrained size of all nodes is changed:
- In -layoutSubviews of table and collection views, detect changes that cause a different constrained size for nodes, and trigger relayout immediately.
- Orientation change can be handled by this solution. So, no need to observe to its events.
- Update Kittens example to support iPad (easier to catch bugs on these devices) and add a title to navigation bar (looks a bit nicer).
2015-08-13 06:28:47 +03:00
Huy Nguyen
a3c2dbf8cd Table and collection views' async data source can provide different constrained size per node. And because the size is of type ASSizeRange, it has a min size that is very helpful in many cases.. 2015-08-12 22:45:08 +03:00
Huy Nguyen
219b659b38 - Automatically relayout cells when editing mode is used.
- Add editing mode to Kitten sample.
2015-08-09 00:45:54 +03:00
Huy Nguyen
e657bedd40 Automatically relayout cells after orientation changed. 2015-08-09 00:36:58 +03:00
Ethan Nagel
bf0766169b PR Feedback: Require main thread for all edit commands, various cleanup. 2015-07-20 22:08:19 -07:00
Ethan Nagel
f497639124 Add support automatically adjusting the content offset to UITableView as well as support for performing endUpdates with no animations. Additionally, there are critical bug fixes for ASDataController (begin/end updates delegates not called in correct order) and ASRangeController (failure to fully refresh internal state when inserts or delete are made.) 2015-07-20 14:05:56 -07:00
Ethan Nagel
9762e7cfe6 short-circuit editing calls after the asyncDataSource has been set to nil (ASTableView) 2015-07-16 20:26:28 -07:00
appleguy
58a55f035d Merge pull request #529 from facebook/DataControllerQueues
Overhaul ASDataController and extensively test ASTableView.
2015-07-04 21:06:34 -07:00
Scott Goodson
8fa092fb77 Complete overhaul of ASFlowLayoutController.
Introduced ASIndexPath for efficient handling of index paths in C++ vectors,
while maintaining the readability of ".section" and ".row" instead of
".first" and ".second" inside of complicated business logic.

Confirmed that the working range calls are firing appropriately during
ASTableViewStressTest, including the deallocation of the rich text placeholders
provided by ASTextNode.
2015-07-04 20:22:04 -07:00
Ethan Nagel
4963a88717 Propagate ASCellNode's clipsToBounds value to the __ASTableViewCell. This helps work around a bug we are seeing in some rare cases (selected background view overlaps other cells if size of ASCellNode has changed.) 2015-06-29 21:22:55 -07:00
Scott Goodson
57465c7fd3 Overhaul ASDataController and extensively test ASTableView.
This diff resolves all known consistency issues with ASTableView and ASCollectionView.
It includes significantly more aggressive thrash-testing in ASTableViewStressTest,
which now passes on a variety of device and simulator configurations.  It also updates
the unit tests run on every commit to ensure any regression is caught quickly.

A few of the salient changes in this diff:
- ASTableView now uses Rene's ASCollectionViewLayoutController, and actually uses a
UICollectionViewFlowLayout without any UICollectionView.  This resolves an issue where
ASFlowLayoutController was generating slightly out-of-bounds indicies when programmatically
scrolling past the end of the table content.  Because the custom implementation is likely
faster, I will revisit this later with profiling and possibly returning to the custom impl.
- There is now a second copy of the _nodes array maintained by ASDataController.  It shares
the same node instances, but this does add some overhead to manipulating the arrays. I've
filed a task to follow up with optimization, as there are several great opportunities to
make it faster.  However, I don't believe the overhead is a significant issue, and it does
guarantee correctness in even the toughest app usage scenarios.
- ASDataController no longer supports calling its delegate /before/ edit operations.  No
other class was relying on this behavior, and it would be unusual for an app developer to
use ASDataController directly.  However, it is possible that someone with a custom view
that integrates with ASDataController and ASRangeController could be affected by this.
- Further cleanup of organization, naming, additional comments, reduced code length
wherever possible.  Overall, significantly more accessible to a new reader.
2015-06-28 18:03:45 -07:00
Scott Goodson
06cfe68cbd Clean up ASDataController for readability & API naming consistency. 2015-06-27 11:06:54 -07:00
Ethan Nagel
ae523f4fce better logic for detecting when the pending index path is before or after the visible index paths 2015-06-25 09:53:36 -07:00
Ethan Nagel
baf91b4a45 validate that _pendingVisibleIndexPath is contiguous with visibleIndexPaths before appending it. Also, always return a sorted array of NSIndexPaths 2015-06-24 13:18:12 -07:00
Ethan Nagel
0e37bff7c1 Revert to using a single NSIndexPath for the pending visible item 2015-06-24 13:13:43 -07:00
Scott Goodson
c700618862 Improvements to thread safety during closely spaced edit events.
This applies primarily when beginUpdates / endUpdates is not used.
Due to user interaction-driven edits, like reloads or adding content
at the bottom, sometimes this is unavoidable in app design and thus
critical.

I have a diff in flight to make ASDataController / ASRangeController
robust against very aggressive thrash testing, which will be added
both to the unit test suite and this new example project.
2015-06-21 21:04:09 -07:00
Scott Goodson
ba5a6e15c0 Disable asyncDataFetching in ASTableView and ASCollectionView init methods.
It's currently unreliable for some use cases that issue editing calls while
content is displayed or being interacted with.  The performance gain is not
sufficient to sacrifice correctness for the clients that hit this issue,
so it will remain off until fully resolved.
2015-06-14 19:59:39 -07:00