public interface ReactShadowNode<T extends ReactShadowNode>
YogaNode
to allow that. They also help with handling
Common base subclass of YogaNode
for all layout nodes for react-based view. It extends
YogaNode
by adding additional capabilities.
Instances of this class receive property updates from JS via @{link UIManagerModule}.
Subclasses may use #updateShadowNode
to persist some of the updated fields in the node
instance that corresponds to a particular view type.
Subclasses of ReactShadowNode
should be created only from ViewManager
that
corresponds to a certain type of native view. They will be updated and accessed only from JS
thread. Subclasses of ViewManager
may choose to use base class ReactShadowNode
or
custom subclass of it if necessary.
The primary use-case for ReactShadowNode
nodes is to calculate layouting. Although
this might be extended. For some examples please refer to ARTGroupYogaNode or ReactTextYogaNode.
This class allows for the native view hierarchy to not be an exact copy of the hierarchy
received from JS by keeping track of both JS children (e.g. getChildCount()
and
separately native children (e.g. getNativeChildCount()
). See NativeViewHierarchyOptimizer
for more information.
Modifier and Type | Method and Description |
---|---|
void |
addChildAt(T child,
int i) |
void |
addNativeChildAt(T child,
int nativeIndex)
Adds a child that the native view hierarchy will have at this index in the native view
corresponding to this node.
|
void |
calculateLayout() |
void |
dirty() |
boolean |
dispatchUpdates(float absoluteX,
float absoluteY,
UIViewOperationQueue uiViewOperationQueue,
NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer) |
void |
dispose() |
T |
getChildAt(int i) |
int |
getChildCount() |
java.lang.String |
getHierarchyInfo() |
YogaDirection |
getLayoutDirection() |
float |
getLayoutHeight() |
float |
getLayoutWidth() |
float |
getLayoutX() |
float |
getLayoutY() |
int |
getNativeChildCount() |
int |
getNativeOffsetForChild(T child)
Returns the offset within the native children owned by all layout-only nodes in the subtree
rooted at this node for the given child.
|
T |
getNativeParent() |
ReactStylesDiffMap |
getNewProps() |
float |
getPadding(int spacingType) |
T |
getParent() |
int |
getReactTag() |
T |
getRootNode() |
int |
getScreenHeight() |
int |
getScreenWidth() |
int |
getScreenX() |
int |
getScreenY() |
YogaValue |
getStyleHeight() |
YogaValue |
getStylePadding(int spacingType) |
YogaValue |
getStyleWidth() |
ThemedReactContext |
getThemedContext()
Get the
ThemedReactContext associated with this ReactShadowNode . |
int |
getTotalNativeChildren() |
java.lang.String |
getViewClass() |
boolean |
hasNewLayout() |
boolean |
hasUnseenUpdates() |
boolean |
hasUpdates() |
int |
indexOf(T child) |
int |
indexOfNativeChild(T nativeChild) |
boolean |
isDescendantOf(T ancestorNode) |
boolean |
isDirty() |
boolean |
isLayoutOnly() |
boolean |
isMeasureDefined() |
boolean |
isVirtual()
Nodes that return
true will be treated as "virtual" nodes. |
boolean |
isVirtualAnchor()
Nodes that return
true will be treated as a root view for the virtual nodes tree. |
boolean |
isYogaLeafNode()
Nodes that return
true will not manage (and and remove) child Yoga nodes. |
void |
markLayoutSeen() |
void |
markUpdated() |
void |
markUpdateSeen() |
T |
mutableCopy() |
T |
mutableCopyWithNewChildren() |
T |
mutableCopyWithNewChildrenAndProps(ReactStylesDiffMap newProps) |
T |
mutableCopyWithNewProps(ReactStylesDiffMap newProps) |
void |
onAfterUpdateTransaction() |
void |
onBeforeLayout()
This method will be called by
UIManagerModule once per batch, before calculating
layout. |
void |
onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue)
Called after layout step at the end of the UI batch from
UIManagerModule . |
void |
removeAllNativeChildren() |
void |
removeAndDisposeAllChildren() |
T |
removeChildAt(int i) |
T |
removeNativeChildAt(int i) |
void |
setAlignContent(YogaAlign alignContent) |
void |
setAlignItems(YogaAlign alignItems) |
void |
setAlignSelf(YogaAlign alignSelf) |
void |
setBaselineFunction(YogaBaselineFunction baselineFunction) |
void |
setBorder(int spacingType,
float borderWidth) |
void |
setDefaultPadding(int spacingType,
float padding) |
void |
setDisplay(YogaDisplay display) |
void |
setFlex(float flex) |
void |
setFlexBasis(float flexBasis) |
void |
setFlexBasisAuto() |
void |
setFlexBasisPercent(float percent) |
void |
setFlexDirection(YogaFlexDirection flexDirection) |
void |
setFlexGrow(float flexGrow) |
void |
setFlexShrink(float flexShrink) |
void |
setFlexWrap(YogaWrap wrap) |
void |
setIsLayoutOnly(boolean isLayoutOnly)
Sets whether this node only contributes to the layout of its children without doing any drawing
or functionality itself.
|
void |
setJustifyContent(YogaJustify justifyContent) |
void |
setLayoutDirection(YogaDirection direction) |
void |
setLocalData(java.lang.Object data) |
void |
setMargin(int spacingType,
float margin) |
void |
setMarginAuto(int spacingType) |
void |
setMarginPercent(int spacingType,
float percent) |
void |
setMeasureFunction(YogaMeasureFunction measureFunction) |
void |
setOverflow(YogaOverflow overflow) |
void |
setPadding(int spacingType,
float padding) |
void |
setPaddingPercent(int spacingType,
float percent) |
void |
setPosition(int spacingType,
float position) |
void |
setPositionPercent(int spacingType,
float percent) |
void |
setPositionType(YogaPositionType positionType) |
void |
setReactTag(int reactTag) |
void |
setRootNode(T rootNode) |
void |
setShouldNotifyOnLayout(boolean shouldNotifyOnLayout) |
void |
setStyleAspectRatio(float aspectRatio) |
void |
setStyleHeight(float heightPx) |
void |
setStyleHeightAuto() |
void |
setStyleHeightPercent(float percent) |
void |
setStyleMaxHeight(float widthPx) |
void |
setStyleMaxHeightPercent(float percent) |
void |
setStyleMaxWidth(float widthPx) |
void |
setStyleMaxWidthPercent(float percent) |
void |
setStyleMinHeight(float widthPx) |
void |
setStyleMinHeightPercent(float percent) |
void |
setStyleMinWidth(float widthPx) |
void |
setStyleMinWidthPercent(float percent) |
void |
setStyleWidth(float widthPx) |
void |
setStyleWidthAuto() |
void |
setStyleWidthPercent(float percent) |
void |
setThemedContext(ThemedReactContext themedContext) |
void |
setViewClassName(java.lang.String viewClassName) |
boolean |
shouldNotifyOnLayout() |
void |
updateProperties(ReactStylesDiffMap props) |
boolean isVirtual()
true
will be treated as "virtual" nodes. That is, nodes that are not
mapped into native views (e.g. nested text node). By default this method returns false
.boolean isVirtualAnchor()
true
will be treated as a root view for the virtual nodes tree. It
means that NativeViewHierarchyManager
will not try to perform manageChildren
operation on such views. Good example is InputText
view that may have children Text
nodes but this whole hierarchy will be mapped to a single android EditText
view.boolean isYogaLeafNode()
true
will not manage (and and remove) child Yoga nodes. For example
ReactTextInputShadowNode
or ReactTextShadowNode
have child nodes, which do not
want Yoga to lay out, so in the eyes of Yoga it is a leaf node. Override this method in
subclass to enforce this requirement.T mutableCopy()
ReactShadowNode
T mutableCopyWithNewProps(@Nullable ReactStylesDiffMap newProps)
T mutableCopyWithNewChildren()
T mutableCopyWithNewChildrenAndProps(@Nullable ReactStylesDiffMap newProps)
java.lang.String getViewClass()
boolean hasUpdates()
void markUpdateSeen()
void markUpdated()
boolean hasUnseenUpdates()
void dirty()
boolean isDirty()
void addChildAt(T child, int i)
T removeChildAt(int i)
int getChildCount()
T getChildAt(int i)
int indexOf(T child)
void removeAndDisposeAllChildren()
@Nullable ReactStylesDiffMap getNewProps()
void onBeforeLayout()
UIManagerModule
once per batch, before calculating
layout. Will be only called for nodes that are marked as updated with markUpdated()
or
require layouting (marked with dirty()
).void updateProperties(ReactStylesDiffMap props)
void onAfterUpdateTransaction()
void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue)
UIManagerModule
. May be used
to enqueue additional ui operations for the native view. Will only be called on nodes marked as
updated either with dirty()
or markUpdated()
.uiViewOperationQueue
- interface for enqueueing UI operationsboolean dispatchUpdates(float absoluteX, float absoluteY, UIViewOperationQueue uiViewOperationQueue, NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer)
int getReactTag()
void setReactTag(int reactTag)
T getRootNode()
void setRootNode(T rootNode)
void setViewClassName(java.lang.String viewClassName)
@Nullable T getParent()
ThemedReactContext getThemedContext()
ThemedReactContext
associated with this ReactShadowNode
. This will
never change during the lifetime of a ReactShadowNode
instance, but different instances
can have different contexts; don't cache any calculations based on theme values globally.void setThemedContext(ThemedReactContext themedContext)
boolean shouldNotifyOnLayout()
void calculateLayout()
boolean hasNewLayout()
void markLayoutSeen()
void addNativeChildAt(T child, int nativeIndex)
T removeNativeChildAt(int i)
void removeAllNativeChildren()
int getNativeChildCount()
int indexOfNativeChild(T nativeChild)
@Nullable T getNativeParent()
void setIsLayoutOnly(boolean isLayoutOnly)
boolean isLayoutOnly()
int getTotalNativeChildren()
boolean isDescendantOf(T ancestorNode)
java.lang.String getHierarchyInfo()
String
representation of the Yoga hierarchy of this ReactShadowNode
void setLocalData(java.lang.Object data)
int getNativeOffsetForChild(T child)
Basically, a view might have children that have been optimized away by NativeViewHierarchyOptimizer
. Since those children will then add their native children to this
view, we now have ranges of native children that correspond to single unoptimized children. The
purpose of this method is to return the index within the native children that corresponds to
the **start** of the native children that belong to the given child. Also, note that all of the
children of a view might be optimized away, so this could return the same value for multiple
different children.
Example. Native children are represented by (N) where N is the no-opt child they came from. If no children are optimized away it'd look like this: (0) (1) (2) (3) ... (n)
In case some children are optimized away, it might look like this: (0) (1) (1) (1) (3) (3) (4)
In that case: getNativeOffsetForChild(Node 0) => 0 getNativeOffsetForChild(Node 1) => 1 getNativeOffsetForChild(Node 2) => 4 getNativeOffsetForChild(Node 3) => 4
getNativeOffsetForChild(Node 4) => 6
float getLayoutX()
float getLayoutY()
float getLayoutWidth()
float getLayoutHeight()
int getScreenX()
int getScreenY()
int getScreenWidth()
int getScreenHeight()
YogaDirection getLayoutDirection()
void setLayoutDirection(YogaDirection direction)
YogaValue getStyleWidth()
void setStyleWidth(float widthPx)
void setStyleWidthPercent(float percent)
void setStyleWidthAuto()
void setStyleMinWidth(float widthPx)
void setStyleMinWidthPercent(float percent)
void setStyleMaxWidth(float widthPx)
void setStyleMaxWidthPercent(float percent)
YogaValue getStyleHeight()
void setStyleHeight(float heightPx)
void setStyleHeightPercent(float percent)
void setStyleHeightAuto()
void setStyleMinHeight(float widthPx)
void setStyleMinHeightPercent(float percent)
void setStyleMaxHeight(float widthPx)
void setStyleMaxHeightPercent(float percent)
void setFlex(float flex)
void setFlexGrow(float flexGrow)
void setFlexShrink(float flexShrink)
void setFlexBasis(float flexBasis)
void setFlexBasisAuto()
void setFlexBasisPercent(float percent)
void setStyleAspectRatio(float aspectRatio)
void setFlexDirection(YogaFlexDirection flexDirection)
void setFlexWrap(YogaWrap wrap)
void setAlignSelf(YogaAlign alignSelf)
void setAlignItems(YogaAlign alignItems)
void setAlignContent(YogaAlign alignContent)
void setJustifyContent(YogaJustify justifyContent)
void setOverflow(YogaOverflow overflow)
void setDisplay(YogaDisplay display)
void setMargin(int spacingType, float margin)
void setMarginPercent(int spacingType, float percent)
void setMarginAuto(int spacingType)
float getPadding(int spacingType)
YogaValue getStylePadding(int spacingType)
void setDefaultPadding(int spacingType, float padding)
void setPadding(int spacingType, float padding)
void setPaddingPercent(int spacingType, float percent)
void setBorder(int spacingType, float borderWidth)
void setPosition(int spacingType, float position)
void setPositionPercent(int spacingType, float percent)
void setPositionType(YogaPositionType positionType)
void setShouldNotifyOnLayout(boolean shouldNotifyOnLayout)
void setBaselineFunction(YogaBaselineFunction baselineFunction)
void setMeasureFunction(YogaMeasureFunction measureFunction)
boolean isMeasureDefined()
void dispose()