Files
react-native/ReactCommon/fabric/text/paragraph/ParagraphProps.cpp
Valentin Shergin d9ff1769aa Fabric/Text: <Paragraph> is now supporting text attributes
Summary:
I was shamed by Sebastian's sebmarkbage concerns (totally unrelated to this topic) about introducing another level of indirection into the system and decided to change my original plan not to support text attributes for the <Paragraph> component.

So, now <Paragraph> shares <View>, <Text> and <Paragraph> itself capabilities. That reduces the minimum amount of required components for trivial text fragment from three (Paragraph, Text, RawText) to two (Paragraph and RawText).

Special thanks for C++ for supporting multiple inheritance.

Reviewed By: mdvacca

Differential Revision: D7785889

fbshipit-source-id: dd9f2e2650bfbfd76d7d4b538adaf409f9429df3
2018-05-08 19:24:10 -07:00

65 lines
2.0 KiB
C++

/**
* 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.
*/
#include "ParagraphProps.h"
#include <fabric/attributedstring/textValuesConversions.h>
#include <fabric/core/propsConversions.h>
#include <fabric/debug/DebugStringConvertibleItem.h>
#include <fabric/text/propsConversions.h>
namespace facebook {
namespace react {
void ParagraphProps::apply(const RawProps &rawProps) {
ViewProps::apply(rawProps);
BaseTextProps::apply(rawProps);
// Paragraph Attributes
applyRawProp(rawProps, "numberOfLines", paragraphAttributes_.maximumNumberOfLines);
applyRawProp(rawProps, "ellipsizeMode", paragraphAttributes_.ellipsizeMode);
applyRawProp(rawProps, "adjustsFontSizeToFit", paragraphAttributes_.adjustsFontSizeToFit);
applyRawProp(rawProps, "minimumFontSize", paragraphAttributes_.minimumFontSize);
applyRawProp(rawProps, "maximumFontSize", paragraphAttributes_.maximumFontSize);
// Other Props
applyRawProp(rawProps, "selectable", isSelectable_);
}
#pragma mark - Getters
ParagraphAttributes ParagraphProps::getParagraphAttributes() const {
return paragraphAttributes_;
}
bool ParagraphProps::getIsSelectable() const {
return isSelectable_;
}
#pragma mark - DebugStringConvertible
SharedDebugStringConvertibleList ParagraphProps::getDebugProps() const {
SharedDebugStringConvertibleList list = {};
// View Props
auto &&viewPropsList = ViewProps::getDebugProps();
std::move(viewPropsList.begin(), viewPropsList.end(), std::back_inserter(list));
// Paragraph Props
auto &&paragraphAttributePropsList = paragraphAttributes_.getDebugProps();
std::move(paragraphAttributePropsList.begin(), paragraphAttributePropsList.end(), std::back_inserter(list));
// Base Text Props
auto &&baseTextPropsList = BaseTextProps::getDebugProps();
std::move(baseTextPropsList.begin(), baseTextPropsList.end(), std::back_inserter(list));
return list;
}
} // namespace react
} // namespace facebook