Inherits from NSObject
Conforms to RCTViewNodeProtocol
Declared in RCTShadowView.h

Overview

ShadowView tree mirrors RCT view tree. Every node is highly stateful. 1. A node is in one of three lifecycles: uninitialized, computed, dirtied. 1. RCTBridge may call any of the padding/margin/width/height/top/left setters. A setter would dirty the node and all of its ancestors. 2. At the end of each Bridge transaction, we call collectUpdatedFrames:widthConstraint:heightConstraint at the root node to recursively lay out the entire hierarchy. 3. If a node is “computed” and the constraint passed from above is identical to the constraint used to perform the last computation, we skip laying out the subtree entirely.

Tasks

Properties

alignItems

@property (nonatomic, assign) css_align_t alignItems

alignSelf

@property (nonatomic, assign) css_align_t alignSelf

backgroundColor

@property (nonatomic, strong) UIColor *backgroundColor

borderBottomWidth

@property (nonatomic, assign) CGFloat borderBottomWidth

borderLeftWidth

@property (nonatomic, assign) CGFloat borderLeftWidth

borderRightWidth

@property (nonatomic, assign) CGFloat borderRightWidth

borderTopWidth

@property (nonatomic, assign) CGFloat borderTopWidth
Discussion

Border. Defaults to { 0, 0, 0, 0 }.

Declared In

RCTShadowView.h

bottom

@property (nonatomic, assign) CGFloat bottom

cssNode

@property (nonatomic, assign, readonly) css_node_t *cssNode

flex

@property (nonatomic, assign) CGFloat flex

flexDirection

@property (nonatomic, assign) css_flex_direction_t flexDirection
Discussion

Flexbox properties. All zero/disabled by default

Declared In

RCTShadowView.h

flexWrap

@property (nonatomic, assign) css_wrap_type_t flexWrap

frame

@property (nonatomic, assign) CGRect frame

hasOnLayout

@property (nonatomic, assign) BOOL hasOnLayout

height

@property (nonatomic, assign) CGFloat height

justifyContent

@property (nonatomic, assign) css_justify_t justifyContent

layoutLifecycle

@property (nonatomic, assign) RCTUpdateLifecycle layoutLifecycle

left

@property (nonatomic, assign) CGFloat left

marginBottom

@property (nonatomic, assign) CGFloat marginBottom

marginLeft

@property (nonatomic, assign) CGFloat marginLeft

marginRight

@property (nonatomic, assign) CGFloat marginRight

marginTop

@property (nonatomic, assign) CGFloat marginTop
Discussion

Margin. Defaults to { 0, 0, 0, 0 }.

Declared In

RCTShadowView.h

newView

@property (nonatomic, assign, getter=isNewView) BOOL newView
Discussion

isNewView - Used to track the first time the view is introduced into the hierarchy. It is initialized YES, then is set to NO in RCTUIManager after the layout pass is done and all frames have been extracted to be applied to the corresponding UIViews.

Declared In

RCTShadowView.h

paddingBottom

@property (nonatomic, assign) CGFloat paddingBottom

paddingLeft

@property (nonatomic, assign) CGFloat paddingLeft

paddingRight

@property (nonatomic, assign) CGFloat paddingRight

paddingTop

@property (nonatomic, assign) CGFloat paddingTop
Discussion

Padding. Defaults to { 0, 0, 0, 0 }.

Declared In

RCTShadowView.h

positionType

@property (nonatomic, assign) css_position_type_t positionType

right

@property (nonatomic, assign) CGFloat right

superview

@property (nonatomic, weak, readonly) RCTShadowView *superview

top

@property (nonatomic, assign) CGFloat top
Discussion

Position and dimensions. Defaults to { 0, 0, NAN, NAN }.

Declared In

RCTShadowView.h

viewName

@property (nonatomic, copy) NSString *viewName

width

@property (nonatomic, assign) CGFloat width

Instance Methods

applyLayoutNode:viewsWithNewFrame:absolutePosition:

- (void)applyLayoutNode:(css_node_t *)node viewsWithNewFrame:(NSMutableSet *)viewsWithNewFrame absolutePosition:(CGPoint)absolutePosition
Discussion

Recursively apply layout to children.

Declared In

RCTShadowView.h

collectRootUpdatedFrames:parentConstraint:

- (void)collectRootUpdatedFrames:(NSMutableSet *)viewsWithNewFrame parentConstraint:(CGSize)parentConstraint
Discussion

Calculate all views whose frame needs updating after layout has been calculated. The viewsWithNewFrame set contains the reactTags of the views that need updating.

Declared In

RCTShadowView.h

collectUpdatedProperties:parentProperties:

- (void)collectUpdatedProperties:(NSMutableSet *)applierBlocks parentProperties:(NSDictionary *)parentProperties
Discussion

Calculate property changes that need to be propagated to the view. The applierBlocks set contains RCTApplierBlock functions that must be applied on the main thread in order to update the view.

Declared In

RCTShadowView.h

dirtyLayout

- (void)dirtyLayout

dirtyPropagation

- (void)dirtyPropagation

dirtyText

- (void)dirtyText

fillCSSNode:

- (void)fillCSSNode:(css_node_t *)node
Discussion

The following are implementation details exposed to subclasses. Do not call them directly

Declared In

RCTShadowView.h

isLayoutDirty

- (BOOL)isLayoutDirty

isPropagationDirty

- (BOOL)isPropagationDirty

isTextDirty

- (BOOL)isTextDirty

measureLayoutRelativeToAncestor:

- (CGRect)measureLayoutRelativeToAncestor:(RCTShadowView *)ancestor
Discussion

Computes the recursive offset, meaning the sum of all descendant offsets - this is the sum of all positions inset from parents. This is not merely the sum of top/lefts, as this function uses the actual positions of children, not the style specified positions - it computes this based on the resulting layout. It does not yet compensate for native scroll view insets or transforms or anchor points.

Declared In

RCTShadowView.h

paddingAsInsets

- (UIEdgeInsets)paddingAsInsets

processUpdatedProperties:parentProperties:

- (NSDictionary *)processUpdatedProperties:(NSMutableSet *)applierBlocks parentProperties:(NSDictionary *)parentProperties
Discussion

Process the updated properties and apply them to view. Shadow view classes that add additional propagating properties should override this method.

Declared In

RCTShadowView.h

setBorderWidth:

- (void)setBorderWidth:(CGFloat)value

setMargin:

- (void)setMargin:(CGFloat)margin

setMarginHorizontal:

- (void)setMarginHorizontal:(CGFloat)margin

setMarginVertical:

- (void)setMarginVertical:(CGFloat)margin

setPadding:

- (void)setPadding:(CGFloat)padding

setPaddingHorizontal:

- (void)setPaddingHorizontal:(CGFloat)padding

setPaddingVertical:

- (void)setPaddingVertical:(CGFloat)padding

setSize:

- (void)setSize:(CGSize)size

setTextComputed

- (void)setTextComputed

setTopLeft:

- (void)setTopLeft:(CGPoint)topLeft

updateLayout

- (void)updateLayout
Discussion

Triggers a recalculation of the shadow view’s layout.

Declared In

RCTShadowView.h