Skip to content

Commit 79b928c

Browse files
bartlomiejbloniarzkasperski95
authored andcommitted
handle snapshots on iOS
1 parent 0646e4e commit 79b928c

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ std::optional<MountingTransaction> LayoutAnimationsProxy_Experimental::pullTrans
5757
ReanimatedSystraceSection s("find after elements");
5858
findSharedElementsOnScreen(afterTopScreen, AFTER, propsParserContext);
5959
#ifdef __APPLE__
60-
forceScreenSnapshot_(afterTopScreen->current.tag);
60+
// this is a temporary workaround for RNScreens on iOS, which takes
61+
// the snapshot of the popped screen before we hide the shared element,
62+
// the issue should be gone with the new stack implementation
63+
if (auto screen = findParentRNSScreen(afterTopScreen)) {
64+
forceScreenSnapshot_(screen->current.tag);
65+
}
6166
#endif
6267
}
6368
const bool hasScreenChanged = beforeTopScreen && afterTopScreen && beforeTopScreen != afterTopScreen;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ static inline bool isRNSScreen(const std::shared_ptr<LightNode> &node) {
135135
return !std::strcmp(componentName, "RNSScreen") || !std::strcmp(componentName, "RNSModalScreen");
136136
}
137137

138+
static inline std::shared_ptr<LightNode> findParentRNSScreen(const std::shared_ptr<LightNode> &node) {
139+
auto current = node->parent.lock();
140+
while (current && !isRNSScreen(current)) {
141+
current = current->parent.lock();
142+
}
143+
return current;
144+
}
145+
138146
static inline bool isSETBoundary(const std::shared_ptr<LightNode> &node) {
139147
return !std::strcmp(node->current.componentName, RNReanimatedSharedTransitionBoundaryComponentName);
140148
}

0 commit comments

Comments
 (0)