Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "extract shadow properties to baseComponentView",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,24 @@ void CompositionBaseComponentView::updateBorderProps(
}
}

void CompositionBaseComponentView::updateShadowProps(
const facebook::react::ViewProps &oldViewProps,
const facebook::react::ViewProps &newViewProps,
winrt::Microsoft::ReactNative::Composition::ISpriteVisual m_visual) noexcept {
// Shadow Properties
if (oldViewProps.shadowOffset != newViewProps.shadowOffset || oldViewProps.shadowColor != newViewProps.shadowColor ||
oldViewProps.shadowOpacity != newViewProps.shadowOpacity ||
oldViewProps.shadowRadius != newViewProps.shadowRadius) {
auto shadow = m_compContext.CreateDropShadow();
shadow.Offset({newViewProps.shadowOffset.width, newViewProps.shadowOffset.height, 0});
shadow.Opacity(newViewProps.shadowOpacity);
shadow.BlurRadius(newViewProps.shadowRadius);
if (newViewProps.shadowColor)
shadow.Color(newViewProps.shadowColor.AsWindowsColor());
m_visual.Shadow(shadow);
}
}

void CompositionBaseComponentView::updateAccessibilityProps(
const facebook::react::ViewProps &oldViewProps,
const facebook::react::ViewProps &newViewProps) noexcept {
Expand Down Expand Up @@ -1288,19 +1306,7 @@ void CompositionViewComponentView::updateProps(

updateAccessibilityProps(oldViewProps, newViewProps);
updateBorderProps(oldViewProps, newViewProps);

// Shadow
if (oldViewProps.shadowOffset != newViewProps.shadowOffset || oldViewProps.shadowColor != newViewProps.shadowColor ||
oldViewProps.shadowOpacity != newViewProps.shadowOpacity ||
oldViewProps.shadowRadius != newViewProps.shadowRadius) {
auto shadow = m_compContext.CreateDropShadow();
shadow.Offset({newViewProps.shadowOffset.width, newViewProps.shadowOffset.height, 0});
shadow.Opacity(newViewProps.shadowOpacity);
shadow.BlurRadius(newViewProps.shadowRadius);
if (newViewProps.shadowColor)
shadow.Color(newViewProps.shadowColor.AsWindowsColor());
m_visual.Shadow(shadow);
}
updateShadowProps(oldViewProps, newViewProps, m_visual);

if (oldViewProps.backfaceVisibility != newViewProps.backfaceVisibility) {
static_assert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ struct CompositionBaseComponentView : public IComponentView,
void updateBorderProps(
const facebook::react::ViewProps &oldViewProps,
const facebook::react::ViewProps &newViewProps) noexcept;
void updateShadowProps(
const facebook::react::ViewProps &oldViewProps,
const facebook::react::ViewProps &newViewProps,
winrt::Microsoft::ReactNative::Composition::ISpriteVisual m_visual) noexcept;
void updateAccessibilityProps(
const facebook::react::ViewProps &oldView,
const facebook::react::ViewProps &newViewProps) noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ void ImageComponentView::updateProps(

ensureVisual();

updateShadowProps(oldImageProps, newImageProps, m_visual);
updateBorderProps(oldImageProps, newImageProps);

if (oldImageProps.backgroundColor != newImageProps.backgroundColor ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void ParagraphComponentView::updateProps(
updateTextAlignment(newViewProps.textAttributes.alignment);
}

updateShadowProps(oldViewProps, newViewProps, m_visual);
updateAccessibilityProps(oldViewProps, newViewProps);
updateBorderProps(oldViewProps, newViewProps);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ void ScrollViewComponentView::updateProps(
}
*/

updateShadowProps(oldViewProps, newViewProps, m_visual);
updateBorderProps(oldViewProps, newViewProps);
m_props = std::static_pointer_cast<facebook::react::ViewProps const>(props);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct ScrollInteractionTrackerOwner : public winrt::implements<
void updateContentVisualSize() noexcept;

facebook::react::Size m_contentSize;
winrt::Microsoft::ReactNative::Composition::IVisual m_visual{nullptr};
winrt::Microsoft::ReactNative::Composition::ISpriteVisual m_visual{nullptr};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acoates-ms Every other component m_visual was a ISpriteVisual, so changed ScrollView's to match and it seemed to not affect anything on rnTester. Let me know if there was a reason for having this as a IVisual though and I can change it back!

winrt::Microsoft::ReactNative::Composition::IScrollVisual m_scrollVisual{nullptr};
winrt::Microsoft::ReactNative::Composition::IScrollVisual::ScrollPositionChanged_revoker
m_scrollPositionChangedRevoker{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void SwitchComponentView::updateProps(
m_drawingSurface = nullptr;
}

updateShadowProps(oldViewProps, newViewProps, m_visual);
updateBorderProps(oldViewProps, newViewProps);
m_props = std::static_pointer_cast<facebook::react::ViewProps const>(props);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ void WindowsTextInputComponentView::updateProps(

ensureVisual();

updateShadowProps(oldTextInputProps, newTextInputProps, m_visual);
updateBorderProps(oldTextInputProps, newTextInputProps);

if (!facebook::react::floatEquality(
Expand Down