Skip to content

Commit 3addafa

Browse files
javachefacebook-github-bot
authored andcommitted
Support constructing UIEdgeInsets with single value
Summary: This is only required in the old renderer, as in Fabric the parsing behaviour is shared across platforms (https://github.com/facebook/react-native/blob/main/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm#L264). JS changes are following in D33453327. Changelog: [iOS][Fixed] Enable hitSlop to be set using a single number. Reviewed By: philIip Differential Revision: D33453326 fbshipit-source-id: f15a4fd1d26dcac6f40b064be1a8266051b6aedf
1 parent a46a99e commit 3addafa

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

React/Base/RCTConvert.m

+18-1
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,24 @@ +(type)type : (id)json \
554554
RCT_CGSTRUCT_CONVERTER(CGPoint, (@[ @"x", @"y" ]))
555555
RCT_CGSTRUCT_CONVERTER(CGSize, (@[ @"width", @"height" ]))
556556
RCT_CGSTRUCT_CONVERTER(CGRect, (@[ @"x", @"y", @"width", @"height" ]))
557-
RCT_CGSTRUCT_CONVERTER(UIEdgeInsets, (@[ @"top", @"left", @"bottom", @"right" ]))
557+
558+
+ (UIEdgeInsets)UIEdgeInsets:(id)json
559+
{
560+
static NSArray *fields;
561+
static dispatch_once_t onceToken;
562+
dispatch_once(&onceToken, ^{
563+
fields = @[ @"top", @"left", @"bottom", @"right" ];
564+
});
565+
566+
if ([json isKindOfClass:[NSNumber class]]) {
567+
CGFloat value = [json doubleValue];
568+
return UIEdgeInsetsMake(value, value, value, value);
569+
} else {
570+
UIEdgeInsets result;
571+
convertCGStruct("UIEdgeInsets", fields, (CGFloat *)&result, json);
572+
return result;
573+
}
574+
}
558575

559576
RCT_ENUM_CONVERTER(
560577
CGLineJoin,

0 commit comments

Comments
 (0)