4229 Commits

Author SHA1 Message Date
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
0e73f4ad5e Fix warnings (#3194) 2017-03-17 07:15:31 -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
Ahmed Denison-Afifi
b1cfd76cee Update example podfile platform to match AsyncDisplayKit (#3176)
* Update podfile platform
2017-03-14 12:34:06 +00:00
Michael Schneider
dae3a72d4b [Tests] Add launch image back for test host app (#3171)
* Add launch image back

* Add TestHostResources back to BUCK file

* Use the new launch image in Buck
2017-03-13 09:10:55 -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
54325ecf66 Minor fix in ASStackLayoutSpecSnapshotTests (#3160) 2017-03-09 14:21:29 -08: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
Adlai Holler
f5951d906e Use fast enumeration for ASElementMap enumerating (#3137) 2017-03-04 15:18:41 -08:00
Adlai Holler
fad40c26c2 Remove ASTableView's pendingVisibleIndexPath system (#3125) 2017-03-04 12:52:28 -08:00
Adlai Holler
2785a0bcd8 Pager should invalidate flow layout metrics on bounds change (#3133) 2017-03-04 11:01:09 -08:00
Adlai Holler
0de270fdfb Revert "Improve designated initializer usage (#3132)"
This reverts commit eaa875c7f2e08afa8b597c653be6b7c45cfff66d.
2017-03-03 15:31:28 -08:00
Michael Schneider
eaa875c7f2 Improve designated initializer usage (#3132)
* Improve designated initializer usage

* Some more changes

* Add some whitespace

* Fix some warning
2017-03-03 14:49:34 -08:00
Michael Schneider
62d7e14ce1 Improve measurement code for cell nodes (#3119) 2017-03-03 09:24:04 -08:00
Adlai Holler
93809bd4e7 Add a Convenience Property to Get Owning View Controller (#3076)
* Add a convenience property -closestViewController

* Address comments
2017-03-02 11:51:16 -08:00
Adlai Holler
012b378a22 Fix a Compiler Warning from ASAbstractLayoutController.mm (#3123)
* Fix a compiler warning about ASAbstractLayoutController

* Fix merge
2017-03-02 10:59:26 -08:00
Adlai Holler
9c7081f2d7 Majorly Simplify ASTableLayoutController (#3124)
* Majorly Simplify ASTableLayoutController

* Remove the setVisibleNodeIndexPaths: API
2017-03-02 10:59:13 -08:00
Huy Nguyen
415005b6fc ASStackLayoutSpec utilizes multiple threads if it runs on main (#3116) 2017-03-02 10:12:53 -08:00
Adlai Holler
bccfc6c779 Don't Load Table/Collection Node Just Because User Updated (#3120)
* Allow user to update collection/table without forcing view to load

* Capture animation enabledness
2017-03-02 10:11:30 -08:00
Michael Schneider
62c5138676 [ASDisplayNode] Fix node is showing up as black box if wrapping an UIActivityIndicatorView (#3121)
* Set the node to not opaque if it’s wrapping an UIActivityIndicatorView

* Add check for subclass of UIVisualEffectView to see if the node needs to be opaque
2017-03-02 08:57:17 -08:00
Adlai Holler
18dc91ccc2 Remove ASRangeController's viewport API (#3122) 2017-03-02 08:38:01 +00:00
appleguy
edd2ce98f7 [ASRangeController] Optimize calls into UICollectionViewLayout via union rect technique. (#3102)
Details in https://github.com/facebook/AsyncDisplayKit/issues/3082
2017-03-01 21:06:18 -08:00
appleguy
f7dbb2013e [ASCollectionView] Interop mode should always call sizeForItem: method for index paths that don't use ASCellNodes. (#3115) 2017-03-01 19:57:51 -08:00