Skip to content

Commit

Permalink
[skip ci] Add missing Android-only props to ImageProps (facebook#47719)
Browse files Browse the repository at this point in the history
Summary:

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
  • Loading branch information
dmytrorykun authored and facebook-github-bot committed Nov 20, 2024
1 parent c4f81e0 commit dc36a10
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit dc36a10

Please sign in to comment.