Skip to content
Draft
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
Expand Up @@ -63,25 +63,34 @@

maybeRestoreOpacity(layoutAnimation, newStyle);

auto rawProps =
std::make_shared<RawProps>(uiRuntime_, jsi::Value(uiRuntime_, newStyle));
auto frame = Frame(uiRuntime_, newStyle);

PropsParserContext propsParserContext{
layoutAnimation.finalView->surfaceId, *contextContainer_};
auto updateValues = UpdateValues(nullptr, frame);

Check failure on line 68 in packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp

View workflow job for this annotation

GitHub Actions / example-ios-build-check

no matching constructor for initialization of 'UpdateValues'

// has props that require cloning
if (newStyle.getPropertyNames(uiRuntime_).size(uiRuntime_) - frame.count >
0) {
auto rawProps = std::make_shared<RawProps>(
uiRuntime_, jsi::Value(uiRuntime_, newStyle));

PropsParserContext propsParserContext{
layoutAnimation.finalView->surfaceId, *contextContainer_};
#ifdef ANDROID
rawProps = std::make_shared<RawProps>(folly::dynamic::merge(
layoutAnimation.finalView->props->rawProps, (folly::dynamic)*rawProps));
rawProps = std::make_shared<RawProps>(folly::dynamic::merge(
layoutAnimation.finalView->props->rawProps, (folly::dynamic)*rawProps));
#endif
auto newProps =
getComponentDescriptorForShadowView(*layoutAnimation.finalView)
.cloneProps(
propsParserContext,
layoutAnimation.finalView->props,
std::move(*rawProps));
auto newProps =
getComponentDescriptorForShadowView(*layoutAnimation.finalView)
.cloneProps(
propsParserContext,
layoutAnimation.finalView->props,
std::move(*rawProps));
updateValues.newProps = newProps;
}

auto &updateMap =
surfaceManager.getUpdateMap(layoutAnimation.finalView->surfaceId);
updateMap.insert_or_assign(
tag, UpdateValues{newProps, Frame(uiRuntime_, newStyle)});
updateMap.insert_or_assign(tag, updateValues);

return layoutAnimation.finalView->surfaceId;
}
Expand Down Expand Up @@ -391,7 +400,9 @@
auto &layoutAnimation = layoutAnimationIt->second;

auto newView = std::make_shared<ShadowView>(*layoutAnimation.finalView);
newView->props = updateValues.newProps;
if (updateValues.newProps) {
newView->props = updateValues.newProps;
}
updateLayoutMetrics(newView->layoutMetrics, updateValues.frame);

mutations.push_back(ShadowViewMutation::UpdateMutation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,23 @@ struct Rect {

struct Frame {
std::optional<double> x, y, width, height;
int count = 0;
Frame(jsi::Runtime &runtime, const jsi::Object &newStyle) {
if (newStyle.hasProperty(runtime, "originX")) {
x = newStyle.getProperty(runtime, "originX").asNumber();
count++;
}
if (newStyle.hasProperty(runtime, "originY")) {
Copy link
Member

Choose a reason for hiding this comment

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

We should add early returns or use else if instead. Once this is done, we can just a boolean to store the information whether there is some custom style or not.

Suggested change
if (newStyle.hasProperty(runtime, "originY")) {
else if (newStyle.hasProperty(runtime, "originY")) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't, the purpose of this class is to aggregate non-props updates in layout animations. We need to parse all of them, and we need to count them all, so that we can calculate how many props updates are there in a given layout animation.

y = newStyle.getProperty(runtime, "originY").asNumber();
count++;
}
if (newStyle.hasProperty(runtime, "width")) {
width = newStyle.getProperty(runtime, "width").asNumber();
count++;
}
if (newStyle.hasProperty(runtime, "height")) {
height = newStyle.getProperty(runtime, "height").asNumber();
count++;
}
}
};
Expand Down
Loading