[Layout] Improve Layout System Abstraction#2941
[Layout] Improve Layout System Abstraction#2941maicki merged 2 commits intofacebookarchive:masterfrom maicki:MSImproveLayoutAbstractionTakeTwo
Conversation
|
test this please |
|
@maicki do you really think we should remove all of ASEnvironment? I remember when you wrote it (and we talked about its design together), and I still think it is one of the most interesting and unique systems in ASDK. Although adoption was not completed, I feel it would be very valuable (and is great, flexible code) if we can get ASInterfaceState and ASHierarchyState into the ASEnvironment struct, as was originally intended / in-progress when we had to jump to other projects. This wouldn't need to be done right now, and I do still agree that removing layout propagation from ASEnvironment makes sense. One reason I say this is because the integration idea I have for Yoga will almost certainly be able to use ASEnvironment as a central mechanism for keeping the Yoga tree up to date with the ASDK children tree. |
|
@appleguy Yes for now we should get rid of |
|
Ready for first review. CC @nguyenhuy |
|
Nice! Thoughts:
|
|
Adlai-Holler
left a comment
There was a problem hiding this comment.
A couple notes on naming and then we can land.
| /** | ||
| * Abstraction on top of UITraitCollection for propagation within AsyncDisplayKit-Layout | ||
| */ | ||
| @protocol ASPrimitiveTraitEnvironment <NSObject> |
There was a problem hiding this comment.
Let's name this protocol ASTraitEnvironment.
| ASEnvironmentTraitCollection traitCollection = [self environmentTraitCollectionForUITraitCollection:self.traitCollection]; | ||
| [self progagateNewEnvironmentTraitCollection:traitCollection]; | ||
| ASPrimitiveTraitCollection traitCollection = [self primitiveTraitCollectionForUITraitCollection:self.traitCollection]; | ||
| [self progagateNewPrimitiveTraitCollection:traitCollection]; |
There was a problem hiding this comment.
Nit: let's call this method -propagateNewTraitCollection:.
|
|
||
| // Now that we have a supernode, propagate its traits to self. | ||
| ASEnvironmentStatePropagateDown(self, [newSupernode environmentTraitCollection]); | ||
| ASPrimitiveTraitCollectionPropagateDown(self, newSupernode.primitiveTraitCollection); |
There was a problem hiding this comment.
Let's call this ASTraitCollectionPropagateDown. In cases where there won't be ambiguity, we should omit the word Primitive because it's non-essential.
- Rename ASPrimitiveTraitEnvironment to ASTraitEnvironment - Rename ASPrimitiveTraitCollectionPropagateDown to ASTraitCollectionPropagateDown - Rename progagateNewPrimitiveTraitCollection: to propagateNewTraitCollection:
|
@Adlai-Holler Addressed your comments ready for next review. Thanks! |
Currently our layout system is pretty coupled to the overall ASDK system. This PR is the first step to loosen up this coupling.
For now it:
ASLayoutElement.ASEnvironmentand introduces trait collection support that would allow us to more easier compile out in certain cases.ASLayoutElementStyleExtensionsout fromASEnvironmentTODO:
ASLayoutElementTraitCollectionrelated code toASTraitCollection_extensionsASLayoutElementASEnvironmentTraitCollectionas deprecatedASEnvironmentrelated files from projectASLayoutElementTraitCollectiontoASPrimitiveTraitCollection