Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Fix ASTableNode / ASCollectionNode backgroundColor does not apply correctly. #1537

Merged
merged 2 commits into from
Apr 19, 2016
Merged

Fix ASTableNode / ASCollectionNode backgroundColor does not apply correctly. #1537

merged 2 commits into from
Apr 19, 2016

Conversation

maicki
Copy link
Contributor

@maicki maicki commented Apr 15, 2016

If the background color is applied via the pending state it's applied to the layer of the UICollectionView / UITableview. Unfortunately UITableView / UICollectionView does not consider using the layer backgroundColor property as it's background color, so it needs to be applied to the view after the ASCollectionNode / ASTableNode did load and the view is available

@appleguy
Copy link
Contributor

@maicki interesting. So, there is actually a similar workaround for frame. UITableView frame does not work properly if it is set only on the layer, unlike almost all other UIViews.

I think the right fix here is actually to change the property bridge, and always use -[UIView setBackgroundColor:] for a view-backed node. Otherwise, initWithViewBlock: on certain elements like perhaps a custom table (that a developer doesn't need to be async) will have the same issue. There could also be other UIKit classes that override setBackgroundColor: -- because it is difficult for UIKit to intercept the CALayer calls in the way our architecture allows. Lastly, it would reduce the code change.

We would need to change the _ASPendingState to always store a UIColor as regenerating it is too costly. This is fine as the node.backgroundColor is already of this type. It would actually make some drawing operations faster as capturing it as a draw parameter would be quicker that regenerating. For layer-backed we'd call CGColor.

If you'd prefer to land this as-is and file a task for the other change, that's totally fine. I'm not certain how complex the diff would be to make, but it may be simple enough to do now. @maicki just let me know and I will merge this now if you suggest.

If the background color is applied via the pending state it's applied to the layer of the UICollectionView / UITableview. Unfortunately UITableView / UICollectionView does not consider using the layer backgroundColor property as it's background color, so it needs to be applied to the view after the ASCollectionNode / ASTableNode did load and the view is available
…e UIView

- Remove duplicated code in ASCollectionNode and ASTableNode
- Fix setting the pending state to the view if applying the pending state to the view
@@ -19,6 +19,7 @@
#import "ASPendingStateController.h"
#import "ASThread.h"
#import "ASTextNode.h"
#import "ASTableNode.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this if possible

@appleguy appleguy changed the title Fix ASTableNode / ASCollectionNode backgroundColor does not work Fix ASTableNode / ASCollectionNode backgroundColor does not apply correctly. Apr 19, 2016
@appleguy appleguy merged commit 39da098 into facebookarchive:master Apr 19, 2016
@appleguy
Copy link
Contributor

Thanks, this is a great fix because it is so generalized! We can make some tweaks in a followup.

@maicki
Copy link
Contributor Author

maicki commented Apr 19, 2016

@appleguy Here is the follow up PR: #1563

rahul-malik added a commit to TextureGroup/Texture that referenced this pull request Jul 18, 2019
is layerBacked.

Summary:
UIColor can now be a dynamic color provider to support capabilities like Dark Mode in applications. UIKit is able to re-render views when a user enters dark mode but this dynamic capabilities is not handled at the layer level.

Currently this takes the recommendation in facebookarchive/AsyncDisplayKit#1537 (comment) to set background color on the view directly or layer depending on if the node is layer backed. This change allows UIKit to track these colors and update the UI when the UITraitCollection.userInterfaceStyle changes.
nguyenhuy pushed a commit to TextureGroup/Texture that referenced this pull request Jul 20, 2019
* Set background color directly to view or layer depending on if the node
is layerBacked.

Summary:
UIColor can now be a dynamic color provider to support capabilities like Dark Mode in applications. UIKit is able to re-render views when a user enters dark mode but this dynamic capabilities is not handled at the layer level.

Currently this takes the recommendation in facebookarchive/AsyncDisplayKit#1537 (comment) to set background color on the view directly or layer depending on if the node is layer backed. This change allows UIKit to track these colors and update the UI when the UITraitCollection.userInterfaceStyle changes.

* Updates to UIViewBridge to fix tests

* Remove opaque

* Test fixes

* Revert change to test checker method

* Fix strange issue where setting UIView backgroundColor sets the layer to
opaque to false

* Address Huy comments

* Address last comment
aimalygin pushed a commit to aimalygin/AsyncDisplayKit that referenced this pull request Sep 23, 2019
)

* Improve Accessibility Implementation

- Fixes calculations for accessibilityFrame of ASAccessibilityCustomAction and ASAccessibilityElement
- Fix crash for accessibility elements within layer backed nodes
- Fix accessibility action label updating after other actions change the accessibility label of the corresponding node

* Address comments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants