Fabric: `EdgeInsets` from `dynamic` conversion

Summary: We will need this for several components, first of all for ScrollView.

Reviewed By: fkgozali

Differential Revision: D7958246

fbshipit-source-id: 364b939abe8f0734376448149bbdc735abd00189
This commit is contained in:
Valentin Shergin 2018-05-15 23:32:38 -07:00 коммит произвёл Facebook Github Bot
Родитель 545f087b46
Коммит 30d08ea8a4
1 изменённых файлов: 13 добавлений и 0 удалений

Просмотреть файл

@ -75,6 +75,19 @@ inline void fromDynamic(const folly::dynamic &value, Size &result) {
abort();
}
inline void fromDynamic(const folly::dynamic &value, EdgeInsets &result) {
if (value.isArray()) {
result = EdgeInsets {
(Float)value[0].asDouble(),
(Float)value[1].asDouble(),
(Float)value[2].asDouble(),
(Float)value[3].asDouble()
};
return;
}
abort();
}
inline std::string toString(const Point &point) {
return "{" + folly::to<std::string>(point.x) + ", " + folly::to<std::string>(point.y) + "}";
}