mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
4d35e4d92c
Summary: Even though it makes no sense to construct RootProps from RawProps, we need to support that (even if it's no-op) to be able to call this once from generic `ConcreteComponentDescriptor`. We will need it in the coming diff. Reviewed By: mdvacca Differential Revision: D15752970 fbshipit-source-id: b75a4023c5d0425a8dbe0f104a36a0f265eb6084
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "RootProps.h"
|
|
|
|
#include <react/components/view/YogaLayoutableShadowNode.h>
|
|
#include <react/components/view/conversions.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
static YGStyle yogaStyleFromLayoutConstraints(
|
|
LayoutConstraints const &layoutConstraints) {
|
|
auto yogaStyle = YGStyle{};
|
|
yogaStyle.minDimensions()[YGDimensionWidth] =
|
|
yogaStyleValueFromFloat(layoutConstraints.minimumSize.width);
|
|
yogaStyle.minDimensions()[YGDimensionHeight] =
|
|
yogaStyleValueFromFloat(layoutConstraints.minimumSize.height);
|
|
|
|
yogaStyle.maxDimensions()[YGDimensionWidth] =
|
|
yogaStyleValueFromFloat(layoutConstraints.maximumSize.width);
|
|
yogaStyle.maxDimensions()[YGDimensionHeight] =
|
|
yogaStyleValueFromFloat(layoutConstraints.maximumSize.height);
|
|
|
|
yogaStyle.direction() =
|
|
yogaDirectionFromLayoutDirection(layoutConstraints.layoutDirection);
|
|
|
|
return yogaStyle;
|
|
}
|
|
|
|
RootProps::RootProps(RootProps const &sourceProps, RawProps const &rawProps)
|
|
: ViewProps(sourceProps, rawProps) {}
|
|
|
|
RootProps::RootProps(
|
|
RootProps const &sourceProps,
|
|
LayoutConstraints const &layoutConstraints,
|
|
LayoutContext const &layoutContext)
|
|
: ViewProps(yogaStyleFromLayoutConstraints(layoutConstraints)),
|
|
layoutConstraints(layoutConstraints),
|
|
layoutContext(layoutContext){};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|