mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-07 00:42:31 +00:00
Alternative approach without TextureView.
This commit is contained in:
@@ -16,8 +16,8 @@
|
||||
@property (nonatomic, assign) id src;
|
||||
@property (nonatomic, strong) NSString* x;
|
||||
@property (nonatomic, strong) NSString* y;
|
||||
@property (nonatomic, strong) NSString* width;
|
||||
@property (nonatomic, strong) NSString* height;
|
||||
@property (nonatomic, strong) NSString* imagewidth;
|
||||
@property (nonatomic, strong) NSString* imageheight;
|
||||
@property (nonatomic, strong) NSString *align;
|
||||
@property (nonatomic, assign) RNSVGVBMOS meetOrSlice;
|
||||
|
||||
|
||||
@@ -53,22 +53,22 @@
|
||||
_y = y;
|
||||
}
|
||||
|
||||
- (void)setWidth:(NSString *)width
|
||||
- (void)setImagewidth:(NSString *)width
|
||||
{
|
||||
if (width == _width) {
|
||||
if (width == _imagewidth) {
|
||||
return;
|
||||
}
|
||||
[self invalidate];
|
||||
_width = width;
|
||||
_imagewidth = width;
|
||||
}
|
||||
|
||||
- (void)setHeight:(NSString *)height
|
||||
- (void)setImageheight:(NSString *)height
|
||||
{
|
||||
if (height == _height) {
|
||||
if (height == _imageheight) {
|
||||
return;
|
||||
}
|
||||
[self invalidate];
|
||||
_height = height;
|
||||
_imageheight = height;
|
||||
}
|
||||
|
||||
- (void)setAlign:(NSString *)align
|
||||
@@ -121,8 +121,8 @@
|
||||
{
|
||||
CGFloat x = [self relativeOnWidth:self.x];
|
||||
CGFloat y = [self relativeOnHeight:self.y];
|
||||
CGFloat width = [self relativeOnWidth:self.width];
|
||||
CGFloat height = [self relativeOnHeight:self.height];
|
||||
CGFloat width = [self relativeOnWidth:self.imagewidth];
|
||||
CGFloat height = [self relativeOnHeight:self.imageheight];
|
||||
if (width == 0) {
|
||||
width = _imageSize.width;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,6 @@
|
||||
@interface RNSVGUse : RNSVGRenderable
|
||||
|
||||
@property (nonatomic, strong) NSString *href;
|
||||
@property (nonatomic, strong) NSString *width;
|
||||
@property (nonatomic, strong) NSString *height;
|
||||
@property (nonatomic, strong) NSString *usewidth;
|
||||
@property (nonatomic, strong) NSString *useheight;
|
||||
@end
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
if (href == _href) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
[self invalidate];
|
||||
_href = href;
|
||||
}
|
||||
@@ -28,22 +28,22 @@
|
||||
if (template) {
|
||||
[self beginTransparencyLayer:context];
|
||||
[self clip:context];
|
||||
|
||||
|
||||
if ([template isKindOfClass:[RNSVGRenderable class]]) {
|
||||
[(RNSVGRenderable*)template mergeProperties:self];
|
||||
}
|
||||
|
||||
if ([template class] == [RNSVGSymbol class]) {
|
||||
RNSVGSymbol *symbol = (RNSVGSymbol*)template;
|
||||
[symbol renderSymbolTo:context width:[self relativeOnWidth:self.width] height:[self relativeOnWidth:self.height]];
|
||||
[symbol renderSymbolTo:context width:[self relativeOnWidth:self.usewidth] height:[self relativeOnHeight:self.useheight]];
|
||||
} else {
|
||||
[template renderTo:context rect:rect];
|
||||
}
|
||||
|
||||
|
||||
if ([template isKindOfClass:[RNSVGRenderable class]]) {
|
||||
[(RNSVGRenderable*)template resetProperties];
|
||||
}
|
||||
|
||||
|
||||
[self endTransparencyLayer:context];
|
||||
} else if (self.href) {
|
||||
// TODO: calling yellow box here
|
||||
|
||||
@@ -22,8 +22,8 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
RCT_EXPORT_VIEW_PROPERTY(x, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(y, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(width, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(height, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(imagewidth, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(imageheight, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(src, id)
|
||||
RCT_EXPORT_VIEW_PROPERTY(align, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(meetOrSlice, RNSVGVBMOS)
|
||||
|
||||
@@ -19,7 +19,7 @@ RCT_EXPORT_MODULE()
|
||||
}
|
||||
|
||||
RCT_EXPORT_VIEW_PROPERTY(href, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(width, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(height, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(usewidth, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(useheight, NSString)
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user