579 Commits

Author SHA1 Message Date
Adlai Holler
873ae64cec Remove macOS support (#3245) 2017-04-05 11:58:11 -07:00
Garrett Moon
30ad10da3c _setImage wasn't calling correct implementation (#3243)
_setImage is intended to call the super version of the method,
however with the adoption of the new _locked_ prefix, ASImageNode's
implementation would call back into ASNetworkImageNode's implementation.
This restore the intent of the _setImage method.
2017-04-04 15:13:10 -07:00
Huy Nguyen
75ad248f8c Fix failing build in XCode 8.3 (#3241) 2017-04-04 14:37:45 -07:00
Adlai Holler
e1f7b86756 Add support for IGListKit > 2.1, without IGListCollectionView (#3239) 2017-04-03 12:52:36 -07:00
Adlai Holler
42eb955d8f Range controller: do not schedule range update after rendering finishes if already in full range mode (#3236) 2017-04-03 09:57:16 -07:00
Adlai Holler
c7794a31dd Beef up the headers for ASSectionController and ASSupplementaryNodeSource (#3233) 2017-04-03 11:09:57 +01:00
appleguy
d4af736985 [ASCollectionView] Improve interop to silence invalid layout warnings, fix supplementary passthrough. (#3178)
* [ASCollectionView] Improve interop to silence invalid layout warnings, fix supplementary passthrough.

Before this change, passthrough of supplementary elements didn't work properly -- it would get rehosted into the blank ASCellNode.

* [ASCollectionView] Ensure that IGListKit-handled supplementary views are sent through ASRangeController.

* [ASCellNode] When .shouldUseUIKitCell == YES, don't remove the subviews of the .contentView
2017-04-02 12:11:44 -07:00
Huy Nguyen
6abccf5841 ASDataController can bail early if a change set is empty (#3225) 2017-03-31 10:48:11 -07:00
Huy Nguyen
3d19923731 [Trait collection] Correctly handle changes that occur mid-updates (#3224)
* Add unit test to test trait collection changes occur during updates are handles correctly

* Remove handling code in ASDataController:updateWithChangeSet. Previous test should fail

* Correctly handle trait collection changes that occur mid-updates
- Currently, when there is a new trait collection, we correctly propagate it to all visible elements. However, since the propagating block is executed on main thread immediately without waiting for the background editing queue of ASDataController, not all elements are updated.
- Then to fix that, we updated ASDataController to handle these changes inside updateWithChangeSet. This works, but it doesn’t address the underlying issue.
- We now delegate the propagating task to ASDataController which schedule a block to its main serial queue after waiting for its background editing queue.
2017-03-31 10:47:59 -07:00
Adlai Holler
fcbbea51a6 Fix the Initialization Hierarchy (#3207)
* Fix the initializers setup

* Update Swift example

* Remove incorrect comment

* Add one to ASTableNode
2017-03-28 11:48:20 -07:00
Adlai Holler
27c94069ae Add a category to _ASCollectionViewCell that makes it IGListBindable (#3226) 2017-03-28 11:27:38 -07:00
Michael Schneider
1f042e960d [ASNetworkImageNode] Improve locking (#3187)
* Locking improvements for ASNetworkImageNode

* Fix typo

* Address comments

* Address comments

* Change comment to kick build
2017-03-28 10:42:59 +01:00
Huy Nguyen
0f50cd02c9 Fix locking situation of layout transition (#3217)
- It's not safe to hold the lock of a supernode and:
  - Edit states of its subnodes
  - Call subclass hooks
  - Run completion block
  - Run animation, which can trigger layout passes on subnodes, especially if one of them is a collection view.
2017-03-24 10:35:43 -07:00
Huy Nguyen
ead2086f96 Fix deadlock while laying out subnodes (#3218) 2017-03-24 10:35:34 -07:00
Huy Nguyen
fc588c5e39 Avoid adding nil element which represents an unsupported decoration view (#3215) 2017-03-23 15:53:13 -07:00
Adlai Holler
d3d0f7be09 Add Support for the Run Loop Queue to be Weak (#3214)
* Add support for the run loop queue to be weak

* Go back to using a deque for itemsToProcess

* Update comment
2017-03-23 15:43:31 -07:00
Adlai Holler
740fc3f4c1 Make the run loop source context a stack object (#3213) 2017-03-23 15:42:15 -07:00
Huy Nguyen
36de258ff9 Avoid multiple initial data loads being issued by UICollectionView/UITableView (#3208)
* Avoid multiple initial data loads being issued by UICollectionView/UITableView
- Currently, there is a gap between the moment UICollectionView/UITableView triggers its first data load and when ASDataController finishes processing it. During this gap, the view keeps issuing "initial" loads by calling reloadData and causes its data controller to reload multiple times.
- Fix by immediately forward the first reloadData call to UICollectionView/UITableView before letting its data controller to handle it for real. During the gap, the view thinks that it loaded initial data but is empty, and thus stops triggering initial loads. Once the data controller finished loading, it will call another reloadData on the view which causes the view to swap to a correct state.

* Fix tests

* Use the existing flag of ASDataController

* Explain unit test
2017-03-23 11:14:05 +00:00
Adlai Holler
9129fa73d0 Simplify composedTruncationText Logic (#3211)
* Clean up the logic around composed truncation text

* Update comment
2017-03-22 13:03:09 -07:00
ricky
43f39bc2e3 [ASTextNode] Reset _composedTruncationText when attributedText is updated (#3210)
* [ASTextNode] Reset _composedTruncationText when attributedText is updated

Current issue:
1) Set `attributedText` in `ASTextNode` with whiteColor
2) `_composedTruncationText` gets updated to take on this new color attribute
3) Set the `attributedText` with greenColor
4) The `_composedTruncationText` gets updated with the new attributes, but does NOT overwrite any existing attributes — i.e., does not overwrite the white color with green. Comment from `_locked_prepareTruncationStringForDrawing:`:
`
// Add any of the original string's attributes to the truncation string,
// but don't overwrite any of the truncation string's attributes
`

* michael’s suggestion
2017-03-22 10:55:25 -07:00
Adlai Holler
c08ecd7c93 Fix retain cycle in ASCellNode when used with non-ASViewControllers (#3206) 2017-03-21 13:17:23 -07:00
Huy Nguyen
54816ee1f2 [ASCollectionElement] Fix trait collection handling (#3200)
* Fix trait collection handling in ASCollectionElement
- Don't store a trait environment directly and request it when needed. The environment is often the cotaining collection/table node. Asking it for a trait collection is an upward tree traversal and can cause deadlocks. This reverts #2963.
- If the environment changes during a change set update, notify all visible elements about the change. This fixes #2959.

* Address comments
2017-03-21 18:03:23 +00:00
appleguy
03d9873cb2 [ASCollectionNode] Add .collectionViewClass to ASCollectionNode+Beta. (#3198)
Although we may not want to support this property long-term, there are some usages of it
that are difficult to avoid. Specifically because the complexity it adds is both low,
and contained to a small area of the code that would be easy to remove it, it would be
great to support this.

The usage relates to apps that require the Interop protocol, and are architected to expect
a few methods / protocols being implemented on the UICollectionView class itself. It does
not directly override ASCollectionView behaviors. So hypothetically, it would also work
if it were possible to set ASCollectionView's superclass.

Instead, the app is making its own subclass descend from ASCollectionView and use the interop
APIs, even in environments where there are no ASCellNodes ever returned.
2017-03-21 09:54:53 -07:00
Flo
d5a84bf7b1 [ASImageProtocols] Fix nullables to avoid bridging crashes (#3190)
* [ASMultiplex/NetworkImageNode] Ensure ASImageProtocols are not called with nil arguments.

* [ASBasic/PINRemoteImageDownloader] Do not check for nil downloadIdentifier needlessly.

* [ASImageCacheProtocol] Make synchronouslyFetchedCachedImageWithURL URL nonnull.
2017-03-17 11:46:10 -07:00
Michael Schneider
39a2d7eebb Fix shadowing variable in [ASTextNode setTextContainerInset] (#3188) 2017-03-15 16:44:50 -07:00
Michael Schneider
bc05227631 Check in layout transition if the supernode is still the node that is executing the transition (#3181)
We have to check in this case if the supernode of the subnode is indeed the _node that executes a layout transition. It can happen that a node already did a layout transition and added this subnode, in this case the subnode would would be removed from the new node instead of _node.
2017-03-15 13:20:01 -07:00
Huy Nguyen
7a11c4b32b Fix recursive description of ASDisplayNode (#3186)
- Before this commit:
  - Bridged properties are accessed to construct a recursive description without considering thread affinity.
  - We have multiple methods that does the same thing: generates a debug description.
- After this commit:
  - Bridged properties are accessed without triggering thread affinity assertions.
  - We have only one method that provides debug description of a node. It is then used to construct a recursive description.
2017-03-15 18:20:19 +00:00
Michael Schneider
ef2ed54d0b [ASDisplayNode] Add locking to view and layer in ASDisplayNode (#3179)
* Add locking to view and layer in ASDisplayNode

* Another approach

* Some more

* Address comments
2017-03-15 09:05:38 -07:00
Huy Nguyen
bf41847665 Don't load collection/table node just to wait for updates to be committed (#3182)
- Because there would be no update otherwise.
2017-03-15 08:55:50 -07:00
Michael Schneider
e6ee24debc [ASDisplayNode] Improve locking in ASDisplayNode (#3172)
* Improve locking in ASDisplayNode

* Address first bunch of comments

* Changed `view` and `layer` methods for locking

* Adress comments
2017-03-14 07:27:34 -07:00
Michael Schneider
be74cd8231 Cell nodes can be used without using it within a collection or table view. In this case if a size change happened we should call super as there is no interactionDelegate (#3168) 2017-03-13 07:33:06 -07:00
Huy Nguyen
326c97a0c1 When update title of a button node, need to get title node via setter (#3167)
* When update title of a button node, need to get title node via setter

* Explain why we need to call self.titleNode

* Fix previous comment
2017-03-11 09:12:00 -08:00
Huy Nguyen
74b9b56632 flexShrinkAdjustment lambda must always return CGFloat (#3166) 2017-03-11 06:58:04 -08:00
Michael Schneider
0540c863ca Improve locking situation in ASDisplayNode subclasses (#3159)
* Improve locking situation in ASDisplayNode subclasses

* Adress first number of comments

* Don’t hold the lock while calling _updateComposedTruncationText
2017-03-10 17:29:09 +00:00
Michael Schneider
0d0176d376 ASControlNode should not receive any touches if it’s disabled (#3161) 2017-03-10 17:14:20 +00:00
Adlai Holler
bfe35fc0b1 Add production workaround for missing elements (#3158) 2017-03-10 14:35:20 +00:00
Adlai Holler
a0e67a8b15 ASMultidimensionalArrayUtils -> ASTwoDimensionalArrayUtils (#3157)
* Requery subarray count less in ASMultidimensionalArrayUtils

* Simplify (gut) ASMultidimensionalArrayUtils

* Remove weird change

* Add bounds-checking for graceful failure
2017-03-10 14:33:30 +00:00
Huy Nguyen
18c906aa5c Some bug fixes for ASStackLayoutSpec: (#3153)
- Avoid returning a NaN flexShrinkAdjustment.
- Bail early (instead of assert) if a line has a positive `flexFactorSum` but then no flexible item can be found via flex adjustments, for example because the flexible items have zero size.
- Continue flexing other lines when one line is inflexible.
- Add unit test for the first 2 fixes.
2017-03-09 13:35:17 -08:00
Huy Nguyen
4f440a34e0 Gratefully handle unknown headers and footers in collection view (#3154)
- UICollectionViewFlowLayout asks its delegate, which is ASCollectionView, for reference size of headers and footers. If a header or footer is unavailable, its backing collection element will be nil and a zero size should be returned immediately.
2017-03-09 13:35:08 -08:00
Michael Schneider
f0de855970 [ASControlNode] Align touch and tracking system in ASControlNode to UIControl (#3145)
* Align touch and tracking system in ASControlNode to UIControl

Currently the touch and tracking system of ASControlNode does not align with the system of UIControl. ASControlNode does not even consider `beginTrackingWithTouch:withEvent:` or `continueTrackingWithTouch:withEvent:`.
This commit will change the ASControlNode logic around touch event handling and tracking to align with UIControl.

* Add assertion for layer backed nodes that would like to add an action target for a control event

* Adress comments
2017-03-09 12:43:29 -08:00
Adlai Holler
7ec293d590 Add Validation to ASElementMap to Avoid Crashes in Production (#3156)
* Add validation to ASElementMap to avoid production crashes

* Only assert sometimes
2017-03-09 12:19:28 -08:00
Adlai Holler
3155d72882 When converting index paths, only wait if asked (#3155) 2017-03-09 10:56:35 -08:00
Adlai Holler
44d9415ab7 Don't Eagerly Trigger Relayout in Wait (#3134)
* Don’t eagerly reload data in wait

* Update tests to account for new reloadData behavior
2017-03-08 10:43:38 -08:00
Huy Nguyen
dd8cac4414 Add a concurrent flag to ASStackLayoutSpec that is off by default (#3148) 2017-03-08 16:33:50 +00:00
Huy Nguyen
21953c97ef -actionForLayer:forKey: of ASDisplayNode should return nil to avoid the node being animated by CA when it's being moved from one supernode to another (#3146)
This reverts commit 1d21c0bd5545741f284e553d7ed003c69fa6897c introduced in #3063.
2017-03-08 14:02:12 +00:00
Michael Schneider
cbd8714260 Fix crashes while subclassing ASDisplayNode and subclasses in Swift (#3143) 2017-03-07 07:36:08 -08:00
Adlai Holler
1d6221c52b Don't Cache ConstrainedSize in ASCollectionView (#3136)
* Never reuse constrained sizes when measuring collection view items

* Assert main thread

* Fix the build
2017-03-06 10:11:56 -08:00
Adlai Holler
d59ea3902d Initial Work for Range Controller to Support Supplementary Elements (#3140)
* Initial work supporting supplementaries in range controller

* Rename indexPathForElementIfItem
2017-03-06 10:11:00 -08:00
Michael Schneider
d0ad24808b Fix setting selectedBackgroundView in collection view (#3131) 2017-03-06 07:19:44 -08:00
Michael Schneider
2df392261e [ASVideoPlayerNode] Fixes and improvements (#3135)
* Improvements for ASVideoPlayer, especially around asset handling and API

* Change legacy URL of videos

* Address comments
2017-03-05 19:28:03 +00:00