Skip to content

Commit

Permalink
Fabric: Improved parsing EdgeInsets and CornerInsets styles
Browse files Browse the repository at this point in the history
Summary: In case if it's just a number, it is treated as unified insets now.

Reviewed By: mdvacca

Differential Revision: D8473510

fbshipit-source-id: 1034377bc3e4abe55778c2f182360345419f00d5
  • Loading branch information
shergin authored and facebook-github-bot committed Jun 18, 2018
1 parent c1e0ea9 commit d92601b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ReactCommon/fabric/graphics/conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ inline void fromDynamic(const folly::dynamic &value, Size &result) {
}

inline void fromDynamic(const folly::dynamic &value, EdgeInsets &result) {
if (value.isNumber()) {
const Float number = value.asDouble();
result = EdgeInsets {number, number, number, number};
return;
}
if (value.isObject()) {
result = EdgeInsets {
(Float)value["top"].asDouble(),
Expand All @@ -106,6 +111,11 @@ inline void fromDynamic(const folly::dynamic &value, EdgeInsets &result) {
}

inline void fromDynamic(const folly::dynamic &value, CornerInsets &result) {
if (value.isNumber()) {
const Float number = value.asDouble();
result = CornerInsets {number, number, number, number};
return;
}
if (value.isObject()) {
result = CornerInsets {
(Float)value["topLeft"].asDouble(),
Expand Down

0 comments on commit d92601b

Please sign in to comment.