Support borders in RCTImageView

Summary: @public Initial RCTImageView implementation only supported 'src', 'tintColor' and 'resizeMode'. This diff adds support for the rest of the properties: 'borderColor', 'borderWidth' and 'borderRadius'. `AbstractDrawBorders` class is reused in a follow up diff to draw borders for 'RCTView'.

Reviewed By: sriramramani

Differential Revision: D2693560
This commit is contained in:
Denis Koroskin
2015-12-12 14:48:34 -08:00
committed by Ahmed El-Helw
parent 760422525e
commit 71ca522c68
6 changed files with 239 additions and 5 deletions

View File

@@ -17,6 +17,7 @@ import android.net.Uri;
import com.facebook.drawee.drawable.ScalingUtils.ScaleType;
import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.ReactProp;
import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.views.image.ImageResizeMode;
@@ -102,6 +103,29 @@ import com.facebook.react.views.image.ImageResizeMode;
}
}
@ReactProp(name = "borderColor", customType = "Color")
public void setBorderColor(int borderColor) {
if (mDrawImage.getBorderColor() != borderColor) {
getMutableDrawImage().setBorderColor(borderColor);
}
}
@ReactProp(name = "borderWidth")
public void setBorderWidth(float borderWidth) {
borderWidth = PixelUtil.toPixelFromDIP(borderWidth);
if (mDrawImage.getBorderWidth() != borderWidth) {
getMutableDrawImage().setBorderWidth(borderWidth);
}
}
@ReactProp(name = "borderRadius")
public void setBorderRadius(float borderRadius) {
if (mDrawImage.getBorderRadius() != borderRadius) {
getMutableDrawImage().setBorderRadius(PixelUtil.toPixelFromDIP(borderRadius));
}
}
private T getMutableDrawImage() {
if (mDrawImage.isFrozen()) {
mDrawImage = (T) mDrawImage.mutableCopy();