From d658ff521ddcfd7e8add9df8b31c6f4a1a02664a Mon Sep 17 00:00:00 2001 From: Dmitry Rykun Date: Wed, 20 Nov 2024 06:34:35 -0800 Subject: [PATCH] Add missing Android-only props to ImageProps (#47719) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47719 There is a subset of `ImageProps` that are used by Android but not used by iOS. They were missing in the `ImageProps.h`. It was fine when they were only consumed by the Android mounting layer. But it becomes a problem if we want to write some shared C++ code based on those props. This diff adds those props to the corresponding C++ type. This should have no practical effect for both platforms. Changelog: [Internal] Reviewed By: javache Differential Revision: D65426569 fbshipit-source-id: dc1c9fe4a6e0e62e62f84b9b249e1c7d253290f5 --- .../renderer/components/image/ImageProps.cpp | 70 +++++++++++++++++++ .../renderer/components/image/ImageProps.h | 7 ++ 2 files changed, 77 insertions(+) diff --git a/packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.cpp index 23f56d8670d..ecfa39dfb16 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.cpp @@ -35,6 +35,15 @@ ImageProps::ImageProps( "defaultSource", sourceProps.defaultSource, {})), + loadingIndicatorSource( + ReactNativeFeatureFlags::enableCppPropsIteratorSetter() + ? sourceProps.loadingIndicatorSource + : convertRawProp( + context, + rawProps, + "loadingIndicatorSource", + sourceProps.loadingIndicatorSource, + {})), resizeMode( ReactNativeFeatureFlags::enableCppPropsIteratorSetter() ? sourceProps.resizeMode @@ -79,6 +88,60 @@ ImageProps::ImageProps( rawProps, "internal_analyticTag", sourceProps.internal_analyticTag, + {})), + resizeMethod( + ReactNativeFeatureFlags::enableCppPropsIteratorSetter() + ? sourceProps.internal_analyticTag + : convertRawProp( + context, + rawProps, + "resizeMethod", + sourceProps.internal_analyticTag, + {})), + resizeMultiplier( + ReactNativeFeatureFlags::enableCppPropsIteratorSetter() + ? sourceProps.resizeMultiplier + : convertRawProp( + context, + rawProps, + "resizeMultiplier", + sourceProps.resizeMultiplier, + {})), + shouldNotify( + ReactNativeFeatureFlags::enableCppPropsIteratorSetter() + ? sourceProps.shouldNotify + : convertRawProp( + context, + rawProps, + "shouldNotify", + sourceProps.shouldNotify, + {})), + overlayColor( + ReactNativeFeatureFlags::enableCppPropsIteratorSetter() + ? sourceProps.overlayColor + : convertRawProp( + context, + rawProps, + "overlayColor", + sourceProps.overlayColor, + {})), + fadeDuration( + ReactNativeFeatureFlags::enableCppPropsIteratorSetter() + ? sourceProps.fadeDuration + : convertRawProp( + context, + rawProps, + "fadeDuration", + sourceProps.fadeDuration, + {})), + progressiveRenderingEnabled( + ReactNativeFeatureFlags::enableCppPropsIteratorSetter() + ? sourceProps.progressiveRenderingEnabled + : convertRawProp( + context, + rawProps, + "progressiveRenderingEnabled", + sourceProps.progressiveRenderingEnabled, {})) {} void ImageProps::setProp( @@ -96,11 +159,18 @@ void ImageProps::setProp( switch (hash) { RAW_SET_PROP_SWITCH_CASE(sources, "source"); RAW_SET_PROP_SWITCH_CASE(defaultSource, "defaultSource"); + RAW_SET_PROP_SWITCH_CASE(loadingIndicatorSource, "loadingIndicatorSource"); RAW_SET_PROP_SWITCH_CASE_BASIC(resizeMode); RAW_SET_PROP_SWITCH_CASE_BASIC(blurRadius); RAW_SET_PROP_SWITCH_CASE_BASIC(capInsets); RAW_SET_PROP_SWITCH_CASE_BASIC(tintColor); RAW_SET_PROP_SWITCH_CASE_BASIC(internal_analyticTag); + RAW_SET_PROP_SWITCH_CASE_BASIC(resizeMethod); + RAW_SET_PROP_SWITCH_CASE_BASIC(resizeMultiplier); + RAW_SET_PROP_SWITCH_CASE_BASIC(shouldNotify); + RAW_SET_PROP_SWITCH_CASE_BASIC(overlayColor); + RAW_SET_PROP_SWITCH_CASE_BASIC(fadeDuration); + RAW_SET_PROP_SWITCH_CASE_BASIC(progressiveRenderingEnabled); } } diff --git a/packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.h b/packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.h index b58b5d290b5..61e1f46f958 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.h +++ b/packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.h @@ -33,11 +33,18 @@ class ImageProps final : public ViewProps { ImageSources sources{}; ImageSource defaultSource{}; + ImageSource loadingIndicatorSource{}; ImageResizeMode resizeMode{ImageResizeMode::Stretch}; Float blurRadius{}; EdgeInsets capInsets{}; SharedColor tintColor{}; std::string internal_analyticTag{}; + std::string resizeMethod{}; + Float resizeMultiplier{}; + bool shouldNotify{}; + SharedColor overlayColor{}; + Float fadeDuration{}; + bool progressiveRenderingEnabled{}; }; } // namespace facebook::react