From b8b4fb8a746569ba1a4b456f7c20f55c3f6116b6 Mon Sep 17 00:00:00 2001 From: Denis Koroskin Date: Sun, 13 Dec 2015 18:58:25 -0800 Subject: [PATCH] Apply base View properties (scale, alpha etc) to FlatShadowNode when it maps to a View Summary: @public There are some properties that we want to handle on a View level, as opposed to a FlatShadowNode level. For example, scale or alpha, that can be done very efficiently in hardware. Once we pop FlatShadowNode to a separate View, we need to apply these properties. This is where `BaseViewManager` comes in handy. Reviewed By: sriramramani Differential Revision: D2694290 --- .../facebook/react/flat/FlatUIImplementation.java | 12 ++++++++++-- .../com/facebook/react/flat/FlatViewManager.java | 9 +++++++-- .../java/com/facebook/react/flat/StateBuilder.java | 4 ++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java index 605aacadf..e64dfc771 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java @@ -80,7 +80,11 @@ public class FlatUIImplementation extends UIImplementation { ReactShadowNode cssNode, int rootViewTag, CatalystStylesDiffMap styles) { - // nothing to do yet. + int tag = cssNode.getReactTag(); + FlatShadowNode node = (FlatShadowNode) cssNode; + if (node.mountsToView()) { + mStateBuilder.ensureBackingViewIsCreated(node, tag, styles); + } } @Override @@ -88,7 +92,11 @@ public class FlatUIImplementation extends UIImplementation { ReactShadowNode cssNode, String className, CatalystStylesDiffMap styles) { - // nothing to do yet. + int tag = cssNode.getReactTag(); + FlatShadowNode node = (FlatShadowNode) cssNode; + if (node.mountsToView()) { + mStateBuilder.ensureBackingViewIsCreated(node, tag, styles); + } } @Override diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewManager.java index d055d93f5..ab92cf740 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewManager.java @@ -10,15 +10,20 @@ package com.facebook.react.flat; import com.facebook.react.uimanager.ThemedReactContext; -import com.facebook.react.uimanager.ViewManager; +import com.facebook.react.uimanager.BaseViewManager; -abstract class FlatViewManager extends ViewManager { +abstract class FlatViewManager extends BaseViewManager { @Override protected FlatViewGroup createViewInstance(ThemedReactContext reactContext) { return new FlatViewGroup(reactContext); } + @Override + public void setBackgroundColor(FlatViewGroup view, int backgroundColor) { + // suppress + } + @Override public void updateExtraData(FlatViewGroup root, Object extraData) { } diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java b/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java index c3b48b8cc..791768cf4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java @@ -88,6 +88,10 @@ import com.facebook.react.uimanager.CatalystStylesDiffMap; int tag, @Nullable CatalystStylesDiffMap styles) { if (node.isBackingViewCreated()) { + if (styles != null) { + // if the View is already created, make sure propagate new styles. + mOperationsQueue.enqueueUpdateProperties(tag, node.getViewClass(), styles); + } return; }