mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add selectionColor paragraph prop (#52847)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52847 Adding the missing Android Text selectionColor prop to the `ParagraphProps` to correctly support the prop with Props 2.0 Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D79023868 fbshipit-source-id: 10e04d438d9d118e6b80e8d8854e0bbb76b430ee
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5e80759994
commit
94d2e0a39b
+25
-3
@@ -10,6 +10,7 @@
|
||||
#include <react/featureflags/ReactNativeFeatureFlags.h>
|
||||
#include <react/renderer/attributedstring/conversions.h>
|
||||
#include <react/renderer/attributedstring/primitives.h>
|
||||
#include <react/renderer/core/graphicsConversions.h>
|
||||
#include <react/renderer/core/propsConversions.h>
|
||||
#include <react/renderer/debug/debugStringConvertibleUtils.h>
|
||||
|
||||
@@ -30,7 +31,16 @@ HostPlatformParagraphProps::HostPlatformParagraphProps(
|
||||
rawProps,
|
||||
"disabled",
|
||||
sourceProps.disabled,
|
||||
false)){};
|
||||
false)),
|
||||
selectionColor(
|
||||
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
||||
? sourceProps.selectionColor
|
||||
: convertRawProp(
|
||||
context,
|
||||
rawProps,
|
||||
"selectionColor",
|
||||
sourceProps.selectionColor,
|
||||
{})){};
|
||||
|
||||
void HostPlatformParagraphProps::setProp(
|
||||
const PropsParserContext& context,
|
||||
@@ -44,7 +54,10 @@ void HostPlatformParagraphProps::setProp(
|
||||
|
||||
static auto defaults = HostPlatformParagraphProps{};
|
||||
|
||||
switch (hash) { RAW_SET_PROP_SWITCH_CASE_BASIC(disabled); }
|
||||
switch (hash) {
|
||||
RAW_SET_PROP_SWITCH_CASE_BASIC(disabled);
|
||||
RAW_SET_PROP_SWITCH_CASE_BASIC(selectionColor);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - DebugStringConvertible
|
||||
@@ -54,7 +67,8 @@ SharedDebugStringConvertibleList HostPlatformParagraphProps::getDebugProps()
|
||||
const {
|
||||
return BaseParagraphProps::getDebugProps() +
|
||||
SharedDebugStringConvertibleList{
|
||||
debugStringConvertibleItem("disabled", disabled)};
|
||||
debugStringConvertibleItem("disabled", disabled),
|
||||
debugStringConvertibleItem("selectionColor", selectionColor)};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -147,6 +161,14 @@ folly::dynamic HostPlatformParagraphProps::getDiffProps(
|
||||
result["disabled"] = disabled;
|
||||
}
|
||||
|
||||
if (selectionColor != oldProps->selectionColor) {
|
||||
if (selectionColor.has_value()) {
|
||||
result["selectionColor"] = *selectionColor.value();
|
||||
} else {
|
||||
result["selectionColor"] = folly::dynamic(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -9,10 +9,12 @@
|
||||
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
#include <react/renderer/components/text/BaseParagraphProps.h>
|
||||
#include <react/renderer/core/Props.h>
|
||||
#include <react/renderer/core/PropsParserContext.h>
|
||||
#include <react/renderer/graphics/Color.h>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
@@ -38,6 +40,7 @@ class HostPlatformParagraphProps : public BaseParagraphProps {
|
||||
#pragma mark - Props
|
||||
|
||||
bool disabled{false};
|
||||
std::optional<SharedColor> selectionColor{};
|
||||
|
||||
#pragma mark - DebugStringConvertible
|
||||
|
||||
|
||||
Reference in New Issue
Block a user