mirror of
https://github.com/status-im/react-native.git
synced 2025-02-03 21:24:31 +00:00
Fabric: Implementation of yogaStyleValueFromFloat
Summary: Quite obvious. Reviewed By: mdvacca Differential Revision: D7857047 fbshipit-source-id: 876664b3ab5c19b7c66a38579664f18a38a1a371
This commit is contained in:
parent
7cf7028092
commit
e028631513
@ -20,8 +20,8 @@ class YogaStylableProps;
|
||||
typedef std::shared_ptr<const YogaStylableProps> SharedYogaStylableProps;
|
||||
|
||||
class YogaStylableProps:
|
||||
public virtual DebugStringConvertible
|
||||
{
|
||||
public virtual DebugStringConvertible {
|
||||
|
||||
public:
|
||||
const YGStyle &getYogaStyle() const;
|
||||
|
||||
|
@ -46,6 +46,14 @@ YGFloatOptional yogaOptionalFloatFromFabricFloat(Float value) {
|
||||
return YGFloatOptional(yogaFloatFromFabricFloat(value));
|
||||
}
|
||||
|
||||
YGValue yogaStyleValueFromFloat(const Float &value) {
|
||||
if (isnan(value) || value == kFloatUndefined) {
|
||||
return YGValueUndefined;
|
||||
}
|
||||
|
||||
return {(float)value, YGUnitPoint};
|
||||
}
|
||||
|
||||
LayoutMetrics layoutMetricsFromYogaNode(YGNode &yogaNode) {
|
||||
LayoutMetrics layoutMetrics;
|
||||
|
||||
@ -182,12 +190,11 @@ YGDisplay yogaStyleDisplayFromDynamic(const folly::dynamic &value) {
|
||||
|
||||
YGValue yogaStyleValueFromDynamic(const folly::dynamic &value) {
|
||||
if (value.isNumber()) {
|
||||
float x = value.asDouble();
|
||||
return { x, YGUnitPoint };
|
||||
return yogaStyleValueFromFloat(value.asDouble());
|
||||
} else if (value.isString()) {
|
||||
const auto stringValue = value.asString();
|
||||
if (stringValue == "auto") {
|
||||
return { YGUndefined, YGUnitAuto };
|
||||
return YGValueUndefined;
|
||||
} else {
|
||||
if (stringValue.back() == '%') {
|
||||
return { folly::to<float>(stringValue.substr(stringValue.length() - 1)), YGUnitPercent };
|
||||
|
@ -24,6 +24,8 @@ float yogaFloatFromFabricFloat(Float value);
|
||||
Float fabricFloatFromYogaOptionalFloat(YGFloatOptional value);
|
||||
YGFloatOptional yogaOptionalFloatFromFabricFloat(Float value);
|
||||
|
||||
YGValue yogaStyleValueFromFloat(const Float &value);
|
||||
|
||||
LayoutMetrics layoutMetricsFromYogaNode(YGNode &yogaNode);
|
||||
|
||||
YGDirection yogaStyleDirectionFromDynamic(const folly::dynamic &value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user