Summary: CKFlexboxComponent's insets are now live editable P.S. Now it takes some time to see the view changed and the new value of everything on flipper side Reviewed By: kevin0571 Differential Revision: D16379743 fbshipit-source-id: 69bc9b7cb6b2103ff34b5c4489b240ac7562a85d
43 lines
1.3 KiB
Plaintext
43 lines
1.3 KiB
Plaintext
/*
|
|
* Copyright (c) 2018-present, Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the LICENSE
|
|
* file in the root directory of this source tree.
|
|
*
|
|
*/
|
|
#if FB_SONARKIT_ENABLED
|
|
|
|
#include "Utils.h"
|
|
|
|
NSString *relativeDimension(CKRelativeDimension dimension) {
|
|
switch(dimension.type()) {
|
|
case CKRelativeDimension::Type::PERCENT:
|
|
return [NSString stringWithFormat: @"%@%%", @(dimension.value())];
|
|
case CKRelativeDimension::Type::POINTS:
|
|
return [NSString stringWithFormat: @"%@pt", @(dimension.value())];
|
|
default:
|
|
return @"auto";
|
|
}
|
|
}
|
|
|
|
CKRelativeDimension relativeStructDimension(NSString *dimension) {
|
|
if ([dimension hasSuffix:@"%"]) {
|
|
return CKRelativeDimension::Percent([[dimension substringToIndex:([dimension length] - 1)] integerValue]);
|
|
}
|
|
if ([dimension hasSuffix:@"pt"]) {
|
|
return CKRelativeDimension::Points([[dimension substringToIndex:([dimension length] - 2)] integerValue]);
|
|
}
|
|
return CKRelativeDimension::Auto();
|
|
}
|
|
|
|
NSDictionary<NSString *, NSString *> *flexboxRect(CKFlexboxSpacing spacing) {
|
|
return @{
|
|
@"top": relativeDimension(spacing.top.dimension()),
|
|
@"bottom": relativeDimension(spacing.bottom.dimension()),
|
|
@"start": relativeDimension(spacing.start.dimension()),
|
|
@"end": relativeDimension(spacing.end.dimension())
|
|
};
|
|
}
|
|
|
|
#endif
|