Skip to content

Commit

Permalink
Add boxShadow support to BaseViewManager (facebook#46936)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#46936

Let's enable box-shadow everywhere! This should be safe, now that we assume any background mutating methods in BaseViewManager go through BackgroundStyleApplicator. `boxShadow` is also already in `BaseViewConfig` instead of configs for each native component (bc we were already planning to make this change).

Changelog:
[Android][Added] - Add boxShadow support to BaseViewManager

Reviewed By: mdvacca

Differential Revision: D64140841

fbshipit-source-id: e937a4bcaa4506fd25d0916633313083c7e49333
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Oct 11, 2024
1 parent 6741fd9 commit b69a92e
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 37 deletions.
7 changes: 1 addition & 6 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -4154,6 +4154,7 @@ public abstract class com/facebook/react/uimanager/BaseViewManager : com/faceboo
public fun setBorderRadius (Landroid/view/View;F)V
public fun setBorderTopLeftRadius (Landroid/view/View;F)V
public fun setBorderTopRightRadius (Landroid/view/View;F)V
public fun setBoxShadow (Landroid/view/View;Lcom/facebook/react/bridge/ReadableArray;)V
public fun setClick (Landroid/view/View;Z)V
public fun setClickCapture (Landroid/view/View;Z)V
public fun setElevation (Landroid/view/View;F)V
Expand Down Expand Up @@ -6666,7 +6667,6 @@ public final class com/facebook/react/views/image/ReactImageManager : com/facebo
public final fun setBorderColor (Lcom/facebook/react/views/image/ReactImageView;Ljava/lang/Integer;)V
public final fun setBorderRadius (Lcom/facebook/react/views/image/ReactImageView;IF)V
public final fun setBorderWidth (Lcom/facebook/react/views/image/ReactImageView;F)V
public final fun setBoxShadow (Lcom/facebook/react/views/image/ReactImageView;Lcom/facebook/react/bridge/ReadableArray;)V
public final fun setDefaultSource (Lcom/facebook/react/views/image/ReactImageView;Ljava/lang/String;)V
public final fun setFadeDuration (Lcom/facebook/react/views/image/ReactImageView;I)V
public final fun setHeaders (Lcom/facebook/react/views/image/ReactImageView;Lcom/facebook/react/bridge/ReadableMap;)V
Expand Down Expand Up @@ -7092,7 +7092,6 @@ public class com/facebook/react/views/scroll/ReactHorizontalScrollViewManager :
public fun setBorderStyle (Lcom/facebook/react/views/scroll/ReactHorizontalScrollView;Ljava/lang/String;)V
public fun setBorderWidth (Lcom/facebook/react/views/scroll/ReactHorizontalScrollView;IF)V
public fun setBottomFillColor (Lcom/facebook/react/views/scroll/ReactHorizontalScrollView;I)V
public fun setBoxShadow (Lcom/facebook/react/views/scroll/ReactHorizontalScrollView;Lcom/facebook/react/bridge/ReadableArray;)V
public fun setContentOffset (Lcom/facebook/react/views/scroll/ReactHorizontalScrollView;Lcom/facebook/react/bridge/ReadableMap;)V
public fun setDecelerationRate (Lcom/facebook/react/views/scroll/ReactHorizontalScrollView;F)V
public fun setDisableIntervalMomentum (Lcom/facebook/react/views/scroll/ReactHorizontalScrollView;Z)V
Expand Down Expand Up @@ -7333,7 +7332,6 @@ public class com/facebook/react/views/scroll/ReactScrollViewManager : com/facebo
public fun setBorderStyle (Lcom/facebook/react/views/scroll/ReactScrollView;Ljava/lang/String;)V
public fun setBorderWidth (Lcom/facebook/react/views/scroll/ReactScrollView;IF)V
public fun setBottomFillColor (Lcom/facebook/react/views/scroll/ReactScrollView;I)V
public fun setBoxShadow (Lcom/facebook/react/views/scroll/ReactScrollView;Lcom/facebook/react/bridge/ReadableArray;)V
public fun setContentOffset (Lcom/facebook/react/views/scroll/ReactScrollView;Lcom/facebook/react/bridge/ReadableMap;)V
public fun setDecelerationRate (Lcom/facebook/react/views/scroll/ReactScrollView;F)V
public fun setDisableIntervalMomentum (Lcom/facebook/react/views/scroll/ReactScrollView;Z)V
Expand Down Expand Up @@ -7633,7 +7631,6 @@ public abstract class com/facebook/react/views/text/ReactTextAnchorViewManager :
public fun setBorderRadius (Lcom/facebook/react/views/text/ReactTextView;IF)V
public fun setBorderStyle (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/String;)V
public fun setBorderWidth (Lcom/facebook/react/views/text/ReactTextView;IF)V
public fun setBoxShadow (Lcom/facebook/react/views/text/ReactTextView;Lcom/facebook/react/bridge/ReadableArray;)V
public fun setDataDetectorType (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/String;)V
public fun setDisabled (Lcom/facebook/react/views/text/ReactTextView;Z)V
public fun setEllipsizeMode (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/String;)V
Expand Down Expand Up @@ -8116,7 +8113,6 @@ public class com/facebook/react/views/textinput/ReactTextInputManager : com/face
public fun setBorderRadius (Lcom/facebook/react/views/textinput/ReactEditText;IF)V
public fun setBorderStyle (Lcom/facebook/react/views/textinput/ReactEditText;Ljava/lang/String;)V
public fun setBorderWidth (Lcom/facebook/react/views/textinput/ReactEditText;IF)V
public fun setBoxShadow (Lcom/facebook/react/views/textinput/ReactEditText;Lcom/facebook/react/bridge/ReadableArray;)V
public fun setCaretHidden (Lcom/facebook/react/views/textinput/ReactEditText;Z)V
public fun setColor (Lcom/facebook/react/views/textinput/ReactEditText;Ljava/lang/Integer;)V
public fun setContextMenuHidden (Lcom/facebook/react/views/textinput/ReactEditText;Z)V
Expand Down Expand Up @@ -8323,7 +8319,6 @@ public class com/facebook/react/views/view/ReactViewManager : com/facebook/react
public fun setBorderRadius (Lcom/facebook/react/views/view/ReactViewGroup;ILcom/facebook/react/bridge/Dynamic;)V
public fun setBorderStyle (Lcom/facebook/react/views/view/ReactViewGroup;Ljava/lang/String;)V
public fun setBorderWidth (Lcom/facebook/react/views/view/ReactViewGroup;IF)V
public fun setBoxShadow (Lcom/facebook/react/views/view/ReactViewGroup;Lcom/facebook/react/bridge/ReadableArray;)V
public fun setCollapsable (Lcom/facebook/react/views/view/ReactViewGroup;Z)V
public fun setCollapsableChildren (Lcom/facebook/react/views/view/ReactViewGroup;Z)V
public fun setFocusable (Lcom/facebook/react/views/view/ReactViewGroup;Z)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,11 @@ public void setOutlineWidth(T view, float width) {
BackgroundStyleApplicator.setOutlineWidth(view, width);
}

@ReactProp(name = ViewProps.BOX_SHADOW, customType = "BoxShadow")
public void setBoxShadow(T view, @Nullable ReadableArray shadows) {
BackgroundStyleApplicator.setBoxShadow(view, shadows);
}

private void logUnsupportedPropertyWarning(String propName) {
FLog.w(ReactConstants.TAG, "%s doesn't support property '%s'", getName(), propName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public abstract class BaseViewManagerDelegate<
mViewManager.setBorderTopRightRadius(
view, (value as Double?)?.toFloat() ?: YogaConstants.UNDEFINED)

ViewProps.BOX_SHADOW -> mViewManager.setBoxShadow(view, value as ReadableArray?)

ViewProps.ELEVATION -> mViewManager.setElevation(view, (value as Double?)?.toFloat() ?: 0.0f)

ViewProps.FILTER -> mViewManager.setFilter(view, value as ReadableArray?)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,6 @@ public constructor(
}
}

@ReactProp(name = ViewProps.BOX_SHADOW, customType = "BoxShadow")
public fun setBoxShadow(view: ReactImageView, shadows: ReadableArray?): Unit {
BackgroundStyleApplicator.setBoxShadow(view, shadows)
}

public override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> =
(super.getExportedCustomDirectEventTypeConstants() ?: mutableMapOf<String, Any>()).apply {
put(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,4 @@ public void setScrollEventThrottle(ReactHorizontalScrollView view, int scrollEve
public void setHorizontal(ReactHorizontalScrollView view, boolean horizontal) {
// Do Nothing: Align with static ViewConfigs
}

@ReactProp(name = ViewProps.BOX_SHADOW, customType = "BoxShadow")
public void setBoxShadow(ReactHorizontalScrollView view, @Nullable ReadableArray shadows) {
BackgroundStyleApplicator.setBoxShadow(view, shadows);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,6 @@ public void setMaintainVisibleContentPosition(ReactScrollView view, ReadableMap
}
}

@ReactProp(name = ViewProps.BOX_SHADOW, customType = "BoxShadow")
public void setBoxShadow(ReactScrollView view, @Nullable ReadableArray shadows) {
BackgroundStyleApplicator.setBoxShadow(view, shadows);
}

@Override
public @Nullable Object updateState(
ReactScrollView view, ReactStylesDiffMap props, StateWrapper stateWrapper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.common.logging.FLog;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.uimanager.BackgroundStyleApplicator;
import com.facebook.react.uimanager.BaseViewManager;
Expand Down Expand Up @@ -231,9 +230,4 @@ public void setDataDetectorType(ReactTextView view, @Nullable String type) {
public void setNotifyOnInlineViewLayout(ReactTextView view, boolean notifyOnInlineViewLayout) {
view.setNotifyOnInlineViewLayout(notifyOnInlineViewLayout);
}

@ReactProp(name = ViewProps.BOX_SHADOW, customType = "BoxShadow")
public void setBoxShadow(ReactTextView view, @Nullable ReadableArray shadows) {
BackgroundStyleApplicator.setBoxShadow(view, shadows);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1029,11 +1029,6 @@ public void setOverflow(ReactEditText view, @Nullable String overflow) {
view.setOverflow(overflow);
}

@ReactProp(name = ViewProps.BOX_SHADOW, customType = "BoxShadow")
public void setBoxShadow(ReactEditText view, @Nullable ReadableArray shadows) {
BackgroundStyleApplicator.setBoxShadow(view, shadows);
}

@Override
protected void onAfterUpdateTransaction(ReactEditText view) {
super.onAfterUpdateTransaction(view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,6 @@ protected void setTransformProperty(
view.setBackfaceVisibilityDependantOpacity();
}

@ReactProp(name = ViewProps.BOX_SHADOW, customType = "BoxShadow")
public void setBoxShadow(ReactViewGroup view, @Nullable ReadableArray shadows) {
BackgroundStyleApplicator.setBoxShadow(view, shadows);
}

@Override
public String getName() {
return REACT_CLASS;
Expand Down

0 comments on commit b69a92e

Please sign in to comment.