Texture - code reading

Updated
May 9, 2021 3:16 PM
Created
Apr 22, 2021 12:45 AM
Tags
Texture (AsyncDisplayKit)
Keywords

How Texture calculates Layout

protocol ASLayoutElement

  • class ASDisplayNode conforms
  • class ASLayoutSpec conforms

ASLayoutElement has

  • set of layoutThatFits
  • set of calculateLayoutThatFits

  • layoutThatFits is entry point to start laying out.
  • calculateLayoutThatFits would be called from layoutThatFits

for example

  • layoutThatFits
    • calculateLayoutThatFits
      • layoutThatFits
        • calculateLayoutThatFits
          • recursively

So, calculateLayoutThatFits gives us to chance to customize layout.

How Texture applies the layout

ASDisplayNode._layoutSublayouts applies the calculated layout to its view or layer.

Memo

  • setNeedsLayout
    • invalidateCalculatedLayout
      • layoutVersion++
  • _layoutSublayouts
    • set frame to node.frame

image

  • _u_setNeedsLayoutFromAbove