native prop tranform => trans,fix defs typo

This commit is contained in:
Horcrux
2016-07-25 11:15:39 +08:00
parent c846c59ed6
commit a2598a5591
15 changed files with 74 additions and 23 deletions
@@ -10,6 +10,6 @@ public class MainActivity extends ReactActivity {
*/ */
@Override @Override
protected String getMainComponentName() { protected String getMainComponentName() {
return "ArtSvgExample"; return "SvgExample";
} }
} }
@@ -1,3 +1,3 @@
<resources> <resources>
<string name="app_name">ArtSvgExample</string> <string name="app_name">SvgExample</string>
</resources> </resources>
+1 -1
View File
@@ -1,4 +1,4 @@
rootProject.name = 'ArtSvgExample' rootProject.name = 'SvgExample'
include ':app' include ':app'
include ':react-native-svg' include ':react-native-svg'
+3 -3
View File
@@ -7,13 +7,13 @@ class Defs extends Component {
static displayName = 'Defs'; static displayName = 'Defs';
render() { render() {
return <RNSVGDefination>{this.props.children}</RNSVGDefination>; return <RNSVGDefs>{this.props.children}</RNSVGDefs>;
} }
} }
const RNSVGDefination = createReactNativeComponentClass({ const RNSVGDefs = createReactNativeComponentClass({
validAttributes: {}, validAttributes: {},
uiViewClassName: 'RNSVGDefination' uiViewClassName: 'RNSVGDefs'
}); });
export default Defs; export default Defs;
+1 -1
View File
@@ -34,7 +34,7 @@ class Image extends Shape {
let {props} = this; let {props} = this;
return <RNSVGImage return <RNSVGImage
ref={ele => this.root = ele} ref={ele => this.root = ele}
{...this.extractProps(props, {transform: true, responder: true})} {...this.extractProps(props, {responder: true})}
x={props.x.toString()} x={props.x.toString()}
y={props.y.toString()} y={props.y.toString()}
width={props.width.toString()} width={props.width.toString()}
@@ -12,6 +12,6 @@
* RNSVG defination are implemented as abstract UIViews for all elements inside Defs. * RNSVG defination are implemented as abstract UIViews for all elements inside Defs.
*/ */
@interface RNSVGDefination : RNSVGNode @interface RNSVGDefs : RNSVGNode
@end @end
@@ -5,11 +5,11 @@
* This source code is licensed under the MIT-style license found in the * This source code is licensed under the MIT-style license found in the
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNSVGDefination.h" #import "RNSVGDefs.h"
@class RNSVGNode; @class RNSVGNode;
@implementation RNSVGDefination @implementation RNSVGDefs
- (void)renderTo:(CGContextRef)context - (void)renderTo:(CGContextRef)context
{ {
+8 -8
View File
@@ -11,7 +11,7 @@
0CF68B0B1AF0549300FF9E5C /* RNSVGBrush.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AEC1AF0549300FF9E5C /* RNSVGBrush.m */; }; 0CF68B0B1AF0549300FF9E5C /* RNSVGBrush.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AEC1AF0549300FF9E5C /* RNSVGBrush.m */; };
0CF68B0D1AF0549300FF9E5C /* RNSVGPattern.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AF01AF0549300FF9E5C /* RNSVGPattern.m */; }; 0CF68B0D1AF0549300FF9E5C /* RNSVGPattern.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AF01AF0549300FF9E5C /* RNSVGPattern.m */; };
0CF68B0F1AF0549300FF9E5C /* RNSVGSolidColorBrush.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF68AF41AF0549300FF9E5C /* RNSVGSolidColorBrush.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 */; }; 1023B4901D3DF4C40051496D /* RNSVGDefination.m in Sources */ = {isa = PBXBuildFile; fileRef = 1023B48F1D3DF4C40051496D /* RNSVGDefination.m */; };
1023B4931D3DF5060051496D /* RNSVGUse.m in Sources */ = {isa = PBXBuildFile; fileRef = 1023B4921D3DF5060051496D /* RNSVGUse.m */; }; 1023B4931D3DF5060051496D /* RNSVGUse.m in Sources */ = {isa = PBXBuildFile; fileRef = 1023B4921D3DF5060051496D /* RNSVGUse.m */; };
1023B4961D3DF57D0051496D /* RNSVGUseManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1023B4951D3DF57D0051496D /* RNSVGUseManager.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 = "<group>"; }; 0CF68AF01AF0549300FF9E5C /* RNSVGPattern.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSVGPattern.m; sourceTree = "<group>"; };
0CF68AF31AF0549300FF9E5C /* RNSVGSolidColorBrush.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNSVGSolidColorBrush.h; sourceTree = "<group>"; }; 0CF68AF31AF0549300FF9E5C /* RNSVGSolidColorBrush.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNSVGSolidColorBrush.h; sourceTree = "<group>"; };
0CF68AF41AF0549300FF9E5C /* RNSVGSolidColorBrush.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSVGSolidColorBrush.m; sourceTree = "<group>"; }; 0CF68AF41AF0549300FF9E5C /* RNSVGSolidColorBrush.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSVGSolidColorBrush.m; sourceTree = "<group>"; };
1023B48B1D3DDCCE0051496D /* RNSVGDefinationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNSVGDefinationManager.h; sourceTree = "<group>"; }; 1023B48B1D3DDCCE0051496D /* RNSVGDefsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNSVGDefsManager.h; sourceTree = "<group>"; };
1023B48C1D3DDCCE0051496D /* RNSVGDefinationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSVGDefinationManager.m; sourceTree = "<group>"; }; 1023B48C1D3DDCCE0051496D /* RNSVGDefsManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSVGDefsManager.m; sourceTree = "<group>"; };
1023B48E1D3DF4C40051496D /* RNSVGDefination.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSVGDefination.h; path = Elements/RNSVGDefination.h; sourceTree = "<group>"; }; 1023B48E1D3DF4C40051496D /* RNSVGDefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSVGDefs.h; path = Elements/RNSVGDefs.h; sourceTree = "<group>"; };
1023B48F1D3DF4C40051496D /* RNSVGDefination.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNSVGDefination.m; path = Elements/RNSVGDefination.m; sourceTree = "<group>"; }; 1023B48F1D3DF4C40051496D /* RNSVGDefination.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNSVGDefination.m; path = Elements/RNSVGDefination.m; sourceTree = "<group>"; };
1023B4911D3DF5060051496D /* RNSVGUse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSVGUse.h; path = Elements/RNSVGUse.h; sourceTree = "<group>"; }; 1023B4911D3DF5060051496D /* RNSVGUse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSVGUse.h; path = Elements/RNSVGUse.h; sourceTree = "<group>"; };
1023B4921D3DF5060051496D /* RNSVGUse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNSVGUse.m; path = Elements/RNSVGUse.m; sourceTree = "<group>"; }; 1023B4921D3DF5060051496D /* RNSVGUse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNSVGUse.m; path = Elements/RNSVGUse.m; sourceTree = "<group>"; };
@@ -225,8 +225,8 @@
10BEC1C11D3F680F00FDCB19 /* RNSVGRadialGradientManager.m */, 10BEC1C11D3F680F00FDCB19 /* RNSVGRadialGradientManager.m */,
1023B4941D3DF57D0051496D /* RNSVGUseManager.h */, 1023B4941D3DF57D0051496D /* RNSVGUseManager.h */,
1023B4951D3DF57D0051496D /* RNSVGUseManager.m */, 1023B4951D3DF57D0051496D /* RNSVGUseManager.m */,
1023B48B1D3DDCCE0051496D /* RNSVGDefinationManager.h */, 1023B48B1D3DDCCE0051496D /* RNSVGDefsManager.h */,
1023B48C1D3DDCCE0051496D /* RNSVGDefinationManager.m */, 1023B48C1D3DDCCE0051496D /* RNSVGDefsManager.m */,
10ED4A9C1CF0656A0078BC02 /* RNSVGClipPathManager.h */, 10ED4A9C1CF0656A0078BC02 /* RNSVGClipPathManager.h */,
10ED4A9D1CF0656A0078BC02 /* RNSVGClipPathManager.m */, 10ED4A9D1CF0656A0078BC02 /* RNSVGClipPathManager.m */,
10BA0D1C1CE74E3100887C2B /* RNSVGCircleManager.h */, 10BA0D1C1CE74E3100887C2B /* RNSVGCircleManager.h */,
@@ -291,7 +291,7 @@
10BEC1BB1D3F66F500FDCB19 /* RNSVGRadialGradient.m */, 10BEC1BB1D3F66F500FDCB19 /* RNSVGRadialGradient.m */,
1023B4911D3DF5060051496D /* RNSVGUse.h */, 1023B4911D3DF5060051496D /* RNSVGUse.h */,
1023B4921D3DF5060051496D /* RNSVGUse.m */, 1023B4921D3DF5060051496D /* RNSVGUse.m */,
1023B48E1D3DF4C40051496D /* RNSVGDefination.h */, 1023B48E1D3DF4C40051496D /* RNSVGDefs.h */,
1023B48F1D3DF4C40051496D /* RNSVGDefination.m */, 1023B48F1D3DF4C40051496D /* RNSVGDefination.m */,
10ED4A991CF065260078BC02 /* RNSVGClipPath.h */, 10ED4A991CF065260078BC02 /* RNSVGClipPath.h */,
10ED4A9A1CF065260078BC02 /* RNSVGClipPath.m */, 10ED4A9A1CF065260078BC02 /* RNSVGClipPath.m */,
@@ -417,7 +417,7 @@
10FDEEB21D3FB60500A5C46C /* RNSVGBaseBrush.m in Sources */, 10FDEEB21D3FB60500A5C46C /* RNSVGBaseBrush.m in Sources */,
1039D28C1CE71EB7001E90A8 /* RNSVGSvgView.m in Sources */, 1039D28C1CE71EB7001E90A8 /* RNSVGSvgView.m in Sources */,
1023B4961D3DF57D0051496D /* RNSVGUseManager.m in Sources */, 1023B4961D3DF57D0051496D /* RNSVGUseManager.m in Sources */,
1023B48D1D3DDCCE0051496D /* RNSVGDefinationManager.m in Sources */, 1023B48D1D3DDCCE0051496D /* RNSVGDefsManager.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
+1 -1
View File
@@ -23,7 +23,7 @@
@property (nonatomic, assign) CGPathRef clipPath; // convert clipPath="M0,0 L0,10 L10,10z" into path @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, strong) NSString *clipPathRef; // use clipPath="url(#clip)" as ClipPath
@property (nonatomic, assign) BOOL responsible; @property (nonatomic, assign) BOOL responsible;
@property (nonatomic, assign) CGAffineTransform trans;
- (void)invalidate; - (void)invalidate;
+5
View File
@@ -69,6 +69,11 @@
_opacity = opacity; _opacity = opacity;
} }
- (void)setTrans:(CGAffineTransform)trans
{
self.transform = trans;
}
- (void)setTransform:(CGAffineTransform)transform - (void)setTransform:(CGAffineTransform)transform
{ {
[self invalidate]; [self invalidate];
+15
View File
@@ -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"
+31
View File
@@ -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
+1 -1
View File
@@ -31,7 +31,7 @@ RCT_EXPORT_MODULE()
RCT_EXPORT_VIEW_PROPERTY(name, NSString) RCT_EXPORT_VIEW_PROPERTY(name, NSString)
RCT_EXPORT_VIEW_PROPERTY(opacity, CGFloat) 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(clipPathRef, NSString)
RCT_EXPORT_VIEW_PROPERTY(clipPath, CGPath) RCT_EXPORT_VIEW_PROPERTY(clipPath, CGPath)
RCT_EXPORT_VIEW_PROPERTY(clipRule, RNSVGCGFCRule) RCT_EXPORT_VIEW_PROPERTY(clipRule, RNSVGCGFCRule)
+1 -1
View File
@@ -52,7 +52,7 @@ const ViewBoxAttributes = {
const NodeAttributes = { const NodeAttributes = {
name: true, name: true,
transform: { trans: {
diff: arrayDiffer diff: arrayDiffer
}, },
opacity: true, opacity: true,
+2 -2
View File
@@ -46,11 +46,11 @@ export default function(props, options = {stroke: true, transform: true, fill: t
} }
if (options.transform) { if (options.transform) {
extractedProps.transform = extractTransform(props); extractedProps.trans = extractTransform(props);
} else if (props.transform) { } else if (props.transform) {
// todo: add support for transform prop like this: // todo: add support for transform prop like this:
// {scale: 1.5, translate: '10 10'} // {scale: 1.5, translate: '10 10'}
extractedProps.transform = props.transform; //extractedProps.transform = props.transform;
} }
if (options.responder) { if (options.responder) {