From 19b2e42e1b3ef26ab537cac5164392ac04641ab9 Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Wed, 15 May 2024 10:13:01 +0100 Subject: [PATCH] fix: Fix static view config validation for RNSVGSvgViewAndroid (#2274) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Summary As per title, when running an app in bridgless mode the following redbox appears: > StaticViewConfigValidator: Invalid static view config for 'RNSVGSvgViewAndroid'. > > 'validAttributes.borderBlockColor' is missing. > 'validAttributes.borderBlockEndColor' is missing. > 'validAttributes.borderBlockStartColor' is missing. > 'validAttributes.borderEndEndRadius' is missing. > 'validAttributes.borderEndStartRadius' is missing. > 'validAttributes.borderStartEndRadius' is missing. > 'validAttributes.borderStartStartRadius' is missing. ## Test Plan Tested that the redbox is gone. ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | N/A | | Android | ✅ | ## Checklist - [X] I have tested this on a device and a simulator - [ ] I added documentation in `README.md` - [ ] I updated the typed files (typescript) - [ ] I added a test for the API in the `__tests__` folder --------- Co-authored-by: Jakub Grzywacz --- .../java/com/horcrux/svg/SvgViewManager.java | 35 +++++++++++++++++++ .../RNSVGSvgViewAndroidManagerDelegate.java | 21 +++++++++++ .../RNSVGSvgViewAndroidManagerInterface.java | 7 ++++ src/fabric/AndroidSvgViewNativeComponent.ts | 7 ++++ 4 files changed, 70 insertions(+) diff --git a/android/src/main/java/com/horcrux/svg/SvgViewManager.java b/android/src/main/java/com/horcrux/svg/SvgViewManager.java index 71a88e625..4a8452f52 100644 --- a/android/src/main/java/com/horcrux/svg/SvgViewManager.java +++ b/android/src/main/java/com/horcrux/svg/SvgViewManager.java @@ -316,6 +316,21 @@ public void setNextFocusLeft(SvgView view, int value) { super.nextFocusLeft(view, value); } + @Override + public void setBorderBlockColor(SvgView view, @Nullable Integer value) { + super.setBorderColor(view, 9, value); + } + + @Override + public void setBorderBlockEndColor(SvgView view, @Nullable Integer value) { + super.setBorderColor(view, 10, value); + } + + @Override + public void setBorderBlockStartColor(SvgView view, @Nullable Integer value) { + super.setBorderColor(view, 11, value); + } + @Override public void setBorderRadius(SvgView view, double value) { super.setBorderRadius(view, 0, (float) value); @@ -340,4 +355,24 @@ public void setBorderBottomRightRadius(SvgView view, double value) { public void setBorderBottomLeftRadius(SvgView view, double value) { super.setBorderRadius(view, 4, (float) value); } + + @Override + public void setBorderEndEndRadius(SvgView view, double value) { + super.setBorderRadius(view, 9, (float) value); + } + + @Override + public void setBorderEndStartRadius(SvgView view, double value) { + super.setBorderRadius(view, 10, (float) value); + } + + @Override + public void setBorderStartEndRadius(SvgView view, double value) { + super.setBorderRadius(view, 11, (float) value); + } + + @Override + public void setBorderStartStartRadius(SvgView view, double value) { + super.setBorderRadius(view, 12, (float) value); + } } diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGSvgViewAndroidManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGSvgViewAndroidManagerDelegate.java index 7e4e61ab5..376fbd60c 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGSvgViewAndroidManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGSvgViewAndroidManagerDelegate.java @@ -150,6 +150,27 @@ public void setProperty(T view, String propName, @Nullable Object value) { case "borderTopLeftRadius": mViewManager.setBorderTopLeftRadius(view, value == null ? 0f : ((Double) value).doubleValue()); break; + case "borderBlockColor": + mViewManager.setBorderBlockColor(view, ColorPropConverter.getColor(value, view.getContext())); + break; + case "borderBlockEndColor": + mViewManager.setBorderBlockEndColor(view, ColorPropConverter.getColor(value, view.getContext())); + break; + case "borderBlockStartColor": + mViewManager.setBorderBlockStartColor(view, ColorPropConverter.getColor(value, view.getContext())); + break; + case "borderEndEndRadius": + mViewManager.setBorderEndEndRadius(view, value == null ? 0f : ((Double) value).doubleValue()); + break; + case "borderEndStartRadius": + mViewManager.setBorderEndStartRadius(view, value == null ? 0f : ((Double) value).doubleValue()); + break; + case "borderStartEndRadius": + mViewManager.setBorderStartEndRadius(view, value == null ? 0f : ((Double) value).doubleValue()); + break; + case "borderStartStartRadius": + mViewManager.setBorderStartStartRadius(view, value == null ? 0f : ((Double) value).doubleValue()); + break; default: super.setProperty(view, propName, value); } diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGSvgViewAndroidManagerInterface.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGSvgViewAndroidManagerInterface.java index d89d9ef46..4214009b7 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGSvgViewAndroidManagerInterface.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGSvgViewAndroidManagerInterface.java @@ -57,4 +57,11 @@ public interface RNSVGSvgViewAndroidManagerInterface { void setBorderRadius(T view, double value); void setBorderBottomLeftRadius(T view, double value); void setBorderTopLeftRadius(T view, double value); + void setBorderBlockColor(T view, @Nullable Integer value); + void setBorderBlockEndColor(T view, @Nullable Integer value); + void setBorderBlockStartColor(T view, @Nullable Integer value); + void setBorderEndEndRadius(T view, double value); + void setBorderEndStartRadius(T view, double value); + void setBorderStartEndRadius(T view, double value); + void setBorderStartStartRadius(T view, double value); } diff --git a/src/fabric/AndroidSvgViewNativeComponent.ts b/src/fabric/AndroidSvgViewNativeComponent.ts index 56eac79e7..bf654d6d7 100644 --- a/src/fabric/AndroidSvgViewNativeComponent.ts +++ b/src/fabric/AndroidSvgViewNativeComponent.ts @@ -73,6 +73,13 @@ interface NativeProps extends ViewProps { borderRadius?: Double; borderBottomLeftRadius?: Double; borderTopLeftRadius?: Double; + borderBlockColor?: ColorValue; + borderBlockEndColor?: ColorValue; + borderBlockStartColor?: ColorValue; + borderEndEndRadius?: Double; + borderEndStartRadius?: Double; + borderStartEndRadius?: Double; + borderStartStartRadius?: Double; } export default codegenNativeComponent('RNSVGSvgViewAndroid', {