Valentin Shergin 9d21e6661a Fabric: New props treatment in attributedstring module
Summary:
Adopting template-generated `convertRawProp` and `debugStringConvertibleItem` functions in `attributedstring` module.
Note, to do so we have to change signatures of some conversions functions to make them more overloading-friendly.

Reviewed By: fkgozali

Differential Revision: D7958245

fbshipit-source-id: 275a58bd3955a6ceb4881bffff86bf1d4501b3d2
2018-05-14 16:03:49 -07:00

80 lines
2.2 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.
*/
#pragma once
#include <limits>
#include <fabric/attributedstring/primitives.h>
#include <fabric/core/LayoutPrimitives.h>
#include <fabric/core/ReactPrimitives.h>
#include <fabric/debug/DebugStringConvertible.h>
#include <fabric/graphics/Color.h>
#include <fabric/graphics/Geometry.h>
#include <folly/Optional.h>
namespace facebook {
namespace react {
class TextAttributes;
using SharedTextAttributes = std::shared_ptr<const TextAttributes>;
class TextAttributes:
public DebugStringConvertible {
public:
#pragma mark - Fields
// Color
SharedColor foregroundColor {nullptr};
SharedColor backgroundColor {nullptr};
Float opacity {std::numeric_limits<Float>::quiet_NaN()};
// Font
std::string fontFamily {""};
Float fontSize {std::numeric_limits<Float>::quiet_NaN()};
Float fontSizeMultiplier {std::numeric_limits<Float>::quiet_NaN()};
folly::Optional<FontWeight> fontWeight {};
folly::Optional<FontStyle> fontStyle {};
folly::Optional<FontVariant> fontVariant {};
folly::Optional<bool> allowFontScaling {};
Float letterSpacing {std::numeric_limits<Float>::quiet_NaN()};
// Paragraph Styles
Float lineHeight {std::numeric_limits<Float>::quiet_NaN()};
folly::Optional<TextAlignment> alignment {};
folly::Optional<WritingDirection> baseWritingDirection {};
// Decoration
SharedColor textDecorationColor {nullptr};
folly::Optional<TextDecorationLineType> textDecorationLineType {};
folly::Optional<TextDecorationLineStyle> textDecorationLineStyle {};
folly::Optional<TextDecorationLinePattern> textDecorationLinePattern {};
// Shadow
folly::Optional<Point> textShadowOffset {};
Float textShadowRadius {std::numeric_limits<Float>::quiet_NaN()};
SharedColor textShadowColor {nullptr};
// Special
folly::Optional<bool> isHighlighted {};
folly::Optional<LayoutDirection> layoutDirection {};
#pragma mark - Operations
void apply(TextAttributes textAttributes);
#pragma mark - DebugStringConvertible
SharedDebugStringConvertibleList getDebugProps() const override;
};
} // namespace react
} // namespace facebook