Commit 5d898940 authored by Qiu Xiang's avatar Qiu Xiang

移除 Polyline opacity 接口

parent d68cec5a
......@@ -25,12 +25,6 @@ class AMapPolyline(context: ThemedReactContext) : ReactViewGroup(context) {
polyline?.color = value
}
var opacity: Float = 1f
set(value) {
field = value
polyline?.setTransparency(value)
}
var zIndex: Float = 0f
set(value) {
field = value
......@@ -75,7 +69,6 @@ class AMapPolyline(context: ThemedReactContext) : ReactViewGroup(context) {
.useGradient(gradient)
.geodesic(geodesic)
.setDottedLine(dashed)
.transparency(opacity)
.zIndex(zIndex))
}
}
......@@ -44,11 +44,6 @@ internal class AMapPolylineManager : ViewGroupManager<AMapPolyline>() {
polyline.zIndex = zIndex
}
@ReactProp(name = "opacity")
override fun setOpacity(polyline: AMapPolyline, opacity: Float) {
polyline.opacity = opacity
}
@ReactProp(name = "geodesic")
fun setGeodesic(polyline: AMapPolyline, geodesic: Boolean) {
polyline.geodesic = geodesic
......
......@@ -10,7 +10,6 @@ class Polyline extends Component {
width: PropTypes.number,
color: PropTypes.string,
zIndex: PropTypes.number,
opacity: PropTypes.number,
/**
* 多段颜色
......@@ -59,9 +58,9 @@ class Polyline extends Component {
...Platform.select({
android: {
width: PixelRatio.getPixelSizeForLayoutSize(this.props.width),
colors: this.props.colors.map(processColor),
},
}),
colors: this.props.colors.map(processColor),
onPolylineClick: this._handle('onPress'),
}
return <AMapPolyline {...props}/>
......
......@@ -6,20 +6,19 @@
@implementation AMapPolyline {
MAMultiPolyline *_polyline;
MAMultiColoredPolylineRenderer *_renderer;
CGFloat _width;
UIColor *_color;
NSArray *_colors;
CGFloat _opacity;
BOOL _dashed;
BOOL _gradient;
}
- (instancetype)init {
if (self = [super init]) {
_polyline = [MAMultiPolyline polylineWithCoordinates:NULL count:0 drawStyleIndexes:NULL];
_polyline = [MAMultiPolyline polylineWithCoordinates:nil count:0 drawStyleIndexes:nil];
}
return self;
}
......@@ -28,7 +27,7 @@
for (NSUInteger i = 0; i < coordinates.count; i++) {
coords[i] = coordinates[i].coordinate;
}
[_polyline setPolylineWithCoordinates:coords count:coordinates.count];
}
......@@ -37,44 +36,38 @@
_renderer.lineWidth = width;
}
- (void)setOpacity:(CGFloat)opacity {
opacity = MAX(0.01, opacity); // 线段最低的opacity是0.01不能再小了,否则干掉多好。Android系统上默认为此逻辑。
_opacity = opacity;
_renderer.alpha = opacity;
}
- (void)setColor:(UIColor *)color {
_color = color;
_renderer.strokeColor = color;
}
- (void)setColors:(NSArray *)colors {
// process colors -> strokeColor |egg: [black, black, black, white, white, black] => [black, white, black] + [3, 5]|
// colors -> strokeColors
// egg: [black, black, black, white, white, black] => [black, white, black] + [3, 5]
NSMutableArray *strokeColors = [[NSMutableArray alloc] init];
NSMutableArray *indexs = [[NSMutableArray alloc] init];
if (colors.count > 0) {
UIColor *lastColor = [colors firstObject];
[strokeColors addObject:lastColor];
for (NSUInteger index = 1; index < colors.count; index++) {
UIColor *color = colors[index];
if (![color isEqual:lastColor]) {
[strokeColors addObject:color];
[indexs addObject:@(index)]; // index is the NEXT color
lastColor = color;
}
}
if (strokeColors.count == 1) {
[indexs addObject:@(colors.count)];
}
}
_colors = strokeColors;
_renderer.strokeColors = strokeColors;
// change polyline
[_polyline setDrawStyleIndexes:@[@(1), @(2)]];
}
......@@ -101,12 +94,11 @@
if (_color == nil) {
_color = UIColor.blackColor;
}
_renderer = [[MAMultiColoredPolylineRenderer alloc] initWithMultiPolyline:_polyline];
_renderer.lineWidth = _width;
_renderer.strokeColor = _color;
_renderer.strokeColors = _colors;
_renderer.alpha = _opacity;
_renderer.lineDash = _dashed;
_renderer.gradient = _gradient;
return _renderer;
......
......@@ -18,7 +18,6 @@ RCT_EXPORT_MODULE()
RCT_EXPORT_VIEW_PROPERTY(coordinates, CoordinateArray)
RCT_EXPORT_VIEW_PROPERTY(width, CGFloat)
RCT_EXPORT_VIEW_PROPERTY(opacity, CGFloat)
RCT_EXPORT_VIEW_PROPERTY(color, UIColor)
RCT_EXPORT_VIEW_PROPERTY(dashed, BOOL)
RCT_EXPORT_VIEW_PROPERTY(gradient, BOOL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment