diff --git a/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/HostPlatformParagraphProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/HostPlatformParagraphProps.cpp index 4f151bf069a..a1019158f66 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/HostPlatformParagraphProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/HostPlatformParagraphProps.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -40,7 +41,18 @@ HostPlatformParagraphProps::HostPlatformParagraphProps( rawProps, "selectionColor", sourceProps.selectionColor, - {})){}; + {})), + dataDetectorType( + ReactNativeFeatureFlags::enableCppPropsIteratorSetter() + ? sourceProps.dataDetectorType + : convertRawProp( + context, + rawProps, + "dataDetectorType", + sourceProps.dataDetectorType, + {})) + + {}; void HostPlatformParagraphProps::setProp( const PropsParserContext& context, @@ -57,6 +69,7 @@ void HostPlatformParagraphProps::setProp( switch (hash) { RAW_SET_PROP_SWITCH_CASE_BASIC(disabled); RAW_SET_PROP_SWITCH_CASE_BASIC(selectionColor); + RAW_SET_PROP_SWITCH_CASE_BASIC(dataDetectorType); } } @@ -68,7 +81,8 @@ SharedDebugStringConvertibleList HostPlatformParagraphProps::getDebugProps() return BaseParagraphProps::getDebugProps() + SharedDebugStringConvertibleList{ debugStringConvertibleItem("disabled", disabled), - debugStringConvertibleItem("selectionColor", selectionColor)}; + debugStringConvertibleItem("selectionColor", selectionColor), + debugStringConvertibleItem("dataDetectorType", dataDetectorType)}; } #endif @@ -169,6 +183,14 @@ folly::dynamic HostPlatformParagraphProps::getDiffProps( } } + if (dataDetectorType != oldProps->dataDetectorType) { + if (dataDetectorType.has_value()) { + result["dataDetectorType"] = toString(dataDetectorType.value()); + } else { + result["dataDetectorType"] = folly::dynamic(nullptr); + } + } + return result; } diff --git a/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/HostPlatformParagraphProps.h b/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/HostPlatformParagraphProps.h index cc25bfc83a5..1082b822b3b 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/HostPlatformParagraphProps.h +++ b/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/HostPlatformParagraphProps.h @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -41,6 +42,7 @@ class HostPlatformParagraphProps : public BaseParagraphProps { bool disabled{false}; std::optional selectionColor{}; + std::optional dataDetectorType{}; #pragma mark - DebugStringConvertible diff --git a/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.cpp b/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.cpp index 00def60e86b..2e6417f970b 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.cpp @@ -7,7 +7,7 @@ #include "ParagraphState.h" -#include +#include #include #include diff --git a/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/conversions.h b/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/conversions.h new file mode 100644 index 00000000000..af246ab2b47 --- /dev/null +++ b/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/conversions.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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 +#include +#include +#include + +namespace facebook::react { + +inline void fromRawValue( + const PropsParserContext& /*context*/, + const RawValue& value, + DataDetectorType& result) { + auto string = static_cast(value); + if (string == "all") { + result = DataDetectorType::All; + } else if (string == "email") { + result = DataDetectorType::Email; + } else if (string == "link") { + result = DataDetectorType::Link; + } else if (string == "none") { + result = DataDetectorType::None; + } else if (string == "phoneNumber") { + result = DataDetectorType::PhoneNumber; + } else { + abort(); + } +} + +inline std::string toString(const DataDetectorType& value) { + switch (value) { + case DataDetectorType::All: + return "all"; + case DataDetectorType::Email: + return "email"; + case DataDetectorType::Link: + return "link"; + case DataDetectorType::None: + return "none"; + case DataDetectorType::PhoneNumber: + return "phoneNumber"; + } +} + +} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/primitives.h b/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/primitives.h new file mode 100644 index 00000000000..30f9bd623f5 --- /dev/null +++ b/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/primitives.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +namespace facebook::react { + +enum class DataDetectorType { + All, + Email, + Link, + None, + PhoneNumber, +}; + +} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/text/conversions.h b/packages/react-native/ReactCommon/react/renderer/components/text/stateConversions.h similarity index 100% rename from packages/react-native/ReactCommon/react/renderer/components/text/conversions.h rename to packages/react-native/ReactCommon/react/renderer/components/text/stateConversions.h