Skip to content

Commit

Permalink
fix: Fix static view config validation for RNSVGSvgViewAndroid (#2274)
Browse files Browse the repository at this point in the history
# 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

<!-- Check completed item, when applicable, via: [X] -->

- [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 <jakub.grzywacz@swmansion.com>
  • Loading branch information
fabriziocucci and jakex7 authored May 15, 2024
1 parent 768466d commit 19b2e42
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
35 changes: 35 additions & 0 deletions android/src/main/java/com/horcrux/svg/SvgViewManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,11 @@ public interface RNSVGSvgViewAndroidManagerInterface<T extends View> {
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);
}
7 changes: 7 additions & 0 deletions src/fabric/AndroidSvgViewNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<NativeProps>('RNSVGSvgViewAndroid', {
Expand Down

0 comments on commit 19b2e42

Please sign in to comment.