Files
react-native/ReactCommon/fabric/components/text/paragraph/ParagraphProps.cpp
T
David Vacca 81d6357be1 Add textBreakStrategy as part of ParagraphAttributes object
Summary:
This diff exposes textBreakStrategy as part of ParagraphAttributes. This is necessary to support the textBreakStrategy prop into Text for Android

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D18101404

fbshipit-source-id: e7b665cefe48cf8c764f73a1c51eede16245d1ec
2019-10-24 19:55:15 -07:00

76 lines
2.4 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 "ParagraphProps.h"
#include "../../../attributedstring/primitives.h"
#include <react/attributedstring/conversions.h>
#include <react/core/propsConversions.h>
#include <react/debug/debugStringConvertibleUtils.h>
#include <Glog/logging.h>
namespace facebook {
namespace react {
static ParagraphAttributes convertRawProp(
RawProps const &rawProps,
ParagraphAttributes const &defaultParagraphAttributes) {
auto paragraphAttributes = ParagraphAttributes{};
paragraphAttributes.maximumNumberOfLines = convertRawProp(
rawProps,
"numberOfLines",
defaultParagraphAttributes.maximumNumberOfLines);
paragraphAttributes.ellipsizeMode = convertRawProp(
rawProps, "ellipsizeMode", defaultParagraphAttributes.ellipsizeMode);
paragraphAttributes.textBreakStrategy = convertRawProp(
rawProps,
"textBreakStrategy",
defaultParagraphAttributes.textBreakStrategy);
paragraphAttributes.adjustsFontSizeToFit = convertRawProp(
rawProps,
"adjustsFontSizeToFit",
defaultParagraphAttributes.adjustsFontSizeToFit);
paragraphAttributes.minimumFontSize = convertRawProp(
rawProps,
"minimumFontSize",
defaultParagraphAttributes.minimumFontSize,
std::numeric_limits<Float>::quiet_NaN());
paragraphAttributes.maximumFontSize = convertRawProp(
rawProps,
"maximumFontSize",
defaultParagraphAttributes.maximumFontSize,
std::numeric_limits<Float>::quiet_NaN());
return paragraphAttributes;
}
ParagraphProps::ParagraphProps(
ParagraphProps const &sourceProps,
RawProps const &rawProps)
: ViewProps(sourceProps, rawProps),
BaseTextProps(sourceProps, rawProps),
paragraphAttributes(
convertRawProp(rawProps, sourceProps.paragraphAttributes)),
isSelectable(
convertRawProp(rawProps, "selectable", sourceProps.isSelectable)){};
#pragma mark - DebugStringConvertible
#if RN_DEBUG_STRING_CONVERTIBLE
SharedDebugStringConvertibleList ParagraphProps::getDebugProps() const {
return ViewProps::getDebugProps() + BaseTextProps::getDebugProps() +
paragraphAttributes.getDebugProps() +
SharedDebugStringConvertibleList{
debugStringConvertibleItem("isSelectable", isSelectable)};
}
#endif
} // namespace react
} // namespace facebook