diff --git a/Example/android/app/src/main/java/com/artsvgexample/MainActivity.java b/Example/android/app/src/main/java/com/artsvgexample/MainActivity.java index 46fe2400..fa9fab7e 100644 --- a/Example/android/app/src/main/java/com/artsvgexample/MainActivity.java +++ b/Example/android/app/src/main/java/com/artsvgexample/MainActivity.java @@ -10,6 +10,6 @@ public class MainActivity extends ReactActivity { */ @Override protected String getMainComponentName() { - return "ArtSvgExample"; + return "SvgExample"; } } diff --git a/Example/android/app/src/main/res/values/strings.xml b/Example/android/app/src/main/res/values/strings.xml index 543e99c3..3386d8e0 100644 --- a/Example/android/app/src/main/res/values/strings.xml +++ b/Example/android/app/src/main/res/values/strings.xml @@ -1,3 +1,3 @@ - ArtSvgExample + SvgExample diff --git a/Example/android/settings.gradle b/Example/android/settings.gradle index 32b3fe2a..64cc4dc1 100644 --- a/Example/android/settings.gradle +++ b/Example/android/settings.gradle @@ -1,4 +1,4 @@ -rootProject.name = 'ArtSvgExample' +rootProject.name = 'SvgExample' include ':app' include ':react-native-svg' diff --git a/elements/Defs.js b/elements/Defs.js index d18bb699..06810d31 100644 --- a/elements/Defs.js +++ b/elements/Defs.js @@ -7,13 +7,13 @@ class Defs extends Component { static displayName = 'Defs'; render() { - return {this.props.children}; + return {this.props.children}; } } -const RNSVGDefination = createReactNativeComponentClass({ +const RNSVGDefs = createReactNativeComponentClass({ validAttributes: {}, - uiViewClassName: 'RNSVGDefination' + uiViewClassName: 'RNSVGDefs' }); export default Defs; diff --git a/elements/Image.js b/elements/Image.js index fed205fd..069b1ad2 100644 --- a/elements/Image.js +++ b/elements/Image.js @@ -34,7 +34,7 @@ class Image extends Shape { let {props} = this; return this.root = ele} - {...this.extractProps(props, {transform: true, responder: true})} + {...this.extractProps(props, {responder: true})} x={props.x.toString()} y={props.y.toString()} width={props.width.toString()} diff --git a/ios/Elements/RNSVGDefination.h b/ios/Elements/RNSVGDefs.h similarity index 89% rename from ios/Elements/RNSVGDefination.h rename to ios/Elements/RNSVGDefs.h index 1f961f9a..9e58b40c 100644 --- a/ios/Elements/RNSVGDefination.h +++ b/ios/Elements/RNSVGDefs.h @@ -12,6 +12,6 @@ * RNSVG defination are implemented as abstract UIViews for all elements inside Defs. */ -@interface RNSVGDefination : RNSVGNode +@interface RNSVGDefs : RNSVGNode @end diff --git a/ios/Elements/RNSVGDefination.m b/ios/Elements/RNSVGDefs.m similarity index 88% rename from ios/Elements/RNSVGDefination.m rename to ios/Elements/RNSVGDefs.m index 6ef998c7..5bd583d0 100644 --- a/ios/Elements/RNSVGDefination.m +++ b/ios/Elements/RNSVGDefs.m @@ -5,11 +5,11 @@ * This source code is licensed under the MIT-style license found in the * LICENSE file in the root directory of this source tree. */ -#import "RNSVGDefination.h" +#import "RNSVGDefs.h" @class RNSVGNode; -@implementation RNSVGDefination +@implementation RNSVGDefs - (void)renderTo:(CGContextRef)context { diff --git a/ios/RNSVG.xcodeproj/project.pbxproj b/ios/RNSVG.xcodeproj/project.pbxproj index 9fb28977..e80acbf4 100644 --- a/ios/RNSVG.xcodeproj/project.pbxproj +++ b/ios/RNSVG.xcodeproj/project.pbxproj @@ -11,7 +11,7 @@ 0CF68B0B1AF0549300FF9E5C /* RNSVGBrush.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AEC1AF0549300FF9E5C /* RNSVGBrush.m */; }; 0CF68B0D1AF0549300FF9E5C /* RNSVGPattern.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AF01AF0549300FF9E5C /* RNSVGPattern.m */; }; 0CF68B0F1AF0549300FF9E5C /* RNSVGSolidColorBrush.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AF41AF0549300FF9E5C /* RNSVGSolidColorBrush.m */; }; - 1023B48D1D3DDCCE0051496D /* RNSVGDefinationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1023B48C1D3DDCCE0051496D /* RNSVGDefinationManager.m */; }; + 1023B48D1D3DDCCE0051496D /* RNSVGDefsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1023B48C1D3DDCCE0051496D /* RNSVGDefsManager.m */; }; 1023B4901D3DF4C40051496D /* RNSVGDefination.m in Sources */ = {isa = PBXBuildFile; fileRef = 1023B48F1D3DF4C40051496D /* RNSVGDefination.m */; }; 1023B4931D3DF5060051496D /* RNSVGUse.m in Sources */ = {isa = PBXBuildFile; fileRef = 1023B4921D3DF5060051496D /* RNSVGUse.m */; }; 1023B4961D3DF57D0051496D /* RNSVGUseManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1023B4951D3DF57D0051496D /* RNSVGUseManager.m */; }; @@ -73,9 +73,9 @@ 0CF68AF01AF0549300FF9E5C /* RNSVGPattern.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSVGPattern.m; sourceTree = ""; }; 0CF68AF31AF0549300FF9E5C /* RNSVGSolidColorBrush.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNSVGSolidColorBrush.h; sourceTree = ""; }; 0CF68AF41AF0549300FF9E5C /* RNSVGSolidColorBrush.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSVGSolidColorBrush.m; sourceTree = ""; }; - 1023B48B1D3DDCCE0051496D /* RNSVGDefinationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNSVGDefinationManager.h; sourceTree = ""; }; - 1023B48C1D3DDCCE0051496D /* RNSVGDefinationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSVGDefinationManager.m; sourceTree = ""; }; - 1023B48E1D3DF4C40051496D /* RNSVGDefination.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSVGDefination.h; path = Elements/RNSVGDefination.h; sourceTree = ""; }; + 1023B48B1D3DDCCE0051496D /* RNSVGDefsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNSVGDefsManager.h; sourceTree = ""; }; + 1023B48C1D3DDCCE0051496D /* RNSVGDefsManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSVGDefsManager.m; sourceTree = ""; }; + 1023B48E1D3DF4C40051496D /* RNSVGDefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSVGDefs.h; path = Elements/RNSVGDefs.h; sourceTree = ""; }; 1023B48F1D3DF4C40051496D /* RNSVGDefination.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNSVGDefination.m; path = Elements/RNSVGDefination.m; sourceTree = ""; }; 1023B4911D3DF5060051496D /* RNSVGUse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSVGUse.h; path = Elements/RNSVGUse.h; sourceTree = ""; }; 1023B4921D3DF5060051496D /* RNSVGUse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNSVGUse.m; path = Elements/RNSVGUse.m; sourceTree = ""; }; @@ -225,8 +225,8 @@ 10BEC1C11D3F680F00FDCB19 /* RNSVGRadialGradientManager.m */, 1023B4941D3DF57D0051496D /* RNSVGUseManager.h */, 1023B4951D3DF57D0051496D /* RNSVGUseManager.m */, - 1023B48B1D3DDCCE0051496D /* RNSVGDefinationManager.h */, - 1023B48C1D3DDCCE0051496D /* RNSVGDefinationManager.m */, + 1023B48B1D3DDCCE0051496D /* RNSVGDefsManager.h */, + 1023B48C1D3DDCCE0051496D /* RNSVGDefsManager.m */, 10ED4A9C1CF0656A0078BC02 /* RNSVGClipPathManager.h */, 10ED4A9D1CF0656A0078BC02 /* RNSVGClipPathManager.m */, 10BA0D1C1CE74E3100887C2B /* RNSVGCircleManager.h */, @@ -291,7 +291,7 @@ 10BEC1BB1D3F66F500FDCB19 /* RNSVGRadialGradient.m */, 1023B4911D3DF5060051496D /* RNSVGUse.h */, 1023B4921D3DF5060051496D /* RNSVGUse.m */, - 1023B48E1D3DF4C40051496D /* RNSVGDefination.h */, + 1023B48E1D3DF4C40051496D /* RNSVGDefs.h */, 1023B48F1D3DF4C40051496D /* RNSVGDefination.m */, 10ED4A991CF065260078BC02 /* RNSVGClipPath.h */, 10ED4A9A1CF065260078BC02 /* RNSVGClipPath.m */, @@ -417,7 +417,7 @@ 10FDEEB21D3FB60500A5C46C /* RNSVGBaseBrush.m in Sources */, 1039D28C1CE71EB7001E90A8 /* RNSVGSvgView.m in Sources */, 1023B4961D3DF57D0051496D /* RNSVGUseManager.m in Sources */, - 1023B48D1D3DDCCE0051496D /* RNSVGDefinationManager.m in Sources */, + 1023B48D1D3DDCCE0051496D /* RNSVGDefsManager.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ios/RNSVGNode.h b/ios/RNSVGNode.h index b588c167..b620bdae 100644 --- a/ios/RNSVGNode.h +++ b/ios/RNSVGNode.h @@ -23,7 +23,7 @@ @property (nonatomic, assign) CGPathRef clipPath; // convert clipPath="M0,0 L0,10 L10,10z" into path @property (nonatomic, strong) NSString *clipPathRef; // use clipPath="url(#clip)" as ClipPath @property (nonatomic, assign) BOOL responsible; - +@property (nonatomic, assign) CGAffineTransform trans; - (void)invalidate; diff --git a/ios/RNSVGNode.m b/ios/RNSVGNode.m index ae92c154..396bdbc5 100644 --- a/ios/RNSVGNode.m +++ b/ios/RNSVGNode.m @@ -69,6 +69,11 @@ _opacity = opacity; } +- (void)setTrans:(CGAffineTransform)trans +{ + self.transform = trans; +} + - (void)setTransform:(CGAffineTransform)transform { [self invalidate]; diff --git a/ios/ViewManagers/RNSVGDefsManager.h b/ios/ViewManagers/RNSVGDefsManager.h new file mode 100644 index 00000000..6c2d232c --- /dev/null +++ b/ios/ViewManagers/RNSVGDefsManager.h @@ -0,0 +1,15 @@ +/** + * Copyright (c) 2015-present, Horcrux. + * All rights reserved. + * + * This source code is licensed under the MIT-style license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import "RCTViewManager.h" + +@interface RNSVGDefsManager : RCTViewManager + +@end + +#import "RNSVGNode.h" diff --git a/ios/ViewManagers/RNSVGDefsManager.m b/ios/ViewManagers/RNSVGDefsManager.m new file mode 100644 index 00000000..d6eccd83 --- /dev/null +++ b/ios/ViewManagers/RNSVGDefsManager.m @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2015-present, Horcrux. + * All rights reserved. + * + * This source code is licensed under the MIT-style license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import "RNSVGDefsManager.h" +#import "RNSVGDefs.h" + +@implementation RNSVGDefsManager + +RCT_EXPORT_MODULE() + +- (RNSVGDefs *)node +{ + return [RNSVGDefs new]; +} + +- (UIView *)view +{ + return [self node]; +} + +- (RCTShadowView *)shadowView +{ + return nil; +} + +@end diff --git a/ios/ViewManagers/RNSVGNodeManager.m b/ios/ViewManagers/RNSVGNodeManager.m index 18a98e0c..df19e93b 100644 --- a/ios/ViewManagers/RNSVGNodeManager.m +++ b/ios/ViewManagers/RNSVGNodeManager.m @@ -31,7 +31,7 @@ RCT_EXPORT_MODULE() RCT_EXPORT_VIEW_PROPERTY(name, NSString) RCT_EXPORT_VIEW_PROPERTY(opacity, CGFloat) -RCT_EXPORT_VIEW_PROPERTY(transform, CGAffineTransform) +RCT_EXPORT_VIEW_PROPERTY(trans, CGAffineTransform) RCT_EXPORT_VIEW_PROPERTY(clipPathRef, NSString) RCT_EXPORT_VIEW_PROPERTY(clipPath, CGPath) RCT_EXPORT_VIEW_PROPERTY(clipRule, RNSVGCGFCRule) diff --git a/lib/attributes.js b/lib/attributes.js index ea3da251..0c837ea1 100644 --- a/lib/attributes.js +++ b/lib/attributes.js @@ -52,7 +52,7 @@ const ViewBoxAttributes = { const NodeAttributes = { name: true, - transform: { + trans: { diff: arrayDiffer }, opacity: true, diff --git a/lib/extract/extractProps.js b/lib/extract/extractProps.js index f8f1d079..4a680fca 100644 --- a/lib/extract/extractProps.js +++ b/lib/extract/extractProps.js @@ -46,11 +46,11 @@ export default function(props, options = {stroke: true, transform: true, fill: t } if (options.transform) { - extractedProps.transform = extractTransform(props); + extractedProps.trans = extractTransform(props); } else if (props.transform) { // todo: add support for transform prop like this: // {scale: 1.5, translate: '10 10'} - extractedProps.transform = props.transform; + //extractedProps.transform = props.transform; } if (options.responder) {