mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-06 08:22:23 +00:00
Finish percentage props refactor on iOS
This commit is contained in:
@@ -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,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]];
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user