diff --git a/ReactCommon/fabric/view/ViewProps.cpp b/ReactCommon/fabric/view/ViewProps.cpp index 5f667312c..c6d3ddcce 100644 --- a/ReactCommon/fabric/view/ViewProps.cpp +++ b/ReactCommon/fabric/view/ViewProps.cpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace facebook { namespace react { @@ -20,10 +21,22 @@ ViewProps::ViewProps(const YGStyle &yogaStyle): ViewProps::ViewProps(const ViewProps &sourceProps, const RawProps &rawProps): Props(sourceProps, rawProps), YogaStylableProps(sourceProps, rawProps), - zIndex(convertRawProp(rawProps, "zIndex", sourceProps.zIndex)), opacity(convertRawProp(rawProps, "opacity", sourceProps.opacity)), - foregroundColor(convertRawProp(rawProps, "color", sourceProps.foregroundColor)), - backgroundColor(convertRawProp(rawProps, "backgroundColor", sourceProps.backgroundColor)) {}; + foregroundColor(convertRawProp(rawProps, "foregroundColor", sourceProps.foregroundColor)), + backgroundColor(convertRawProp(rawProps, "backgroundColor", sourceProps.backgroundColor)), + borderWidth(convertRawProp(rawProps, "borderWidth", sourceProps.borderWidth)), + borderRadus(convertRawProp(rawProps, "borderRadus", sourceProps.borderRadus)), + borderColor(convertRawProp(rawProps, "borderColor", sourceProps.borderColor)), + borderStyle(convertRawProp(rawProps, "borderStyle", sourceProps.borderStyle)), + shadowColor(convertRawProp(rawProps, "shadowColor", sourceProps.shadowColor)), + shadowOffset(convertRawProp(rawProps, "shadowOffset", sourceProps.shadowOffset)), + shadowOpacity(convertRawProp(rawProps, "shadowOpacity", sourceProps.shadowOpacity)), + shadowRadius(convertRawProp(rawProps, "shadowRadius", sourceProps.shadowRadius)), + backfaceVisibility(convertRawProp(rawProps, "backfaceVisibility", sourceProps.backfaceVisibility)), + shouldRasterize(convertRawProp(rawProps, "shouldRasterize", sourceProps.shouldRasterize)), + zIndex(convertRawProp(rawProps, "zIndex", sourceProps.zIndex)), + pointerEvents(convertRawProp(rawProps, "pointerEvents", sourceProps.pointerEvents)), + hitSlop(convertRawProp(rawProps, "hitSlop", sourceProps.hitSlop)) {}; #pragma mark - DebugStringConvertible diff --git a/ReactCommon/fabric/view/ViewProps.h b/ReactCommon/fabric/view/ViewProps.h index b0fa20369..5f49e0395 100644 --- a/ReactCommon/fabric/view/ViewProps.h +++ b/ReactCommon/fabric/view/ViewProps.h @@ -10,8 +10,9 @@ #include #include #include -#include #include +#include +#include namespace facebook { namespace react { @@ -33,14 +34,31 @@ public: #pragma mark - Props - const int zIndex {0}; + // Color const Float opacity {1}; - const SharedColor foregroundColor {nullptr}; const SharedColor backgroundColor {nullptr}; + // Borders + const EdgeInsets borderWidth {}; + const CornerInsets borderRadus {}; + const SharedColor borderColor {}; + const BorderStyle borderStyle {}; + + // Shadow const SharedColor shadowColor {nullptr}; - const Point shadowOffset {}; + const Size shadowOffset {}; + const Float shadowOpacity {}; + const Float shadowRadius {}; + + // Transform + const bool backfaceVisibility {false}; + const bool shouldRasterize {false}; + const int zIndex {0}; + + // Events + const PointerEventsMode pointerEvents {}; + const EdgeInsets hitSlop {}; #pragma mark - DebugStringConvertible diff --git a/ReactCommon/fabric/view/conversions.h b/ReactCommon/fabric/view/conversions.h index 66cb25da0..2a228b510 100644 --- a/ReactCommon/fabric/view/conversions.h +++ b/ReactCommon/fabric/view/conversions.h @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -226,6 +227,25 @@ inline void fromDynamic(const folly::dynamic &value, YGFloatOptional &result) { abort(); } +inline void fromDynamic(const folly::dynamic &value, PointerEventsMode &result) { + assert(value.isString()); + auto stringValue = value.asString(); + if (stringValue == "auto") { result = PointerEventsMode::Auto; return; } + if (stringValue == "none") { result = PointerEventsMode::None; return; } + if (stringValue == "box-none") { result = PointerEventsMode::BoxNone; return; } + if (stringValue == "box-only") { result = PointerEventsMode::BoxOnly; return; } + abort(); +} + +inline void fromDynamic(const folly::dynamic &value, BorderStyle &result) { + assert(value.isString()); + auto stringValue = value.asString(); + if (stringValue == "solid") { result = BorderStyle::Solid; return; } + if (stringValue == "dotted") { result = BorderStyle::Dotted; return; } + if (stringValue == "dashed") { result = BorderStyle::Dashed; return; } + abort(); +} + inline std::string toString(const std::array &dimensions) { return "{" + folly::to(dimensions[0]) + ", " + folly::to(dimensions[1]) + "}"; } diff --git a/ReactCommon/fabric/view/primitives.h b/ReactCommon/fabric/view/primitives.h new file mode 100644 index 000000000..1aced9684 --- /dev/null +++ b/ReactCommon/fabric/view/primitives.h @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include + +namespace facebook { +namespace react { + +enum class PointerEventsMode { + Auto, + None, + BoxNone, + BoxOnly +}; + +enum class BorderStyle { + Solid, + Dotted, + Dashed +}; + +} // namespace react +} // namespace facebook