Fabric: Support for object notation in dynamic-to-Point/Size/Edges converstions
Summary: Trivial. Reviewed By: fkgozali Differential Revision: D8086650 fbshipit-source-id: 0850c799811f7cda2dd6786aada6222dcc28a3e4
This commit is contained in:
parent
3bcfdc4b9f
commit
f180300606
|
@ -60,6 +60,10 @@ inline void fromDynamic(const folly::dynamic &value, Float &result) {
|
|||
}
|
||||
|
||||
inline void fromDynamic(const folly::dynamic &value, Point &result) {
|
||||
if (value.isObject()) {
|
||||
result = Point {(Float)value["x"].asDouble(), (Float)value["y"].asDouble()};
|
||||
return;
|
||||
}
|
||||
if (value.isArray()) {
|
||||
result = Point {(Float)value[0].asDouble(), (Float)value[1].asDouble()};
|
||||
return;
|
||||
|
@ -68,6 +72,10 @@ inline void fromDynamic(const folly::dynamic &value, Point &result) {
|
|||
}
|
||||
|
||||
inline void fromDynamic(const folly::dynamic &value, Size &result) {
|
||||
if (value.isObject()) {
|
||||
result = Size {(Float)value["width"].asDouble(), (Float)value["height"].asDouble()};
|
||||
return;
|
||||
}
|
||||
if (value.isArray()) {
|
||||
result = Size {(Float)value[0].asDouble(), (Float)value[1].asDouble()};
|
||||
return;
|
||||
|
@ -76,6 +84,15 @@ inline void fromDynamic(const folly::dynamic &value, Size &result) {
|
|||
}
|
||||
|
||||
inline void fromDynamic(const folly::dynamic &value, EdgeInsets &result) {
|
||||
if (value.isObject()) {
|
||||
result = EdgeInsets {
|
||||
(Float)value["top"].asDouble(),
|
||||
(Float)value["left"].asDouble(),
|
||||
(Float)value["bottom"].asDouble(),
|
||||
(Float)value["right"].asDouble()
|
||||
};
|
||||
return;
|
||||
}
|
||||
if (value.isArray()) {
|
||||
result = EdgeInsets {
|
||||
(Float)value[0].asDouble(),
|
||||
|
|
Loading…
Reference in New Issue