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
This commit is contained in:
Dmitry Rykun 2024-11-20 06:34:35 -08:00 committed by Facebook GitHub Bot
parent 4dd8d3db57
commit d658ff521d
2 changed files with 77 additions and 0 deletions

View File

@ -35,6 +35,15 @@ ImageProps::ImageProps(
"defaultSource", "defaultSource",
sourceProps.defaultSource, sourceProps.defaultSource,
{})), {})),
loadingIndicatorSource(
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
? sourceProps.loadingIndicatorSource
: convertRawProp(
context,
rawProps,
"loadingIndicatorSource",
sourceProps.loadingIndicatorSource,
{})),
resizeMode( resizeMode(
ReactNativeFeatureFlags::enableCppPropsIteratorSetter() ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
? sourceProps.resizeMode ? sourceProps.resizeMode
@ -79,6 +88,60 @@ ImageProps::ImageProps(
rawProps, rawProps,
"internal_analyticTag", "internal_analyticTag",
sourceProps.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( void ImageProps::setProp(
@ -96,11 +159,18 @@ void ImageProps::setProp(
switch (hash) { switch (hash) {
RAW_SET_PROP_SWITCH_CASE(sources, "source"); RAW_SET_PROP_SWITCH_CASE(sources, "source");
RAW_SET_PROP_SWITCH_CASE(defaultSource, "defaultSource"); 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(resizeMode);
RAW_SET_PROP_SWITCH_CASE_BASIC(blurRadius); RAW_SET_PROP_SWITCH_CASE_BASIC(blurRadius);
RAW_SET_PROP_SWITCH_CASE_BASIC(capInsets); RAW_SET_PROP_SWITCH_CASE_BASIC(capInsets);
RAW_SET_PROP_SWITCH_CASE_BASIC(tintColor); RAW_SET_PROP_SWITCH_CASE_BASIC(tintColor);
RAW_SET_PROP_SWITCH_CASE_BASIC(internal_analyticTag); 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);
} }
} }

View File

@ -33,11 +33,18 @@ class ImageProps final : public ViewProps {
ImageSources sources{}; ImageSources sources{};
ImageSource defaultSource{}; ImageSource defaultSource{};
ImageSource loadingIndicatorSource{};
ImageResizeMode resizeMode{ImageResizeMode::Stretch}; ImageResizeMode resizeMode{ImageResizeMode::Stretch};
Float blurRadius{}; Float blurRadius{};
EdgeInsets capInsets{}; EdgeInsets capInsets{};
SharedColor tintColor{}; SharedColor tintColor{};
std::string internal_analyticTag{}; std::string internal_analyticTag{};
std::string resizeMethod{};
Float resizeMultiplier{};
bool shouldNotify{};
SharedColor overlayColor{};
Float fadeDuration{};
bool progressiveRenderingEnabled{};
}; };
} // namespace facebook::react } // namespace facebook::react