From 0fd6262044bb14568a51e2e168548278b2da4acb Mon Sep 17 00:00:00 2001 From: Ruslan Serebriakov Date: Wed, 20 Jan 2021 04:47:18 -0800 Subject: [PATCH] Fixing the issue with broken CKInsetComponent set up Summary: After updating the internal properties of CKInsetComponent we didn't update some KVO magic being used in Flipper which caused some crashes: https://fb.workplace.com/groups/componentkit/permalink/4986354281413147/ Reviewed By: fabiomassimo Differential Revision: D25946704 fbshipit-source-id: 5995cda20d12b18f7520507cb6ede897fddf2670 --- .../CKInsetComponent+Sonar.mm | 51 ++++++++----------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKInsetComponent+Sonar.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKInsetComponent+Sonar.mm index cb996b085..2aa6d4425 100644 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKInsetComponent+Sonar.mm +++ b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKInsetComponent+Sonar.mm @@ -9,6 +9,7 @@ #import "CKInsetComponent+Sonar.h" +#import #import #import @@ -19,39 +20,27 @@ FB_LINKABLE(CKInsetComponent_Sonar) - (NSArray*>*>*) sonar_additionalDataOverride { - return @[ [SKNamed newWithName:@"CKInsetComponent" - withValue:@{ - @"insets" : SKMutableObject( - [[self valueForKey:@"_insets"] UIEdgeInsetsValue]) - }] ]; + return @[ + [SKNamed newWithName:@"CKInsetComponent" + withValue:@{@"insets" : SKObject([self insetsDictionary])}], + ]; } -- (void)setMutableData:(id)data { - [self setValue:data forKey:@"_insets"]; -} - -- (NSDictionary*)sonar_getDataMutationsChanged { - __block UIEdgeInsets insets = - [[self valueForKey:@"_insets"] UIEdgeInsetsValue]; - return @{@"CKInsetComponent.insets.bottom" : ^(NSNumber* value){ - insets.bottom = value.floatValue; - return [NSValue valueWithUIEdgeInsets:insets]; -} -, - @"CKInsetComponent.insets.left": ^(NSNumber *value) { - insets.left = value.floatValue; - return [NSValue valueWithUIEdgeInsets:insets]; - }, - @"CKInsetComponent.insets.right": ^(NSNumber *value) { - insets.right = value.floatValue; - return [NSValue valueWithUIEdgeInsets:insets]; - }, - @"CKInsetComponent.insets.top": ^(NSNumber *value) { - insets.top = value.floatValue; - return [NSValue valueWithUIEdgeInsets:insets]; - }, -} -; +- (id)insetsDictionary { + CKRelativeDimension top; + CKRelativeDimension left; + CKRelativeDimension bottom; + CKRelativeDimension right; + [[self valueForKey:@"_top"] getValue:&top]; + [[self valueForKey:@"_left"] getValue:&left]; + [[self valueForKey:@"_right"] getValue:&bottom]; + [[self valueForKey:@"_bottom"] getValue:&right]; + return @{ + @"top" : top.description(), + @"left" : left.description(), + @"bottom" : bottom.description(), + @"right" : right.description(), + }; } @end