From 34499002f2a26e0e6314ddb9fba4d65cdf408fc7 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 15 Mar 2019 14:27:26 -0700 Subject: [PATCH] fbios BottomSheet implementation Summary: Several things need to ironed out: 1) LocalState in Fabric C++, 2) setting dimensions of BottomSheet component to 0,0 for parent. Reviewed By: shergin Differential Revision: D14426167 fbshipit-source-id: 45a90a7971c87672872108a9e360926b4a6095f0 --- React/Fabric/RCTConversions.h | 1 + .../view/yoga/YogaLayoutableShadowNode.cpp | 14 ++++++++++++++ .../view/yoga/YogaLayoutableShadowNode.h | 11 +++++++++++ ReactCommon/fabric/core/primitives/RawProps.h | 2 +- ReactCommon/fabric/core/propsConversions.h | 4 ++-- 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/React/Fabric/RCTConversions.h b/React/Fabric/RCTConversions.h index c4d8f407b..1f0716eed 100644 --- a/React/Fabric/RCTConversions.h +++ b/React/Fabric/RCTConversions.h @@ -1,3 +1,4 @@ + /** * Copyright (c) Facebook, Inc. and its affiliates. * diff --git a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp index 7886204ff..407664b94 100644 --- a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp @@ -101,6 +101,20 @@ void YogaLayoutableShadowNode::setProps(const YogaStylableProps &props) { yogaNode_.setStyle(props.yogaStyle); } +void YogaLayoutableShadowNode::setSize(Size size) const { + auto style = yogaNode_.getStyle(); + style.dimensions[YGDimensionWidth] = yogaStyleValueFromFloat(size.width); + style.dimensions[YGDimensionHeight] = yogaStyleValueFromFloat(size.height); + yogaNode_.setStyle(style); +} + +void YogaLayoutableShadowNode::setPositionType( + YGPositionType positionType) const { + auto style = yogaNode_.getStyle(); + style.positionType = positionType; + yogaNode_.setStyle(style); +} + void YogaLayoutableShadowNode::layout(LayoutContext layoutContext) { if (!getIsLayoutClean()) { ensureUnsealed(); diff --git a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.h b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.h index ea388e39b..012f67091 100644 --- a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.h +++ b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.h @@ -17,6 +17,7 @@ #include #include #include +#include namespace facebook { namespace react { @@ -63,6 +64,16 @@ class YogaLayoutableShadowNode : public LayoutableShadowNode, */ void setProps(const YogaStylableProps &props); + /** + * Sets layoutable size of node. + */ + void setSize(Size size) const; + + /** + * Sets position type of Yoga node (relative, absolute). + */ + void setPositionType(YGPositionType positionType) const; + #pragma mark - LayoutableShadowNode void cleanLayout() override; diff --git a/ReactCommon/fabric/core/primitives/RawProps.h b/ReactCommon/fabric/core/primitives/RawProps.h index 0e1b52c11..6112e6abe 100644 --- a/ReactCommon/fabric/core/primitives/RawProps.h +++ b/ReactCommon/fabric/core/primitives/RawProps.h @@ -75,7 +75,7 @@ class RawProps { /* * Returns a const unowning pointer to `RawValue` of a prop with a given name. - * Returns `nullptr`, it a prop with the given name does not exist. + * Returns `nullptr` if a prop with the given name does not exist. */ const RawValue *at(const std::string &name) const noexcept { auto iterator = map_.find(name); diff --git a/ReactCommon/fabric/core/propsConversions.h b/ReactCommon/fabric/core/propsConversions.h index 003d9ab64..7ec739133 100644 --- a/ReactCommon/fabric/core/propsConversions.h +++ b/ReactCommon/fabric/core/propsConversions.h @@ -57,8 +57,8 @@ T convertRawProp( return sourceValue; } - // Special case: `null` always means `the prop was removed, use default - // value`. + // Special case: `null` always means "the prop was removed, use default + // value". if (!rawValue->hasValue()) { return defaultValue; }