Rename start & end properties to fix conflict with RN 51

A recent commit in RN added start/end properties to RCTViewManager.
Because LinearGradient inherits from this class and has properties of
the same name, RN gets mixed up and tries to convert to a YGValue
instead of CGPoint, which results in the exception:

```
Error setting property 'start' of BVLinearGradient with tag #18: JSON
value '{
    x = 0;
    y = 0;
}' of type NSMutableDictionary cannot be converted to a YGValue.
```
This commit is contained in:
Sam Mueller 2017-11-15 23:31:10 -08:00
parent 76fccfa7ea
commit a77528523e
5 changed files with 12 additions and 12 deletions

View File

@ -24,14 +24,14 @@
self.gradientLayer.colors = colors; self.gradientLayer.colors = colors;
} }
- (void)setStart:(CGPoint)start - (void)setStartPoint:(CGPoint)startPoint
{ {
self.gradientLayer.startPoint = start; self.gradientLayer.startPoint = startPoint;
} }
- (void)setEnd:(CGPoint)end - (void)setEndPoint:(CGPoint)endPoint
{ {
self.gradientLayer.endPoint = end; self.gradientLayer.endPoint = endPoint;
} }
- (void)setLocations:(NSArray *)locations - (void)setLocations:(NSArray *)locations

View File

@ -19,8 +19,8 @@ RCT_EXPORT_MODULE();
} }
RCT_EXPORT_VIEW_PROPERTY(colors, NSArray); RCT_EXPORT_VIEW_PROPERTY(colors, NSArray);
RCT_EXPORT_VIEW_PROPERTY(start, CGPoint); RCT_EXPORT_VIEW_PROPERTY(startPoint, CGPoint);
RCT_EXPORT_VIEW_PROPERTY(end, CGPoint); RCT_EXPORT_VIEW_PROPERTY(endPoint, CGPoint);
RCT_EXPORT_VIEW_PROPERTY(locations, NSArray); RCT_EXPORT_VIEW_PROPERTY(locations, NSArray);
@end @end

View File

@ -13,8 +13,8 @@ public class LinearGradientManager extends SimpleViewManager<LinearGradientView>
public static final String REACT_CLASS = "BVLinearGradient"; public static final String REACT_CLASS = "BVLinearGradient";
public static final String PROP_COLORS = "colors"; public static final String PROP_COLORS = "colors";
public static final String PROP_LOCATIONS = "locations"; public static final String PROP_LOCATIONS = "locations";
public static final String PROP_START_POS = "start"; public static final String PROP_START_POS = "startPoint";
public static final String PROP_END_POS = "end"; public static final String PROP_END_POS = "endPoint";
public static final String PROP_BORDER_RADII = "borderRadii"; public static final String PROP_BORDER_RADII = "borderRadii";
@Override @Override

View File

@ -89,8 +89,8 @@ export default class LinearGradient extends Component {
<NativeLinearGradient <NativeLinearGradient
style={{position: 'absolute', top: 0, left: 0, bottom: 0, right: 0}} style={{position: 'absolute', top: 0, left: 0, bottom: 0, right: 0}}
colors={colors.map(processColor)} colors={colors.map(processColor)}
start={convertPoint('start', start)} startPoint={convertPoint('start', start)}
end={convertPoint('end', end)} endPoint={convertPoint('end', end)}
locations={locations ? locations.slice(0, colors.length) : null} locations={locations ? locations.slice(0, colors.length) : null}
borderRadii={borderRadiiPerCorner} borderRadii={borderRadiiPerCorner}
/> />

View File

@ -72,8 +72,8 @@ export default class LinearGradient extends Component {
<NativeLinearGradient <NativeLinearGradient
ref={(component) => { this.gradientRef = component; }} ref={(component) => { this.gradientRef = component; }}
{...otherProps} {...otherProps}
start={convertPoint('start', start)} startPoint={convertPoint('start', start)}
end={convertPoint('end', end)} endPoint={convertPoint('end', end)}
colors={colors.map(processColor)} colors={colors.map(processColor)}
locations={locations ? locations.slice(0, colors.length) : null} locations={locations ? locations.slice(0, colors.length) : null}
/> />