From 7c012a9fe37aad146e7794a35a4238481b7d4703 Mon Sep 17 00:00:00 2001 From: Mikael Sand Date: Wed, 10 Oct 2018 22:53:58 +0300 Subject: [PATCH] [iOS] Fixes for native animation of width and height of Rect Allow string or float values. --- ios/ViewManagers/RNSVGRectManager.m | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/ios/ViewManagers/RNSVGRectManager.m b/ios/ViewManagers/RNSVGRectManager.m index a4f3dce9..13a3c125 100644 --- a/ios/ViewManagers/RNSVGRectManager.m +++ b/ios/ViewManagers/RNSVGRectManager.m @@ -22,8 +22,26 @@ RCT_EXPORT_MODULE() RCT_EXPORT_VIEW_PROPERTY(x, NSString) RCT_EXPORT_VIEW_PROPERTY(y, NSString) -RCT_EXPORT_VIEW_PROPERTY(rectwidth, NSString) -RCT_EXPORT_VIEW_PROPERTY(rectheight, NSString) +RCT_CUSTOM_VIEW_PROPERTY(rectheight, id, RNSVGRect) +{ + if ([json isKindOfClass:[NSString class]]) { + NSString *stringValue = (NSString *)json; + view.rectheight = stringValue; + } else { + view.rectheight = [NSString stringWithFormat:@"%f", [json floatValue]]; + } +} + +RCT_CUSTOM_VIEW_PROPERTY(rectwidth, id, RNSVGRect) +{ + if ([json isKindOfClass:[NSString class]]) { + NSString *stringValue = (NSString *)json; + view.rectwidth = stringValue; + } else { + view.rectwidth = [NSString stringWithFormat:@"%f", [json floatValue]]; + } +} + RCT_EXPORT_VIEW_PROPERTY(rx, NSString) RCT_EXPORT_VIEW_PROPERTY(ry, NSString)