mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Implement background in FlatShadowNode
Summary: @public Similar to a `DrawBorder` patch, this diff adds `DrawBackground` and implements `ViewProps.BACKGROUND_COLOR` property in `FlatShadowNode` with it. Reviewed By: sriramramani Differential Revision: D2564466
This commit is contained in:
1 parent
1c7f23c79d
commit
f19acaed4b
4 files changed
+70
-5
No files matched your search
@@ -9,7 +9,11 @@
|
||||
|
||||
package com.facebook.react.flat;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.facebook.react.uimanager.LayoutShadowNode;
|
||||
import com.facebook.react.uimanager.ReactProp;
|
||||
import com.facebook.react.uimanager.ViewProps;
|
||||
|
||||
/**
|
||||
* FlatShadowNode is a base class for all shadow node used in FlatUIImplementation. It extends
|
||||
@@ -17,6 +21,8 @@ import com.facebook.react.uimanager.LayoutShadowNode;
|
||||
*/
|
||||
/* package */ class FlatShadowNode extends LayoutShadowNode {
|
||||
|
||||
private @Nullable DrawBackgroundColor mDrawBackground;
|
||||
|
||||
/**
|
||||
* Collects DrawCommands produced by this FlatShadoNode.
|
||||
*/
|
||||
@@ -26,7 +32,20 @@ import com.facebook.react.uimanager.LayoutShadowNode;
|
||||
float top,
|
||||
float right,
|
||||
float bottom) {
|
||||
// do nothing yet.
|
||||
if (mDrawBackground != null) {
|
||||
mDrawBackground = (DrawBackgroundColor) mDrawBackground.updateBoundsAndFreeze(
|
||||
left,
|
||||
top,
|
||||
right,
|
||||
bottom);
|
||||
stateBuilder.addDrawCommand(mDrawBackground);
|
||||
}
|
||||
}
|
||||
|
||||
@ReactProp(name = ViewProps.BACKGROUND_COLOR)
|
||||
public void setBackgroundColor(int backgroundColor) {
|
||||
mDrawBackground = (backgroundColor == 0) ? null : new DrawBackgroundColor(backgroundColor);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user