Improve cell node relayout - #793
Conversation
f99b099 to
187549d
Compare
- 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.
187549d to
5b8f7e9
Compare
There was a problem hiding this comment.
What's the purpose of having a suggestedAnimation param when this is always automatic? How do you see this being extended?
There was a problem hiding this comment.
It can be set to another value, by another object or in the subclass's initializer.
|
@nguyenhuy Does this mean cells will flash when they resize? In client apps I specifically avoid calling |
"Reload" destroys the existing node and loads a new one. "Relayout" (as in this PR) means the existing node is reused and only its layout is updated. This PR allows you to pass relayout animation (UITableViewRowAnimation) to a cell node, which will then be passed to ASTableView and the underlying UITableView (here). You can also animate the layout changes by wrapping
Yeah, that's because of the delete + insert behaviour. Though you can do some tricks to hide the flash like this, I would recommend avoiding reload methods, as discussed here. |
If the delegate is an ASTableView, relayoutAnimation will still be considered for animation.
There was a problem hiding this comment.
It's only safe to call from the background if the node isn't loaded, right? We should probably just remove that.
|
Thanks for the naming and formatting improvements. This is really a great change and reflects the development philosophy of ASDK, aiming for a smaller API surface that integrates functionality where it makes sense for the developer (e.g. ASCellNode itself bridging table and collection, layout being a concept that should extend to cells' height, etc) |
ASCellNode delegate to automatically resize in table & collection when -setNeedsLayout called.
…r view is necessarily alive (has a superview). (facebookarchive#793) * fix SIMULATE_WEB_RESPONSE not imported facebookarchive#449 * Fix to make rangeMode update in right time * Keep collection/table node alive if view still in use.
As discussed in #792:
-relayoutItemAtIndexPathand-relayoutRowAtIndexPathare removed (Add relayout item/row APIs to ASTableView and ASCollectionView #722, [ASLayoutSpec] ASNetworkImageNode with unknown height don't update ASCellNode's height #718).