mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-02 06:45:02 +08:00
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:
committed by
Ahmed El-Helw
parent
760422525e
commit
71ca522c68
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user