Skip to content

Commit a8df1ef

Browse files
authored
chore: Add 0.78.0-rc.3 support (#6934)
## Summary Adds if checks for the RN 0.78 in native code, thanks to which package builds on both - 0.78 nd 0.77. ## Checklist - [ ] Upgrade `react-native-screens` when 0.78 support is added (software-mansion/react-native-screens#2626) - [ ] Upgrade `react-native-svg` when 0.78 support is added (software-mansion/react-native-svg#2619) - [ ] Upgrade `react-native-gesture-handler` when 0.78 support is added (software-mansion/react-native-gesture-handler#3354) - [ ] `react-native-pager-view` auto generated schema contains invalid `StringEnumTypeAnnotation` fields and crashes build on Android || Fabric (iOS) | Fabric (Android) | Web | MacOS (not upgraded) | TVOS (not upgraded) | |-|-|-|-|-|-| | Builds | ✅ | ✅ | ✅ | ✅ | ✅ | | Runs | ❌ | ❌ | ❌ | ✅ | ✅ | *Apps where RN was upgraded don't run because of incompatible dependency versions
1 parent cbf65b8 commit a8df1ef

File tree

3 files changed

+69
-15
lines changed

3 files changed

+69
-15
lines changed

packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp

+57-14
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@ void LayoutAnimationsProxy::parseRemoveMutations(
153153
if (mutation.type == ShadowViewMutation::Remove) {
154154
updateIndexForMutation(mutation);
155155
auto tag = mutation.oldChildShadowView.tag;
156+
#if REACT_NATIVE_MINOR_VERSION >= 78
157+
auto parentTag = mutation.parentTag;
158+
#else
156159
auto parentTag = mutation.parentShadowView.tag;
160+
#endif // REACT_NATIVE_MINOR_VERSION >= 78
157161
auto unflattenedParentTag = parentTag; // temporary
158162

159163
std::shared_ptr<MutationNode> mutationNode;
@@ -287,17 +291,24 @@ void LayoutAnimationsProxy::handleUpdatesAndEnterings(
287291
}
288292
case ShadowViewMutation::Type::Insert: {
289293
updateIndexForMutation(mutation);
290-
if (nodeForTag_.contains(mutation.parentShadowView.tag)) {
291-
nodeForTag_[mutation.parentShadowView.tag]->applyMutationToIndices(
292-
mutation);
294+
295+
#if REACT_NATIVE_MINOR_VERSION >= 78
296+
const auto parentTag = mutation.parentTag;
297+
const auto mutationParent = parentTag;
298+
#else
299+
const auto parentTag = mutation.parentShadowView.tag;
300+
const auto mutationParent = mutation.parentShadowView;
301+
#endif // REACT_NATIVE_MINOR_VERSION >= 78
302+
if (nodeForTag_.contains(parentTag)) {
303+
nodeForTag_[parentTag]->applyMutationToIndices(mutation);
293304
}
294305

295306
if (movedViews.contains(tag)) {
296307
auto layoutAnimationIt = layoutAnimations_.find(tag);
297308
if (layoutAnimationIt == layoutAnimations_.end()) {
298309
if (oldShadowViewsForReparentings.contains(tag)) {
299310
filteredMutations.push_back(ShadowViewMutation::InsertMutation(
300-
mutation.parentShadowView,
311+
mutationParent,
301312
oldShadowViewsForReparentings[tag],
302313
mutation.index));
303314
} else {
@@ -308,7 +319,7 @@ void LayoutAnimationsProxy::handleUpdatesAndEnterings(
308319

309320
auto oldView = *layoutAnimationIt->second.currentView;
310321
filteredMutations.push_back(ShadowViewMutation::InsertMutation(
311-
mutation.parentShadowView, oldView, mutation.index));
322+
mutationParent, oldView, mutation.index));
312323
continue;
313324
}
314325

@@ -328,7 +339,7 @@ void LayoutAnimationsProxy::handleUpdatesAndEnterings(
328339
cloneViewWithoutOpacity(mutation, propsParserContext);
329340

330341
filteredMutations.push_back(ShadowViewMutation::UpdateMutation(
331-
mutation.newChildShadowView, *newView, mutation.parentShadowView));
342+
mutation.newChildShadowView, *newView, mutationParent));
332343
break;
333344
}
334345

@@ -386,7 +397,14 @@ void LayoutAnimationsProxy::addOngoingAnimations(
386397
updateLayoutMetrics(newView->layoutMetrics, updateValues.frame);
387398

388399
mutations.push_back(ShadowViewMutation::UpdateMutation(
389-
*layoutAnimation.currentView, *newView, *layoutAnimation.parentView));
400+
*layoutAnimation.currentView,
401+
*newView,
402+
#if REACT_NATIVE_MINOR_VERSION >= 78
403+
layoutAnimation.parentTag
404+
#else
405+
*layoutAnimation.parentView
406+
#endif // REACT_NATIVE_MINOR_VERSION >= 78
407+
));
390408
layoutAnimation.currentView = newView;
391409
}
392410
updateMap.clear();
@@ -549,12 +567,18 @@ void LayoutAnimationsProxy::updateIndexForMutation(
549567
if (mutation.index == -1) {
550568
return;
551569
}
552-
if (!nodeForTag_.contains(mutation.parentShadowView.tag)) {
570+
571+
#if REACT_NATIVE_MINOR_VERSION >= 78
572+
const auto parentTag = mutation.parentTag;
573+
#else
574+
const auto parentTag = mutation.parentShadowView.tag;
575+
#endif // REACT_NATIVE_MINOR_VERSION >= 78
576+
577+
if (!nodeForTag_.contains(parentTag)) {
553578
return;
554579
}
555580

556-
auto parent = nodeForTag_[mutation.parentShadowView.tag];
557-
581+
auto parent = nodeForTag_[parentTag];
558582
int size = 0, prevIndex = -1, offset = 0;
559583

560584
for (auto &subNode : parent->children) {
@@ -569,9 +593,8 @@ void LayoutAnimationsProxy::updateIndexForMutation(
569593
int tag = mutation.type == ShadowViewMutation::Insert
570594
? mutation.newChildShadowView.tag
571595
: mutation.oldChildShadowView.tag;
572-
LOG(INFO) << "update index for " << tag << " in "
573-
<< mutation.parentShadowView.tag << ": " << mutation.index << " -> "
574-
<< mutation.index + offset << std::endl;
596+
LOG(INFO) << "update index for " << tag << " in " << parentTag << ": "
597+
<< mutation.index << " -> " << mutation.index + offset << std::endl;
575598
#endif
576599
mutation.index += offset;
577600
}
@@ -599,9 +622,16 @@ void LayoutAnimationsProxy::createLayoutAnimation(
599622
? mutation.oldChildShadowView
600623
: mutation.newChildShadowView);
601624
auto currentView = std::make_shared<ShadowView>(oldView);
625+
626+
#if REACT_NATIVE_MINOR_VERSION >= 78
627+
layoutAnimations_.insert_or_assign(
628+
tag,
629+
LayoutAnimation{finalView, currentView, mutation.parentTag, {}, count});
630+
#else
602631
auto parentView = std::make_shared<ShadowView>(mutation.parentShadowView);
603632
layoutAnimations_.insert_or_assign(
604633
tag, LayoutAnimation{finalView, currentView, parentView, {}, count});
634+
#endif // REACT_NATIVE_MINOR_VERSION >= 78
605635
}
606636

607637
void LayoutAnimationsProxy::startEnteringAnimation(
@@ -612,7 +642,9 @@ void LayoutAnimationsProxy::startEnteringAnimation(
612642
#endif
613643
auto finalView = std::make_shared<ShadowView>(mutation.newChildShadowView);
614644
auto current = std::make_shared<ShadowView>(mutation.newChildShadowView);
645+
#if REACT_NATIVE_MINOR_VERSION < 78
615646
auto parent = std::make_shared<ShadowView>(mutation.parentShadowView);
647+
#endif
616648

617649
auto &viewProps =
618650
static_cast<const ViewProps &>(*mutation.newChildShadowView.props);
@@ -621,7 +653,9 @@ void LayoutAnimationsProxy::startEnteringAnimation(
621653
uiScheduler_->scheduleOnUI([weakThis = weak_from_this(),
622654
finalView,
623655
current,
656+
#if REACT_NATIVE_MINOR_VERSION < 78
624657
parent,
658+
#endif // REACT_NATIVE_MINOR_VERSION < 78
625659
mutation,
626660
opacity,
627661
tag]() {
@@ -635,7 +669,16 @@ void LayoutAnimationsProxy::startEnteringAnimation(
635669
auto &mutex = strongThis->mutex;
636670
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
637671
strongThis->layoutAnimations_.insert_or_assign(
638-
tag, LayoutAnimation{finalView, current, parent, opacity});
672+
tag,
673+
LayoutAnimation{
674+
finalView,
675+
current,
676+
#if REACT_NATIVE_MINOR_VERSION >= 78
677+
mutation.parentTag,
678+
#else
679+
parent,
680+
#endif // REACT_NATIVE_MINOR_VERSION >= 78
681+
opacity});
639682
window = strongThis->surfaceManager.getWindow(
640683
mutation.newChildShadowView.surfaceId);
641684
}

packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h

+5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ class ReanimatedModuleProxy;
2323
using namespace facebook;
2424

2525
struct LayoutAnimation {
26+
#if REACT_NATIVE_MINOR_VERSION >= 78
27+
std::shared_ptr<ShadowView> finalView, currentView;
28+
Tag parentTag;
29+
#else
2630
std::shared_ptr<ShadowView> finalView, currentView, parentView;
31+
#endif // REACT_NATIVE_MINOR_VERSION >= 78
2732
std::optional<double> opacity;
2833
int count = 1;
2934
LayoutAnimation &operator=(const LayoutAnimation &other) = default;

packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ Rect SurfaceManager::getWindow(SurfaceId surfaceId) {
3131
}
3232

3333
void Node::applyMutationToIndices(ShadowViewMutation mutation) {
34-
if (tag != mutation.parentShadowView.tag) {
34+
#if REACT_NATIVE_MINOR_VERSION >= 78
35+
const auto parentTag = mutation.parentTag;
36+
#else
37+
const auto parentTag = mutation.parentShadowView.tag;
38+
#endif // REACT_NATIVE_MINOR_VERSION >= 78
39+
40+
if (tag != parentTag) {
3541
return;
3642
}
3743

0 commit comments

Comments
 (0)