From f42badeb888b829b4260d83a5242c4d96bf25a84 Mon Sep 17 00:00:00 2001 From: Roman Gorbunov Date: Thu, 25 Jul 2019 03:59:05 -0700 Subject: [PATCH] CKInsetComponent live editing Summary: CKInsetComponent's insets are now live editable P.S. Now it takes some time to see the view changed and the new value of insets on flipper side Reviewed By: kevin0571 Differential Revision: D16338109 fbshipit-source-id: 9c6648e72d55a09df9d715637e82901d1b5dcec8 --- .../CKInsetComponent+Sonar.mm | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKInsetComponent+Sonar.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKInsetComponent+Sonar.mm index 42df36c06..985fb80ad 100644 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKInsetComponent+Sonar.mm +++ b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKInsetComponent+Sonar.mm @@ -19,7 +19,33 @@ FB_LINKABLE(CKInsetComponent_Sonar) - (NSArray *> *> *)sonar_additionalDataOverride { - return @[[SKNamed newWithName:@"CKInsetComponent" withValue:@{@"insets": SKObject([[self valueForKey: @"_insets"] UIEdgeInsetsValue])}]]; + return @[[SKNamed newWithName:@"CKInsetComponent" withValue:@{@"insets": SKMutableObject([[self valueForKey:@"_insets"] UIEdgeInsetsValue])}]]; +} + +- (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]; + }, + }; } @end