Finish percentage props refactor on iOS

This commit is contained in:
Horcrux
2017-01-20 17:47:57 +08:00
parent 8582e076e4
commit af6db7039f
23 changed files with 184 additions and 220 deletions
+1 -1
View File
@@ -12,7 +12,7 @@
@interface RNSVGGlyphContext : NSObject
- (instancetype)initWithConverters:(RNSVGPercentageConverter *)widthConverter heightConverter:(RNSVGPercentageConverter *)heightConverter;
- (instancetype)initWithDimensions:(CGFloat)width height:(CGFloat)height;
- (void)pushContext:(NSDictionary *)font deltaX:(NSArray<NSNumber *> *)deltaX deltaY:(NSArray<NSNumber *> *)deltaY positionX:(NSString *)positionX positionY:(NSString *)positionY;
- (void)popContext;
- (CTFontRef)getGlyphFont;
+8 -7
View File
@@ -8,6 +8,7 @@
#import "RNSVGGlyphContext.h"
#import "RNSVGPercentageConverter.h"
#import <React/RCTFont.h>
@implementation RNSVGGlyphContext
@@ -18,15 +19,15 @@
NSMutableArray<NSArray *> *_deltaYContext;
NSMutableArray<NSNumber *> *_xContext;
CGPoint _currentLocation;
RNSVGPercentageConverter *_widthConverter;
RNSVGPercentageConverter *_heightConverter;
CGFloat _width;
CGFloat _height;
}
- (instancetype)initWithConverters:(RNSVGPercentageConverter *)widthConverter heightConverter:(RNSVGPercentageConverter *)heightConverter
- (instancetype)initWithDimensions:(CGFloat)width height:(CGFloat)height
{
if (self = [super init]) {
_widthConverter = widthConverter;
_heightConverter = heightConverter;
_width = width;
_height = height;
_fontContext = [[NSMutableArray alloc] init];
_locationContext = [[NSMutableArray alloc] init];
_deltaXContext = [[NSMutableArray alloc] init];
@@ -42,11 +43,11 @@
CGPoint location = _currentLocation;
if (positionX) {
location.x = [_widthConverter stringToFloat:positionX];
location.x = [RNSVGPercentageConverter stringToFloat:positionX relative:_width offset:0];
}
if (positionY) {
location.y = [_heightConverter stringToFloat:positionY];
location.y = [RNSVGPercentageConverter stringToFloat:positionY relative:_height offset:0];
}
[_locationContext addObject:[NSValue valueWithCGPoint:location]];
-1
View File
@@ -140,7 +140,6 @@
[self traverseTextSuperviews:^(__kindof RNSVGText *node) {
if ([node class] == [RNSVGTextPath class]) {
RNSVGTextPath *textPath = node;
[node setContextBoundingBox:CGContextGetClipBoundingBox(context)];
bezierTransformer = [node getBezierTransformer];
return NO;
}
+2 -3
View File
@@ -45,9 +45,8 @@
- (void)setupGlyphContext:(CGContextRef)context
{
[self setContextBoundingBox:CGContextGetClipBoundingBox(context)];
_glyphContext = [[RNSVGGlyphContext alloc] initWithConverters:[self getWidthConverter]
heightConverter:[self getHeightConverter]];
_glyphContext = [[RNSVGGlyphContext alloc] initWithDimensions:[self getContextWidth]
height:[self getContextHeight]];
}
// release the cached CGPathRef for RNSVGTSpan
+1 -2
View File
@@ -14,7 +14,6 @@
- (void)renderLayerTo:(CGContextRef)context
{
[self setContextBoundingBox:CGContextGetClipBoundingBox(context)];
[self renderGroupTo:context];
}
@@ -29,7 +28,7 @@
}
RNSVGPath *path = template;
CGFloat startOffset = [self getWidthRelatedValue:self.startOffset];
CGFloat startOffset = [self relativeOnWidth:self.startOffset];
return [[RNSVGBezierTransformer alloc] initWithBezierCurvesAndStartOffset:[path getBezierCurves]
startOffset:startOffset];
}