Skip to content

Commit 94d2e0a

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Add selectionColor paragraph prop (facebook#52847)
Summary: Pull Request resolved: facebook#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
1 parent 5e80759 commit 94d2e0a

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/HostPlatformParagraphProps.cpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <react/featureflags/ReactNativeFeatureFlags.h>
1111
#include <react/renderer/attributedstring/conversions.h>
1212
#include <react/renderer/attributedstring/primitives.h>
13+
#include <react/renderer/core/graphicsConversions.h>
1314
#include <react/renderer/core/propsConversions.h>
1415
#include <react/renderer/debug/debugStringConvertibleUtils.h>
1516

@@ -30,7 +31,16 @@ HostPlatformParagraphProps::HostPlatformParagraphProps(
3031
rawProps,
3132
"disabled",
3233
sourceProps.disabled,
33-
false)){};
34+
false)),
35+
selectionColor(
36+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
37+
? sourceProps.selectionColor
38+
: convertRawProp(
39+
context,
40+
rawProps,
41+
"selectionColor",
42+
sourceProps.selectionColor,
43+
{})){};
3444

3545
void HostPlatformParagraphProps::setProp(
3646
const PropsParserContext& context,
@@ -44,7 +54,10 @@ void HostPlatformParagraphProps::setProp(
4454

4555
static auto defaults = HostPlatformParagraphProps{};
4656

47-
switch (hash) { RAW_SET_PROP_SWITCH_CASE_BASIC(disabled); }
57+
switch (hash) {
58+
RAW_SET_PROP_SWITCH_CASE_BASIC(disabled);
59+
RAW_SET_PROP_SWITCH_CASE_BASIC(selectionColor);
60+
}
4861
}
4962

5063
#pragma mark - DebugStringConvertible
@@ -54,7 +67,8 @@ SharedDebugStringConvertibleList HostPlatformParagraphProps::getDebugProps()
5467
const {
5568
return BaseParagraphProps::getDebugProps() +
5669
SharedDebugStringConvertibleList{
57-
debugStringConvertibleItem("disabled", disabled)};
70+
debugStringConvertibleItem("disabled", disabled),
71+
debugStringConvertibleItem("selectionColor", selectionColor)};
5872
}
5973
#endif
6074

@@ -147,6 +161,14 @@ folly::dynamic HostPlatformParagraphProps::getDiffProps(
147161
result["disabled"] = disabled;
148162
}
149163

164+
if (selectionColor != oldProps->selectionColor) {
165+
if (selectionColor.has_value()) {
166+
result["selectionColor"] = *selectionColor.value();
167+
} else {
168+
result["selectionColor"] = folly::dynamic(nullptr);
169+
}
170+
}
171+
150172
return result;
151173
}
152174

packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/HostPlatformParagraphProps.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99

1010
#include <limits>
1111
#include <memory>
12+
#include <optional>
1213

1314
#include <react/renderer/components/text/BaseParagraphProps.h>
1415
#include <react/renderer/core/Props.h>
1516
#include <react/renderer/core/PropsParserContext.h>
17+
#include <react/renderer/graphics/Color.h>
1618

1719
namespace facebook::react {
1820

@@ -38,6 +40,7 @@ class HostPlatformParagraphProps : public BaseParagraphProps {
3840
#pragma mark - Props
3941

4042
bool disabled{false};
43+
std::optional<SharedColor> selectionColor{};
4144

4245
#pragma mark - DebugStringConvertible
4346

0 commit comments

Comments
 (0)