react-native-reanimated 3.12.0-set-experimental → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/Common/cpp/Fabric/ShadowTreeCloner.cpp +8 -6
  2. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +0 -5
  3. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +0 -1
  4. package/android/build.gradle +7 -0
  5. package/android/src/main/cpp/AndroidUIScheduler.cpp +3 -3
  6. package/android/src/main/cpp/AndroidUIScheduler.h +1 -1
  7. package/android/src/main/cpp/LayoutAnimations.cpp +0 -16
  8. package/android/src/main/cpp/LayoutAnimations.h +0 -4
  9. package/android/src/main/cpp/NativeProxy.cpp +0 -10
  10. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +2 -10
  11. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +0 -2
  12. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +0 -2
  13. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +0 -26
  14. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +26 -189
  15. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +0 -30
  16. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +2 -12
  17. package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +0 -8
  18. package/android/src/reactNativeVersionPatch/ReactHost/72/com/swmansion/reanimated/DevMenuUtils.java +18 -0
  19. package/android/src/reactNativeVersionPatch/ReactHost/latest/com/swmansion/reanimated/DevMenuUtils.java +34 -0
  20. package/apple/LayoutReanimation/REAAnimationsManager.h +0 -5
  21. package/apple/LayoutReanimation/REAAnimationsManager.m +2 -31
  22. package/apple/LayoutReanimation/REAScreensHelper.h +0 -7
  23. package/apple/LayoutReanimation/REAScreensHelper.m +4 -125
  24. package/apple/LayoutReanimation/REASharedTransitionManager.h +0 -6
  25. package/apple/LayoutReanimation/REASharedTransitionManager.m +59 -419
  26. package/apple/LayoutReanimation/REASwizzledUIManager.mm +0 -13
  27. package/apple/native/NativeProxy.mm +0 -12
  28. package/lib/module/reanimated2/Colors.js +70 -18
  29. package/lib/module/reanimated2/Colors.js.map +1 -1
  30. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  31. package/lib/module/reanimated2/hook/index.js +1 -0
  32. package/lib/module/reanimated2/hook/index.js.map +1 -1
  33. package/lib/module/reanimated2/hook/useComposedEventHandler.js +52 -0
  34. package/lib/module/reanimated2/hook/useComposedEventHandler.js.map +1 -0
  35. package/lib/module/reanimated2/hook/useScrollViewOffset.js +19 -30
  36. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  37. package/lib/module/reanimated2/index.js +1 -1
  38. package/lib/module/reanimated2/index.js.map +1 -1
  39. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +1 -1
  40. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  41. package/lib/module/reanimated2/layoutReanimation/web/animationParser.js +0 -22
  42. package/lib/module/reanimated2/layoutReanimation/web/animationParser.js.map +1 -1
  43. package/lib/module/reanimated2/layoutReanimation/web/animationsManager.js +12 -22
  44. package/lib/module/reanimated2/layoutReanimation/web/animationsManager.js.map +1 -1
  45. package/lib/module/reanimated2/layoutReanimation/web/componentUtils.js +4 -31
  46. package/lib/module/reanimated2/layoutReanimation/web/componentUtils.js.map +1 -1
  47. package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js +7 -47
  48. package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js.map +1 -1
  49. package/lib/module/reanimated2/platform-specific/jsVersion.js +1 -1
  50. package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -1
  51. package/lib/typescript/reanimated2/Colors.d.ts +1 -0
  52. package/lib/typescript/reanimated2/component/FlatList.d.ts +4 -0
  53. package/lib/typescript/reanimated2/hook/index.d.ts +1 -0
  54. package/lib/typescript/reanimated2/hook/useComposedEventHandler.d.ts +11 -0
  55. package/lib/typescript/reanimated2/hook/useScrollViewOffset.d.ts +1 -1
  56. package/lib/typescript/reanimated2/index.d.ts +1 -1
  57. package/lib/typescript/reanimated2/layoutReanimation/web/animationParser.d.ts +0 -2
  58. package/lib/typescript/reanimated2/layoutReanimation/web/componentUtils.d.ts +2 -5
  59. package/lib/typescript/reanimated2/layoutReanimation/web/createAnimation.d.ts +2 -11
  60. package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
  61. package/package.json +3 -3
  62. package/src/reanimated2/Colors.ts +96 -15
  63. package/src/reanimated2/component/FlatList.tsx +4 -0
  64. package/src/reanimated2/hook/index.ts +1 -0
  65. package/src/reanimated2/hook/useComposedEventHandler.ts +80 -0
  66. package/src/reanimated2/hook/useScrollViewOffset.ts +25 -44
  67. package/src/reanimated2/index.ts +1 -0
  68. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +1 -1
  69. package/src/reanimated2/layoutReanimation/web/animationParser.ts +0 -32
  70. package/src/reanimated2/layoutReanimation/web/animationsManager.ts +11 -37
  71. package/src/reanimated2/layoutReanimation/web/componentUtils.ts +4 -41
  72. package/src/reanimated2/layoutReanimation/web/createAnimation.ts +19 -86
  73. package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
  74. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/TabNavigatorObserver.java +0 -112
@@ -26,7 +26,10 @@ ShadowNode::Unshared cloneShadowTreeWithNewProps(
26
26
  const auto props = source->getComponentDescriptor().cloneProps(
27
27
  propsParserContext, source->getProps(), std::move(rawProps));
28
28
 
29
- auto newChildNode = source->clone({/* .props = */ props, ShadowNodeFragment::childrenPlaceholder(), source->getState()});
29
+ auto newChildNode = source->clone(
30
+ {/* .props = */ props,
31
+ ShadowNodeFragment::childrenPlaceholder(),
32
+ source->getState()});
30
33
 
31
34
  for (auto it = ancestors.rbegin(); it != ancestors.rend(); ++it) {
32
35
  auto &parentNode = it->first.get();
@@ -50,11 +53,10 @@ ShadowNode::Unshared cloneShadowTreeWithNewProps(
50
53
 
51
54
  children[childIndex] = newChildNode;
52
55
 
53
- newChildNode = parentNode.clone({
54
- ShadowNodeFragment::propsPlaceholder(),
55
- std::make_shared<ShadowNode::ListOfShared>(children),
56
- parentNode.getState()
57
- });
56
+ newChildNode = parentNode.clone(
57
+ {ShadowNodeFragment::propsPlaceholder(),
58
+ std::make_shared<ShadowNode::ListOfShared>(children),
59
+ parentNode.getState()});
58
60
  }
59
61
 
60
62
  return std::const_pointer_cast<ShadowNode>(newChildNode);
@@ -159,11 +159,6 @@ int LayoutAnimationsManager::findPrecedingViewTagForTransition(const int tag) {
159
159
  return -1;
160
160
  }
161
161
 
162
- const std::vector<int> LayoutAnimationsManager::getSharedGroup(const int tag) {
163
- auto const &groupName = viewTagToSharedTag_[tag];
164
- return sharedTransitionGroups_[groupName];
165
- }
166
-
167
162
  #ifndef NDEBUG
168
163
  std::string LayoutAnimationsManager::getScreenSharedTagPairString(
169
164
  const int screenTag,
@@ -43,7 +43,6 @@ class LayoutAnimationsManager {
43
43
  void clearSharedTransitionConfig(const int tag);
44
44
  void cancelLayoutAnimation(jsi::Runtime &rt, const int tag) const;
45
45
  int findPrecedingViewTagForTransition(const int tag);
46
- const std::vector<int> getSharedGroup(const int tag);
47
46
  #ifndef NDEBUG
48
47
  std::string getScreenSharedTagPairString(
49
48
  const int screenTag,
@@ -366,6 +366,13 @@ android {
366
366
  srcDirs += "src/reactNativeVersionPatch/ReanimatedUIManager/latest"
367
367
  }
368
368
 
369
+ // ReactHost
370
+ if (REACT_NATIVE_MINOR_VERSION <= 72) {
371
+ srcDirs += "src/reactNativeVersionPatch/ReactHost/72"
372
+ } else {
373
+ srcDirs += "src/reactNativeVersionPatch/ReactHost/latest"
374
+ }
375
+
369
376
  // ReactFeatureFlags
370
377
  if (IS_NEW_ARCHITECTURE_ENABLED) {
371
378
  if (REACT_NATIVE_MINOR_VERSION <= 72) {
@@ -34,7 +34,7 @@ class UISchedulerWrapper : public UIScheduler {
34
34
 
35
35
  AndroidUIScheduler::AndroidUIScheduler(
36
36
  jni::alias_ref<AndroidUIScheduler::javaobject> jThis)
37
- : javaPart_(jni::make_weak(jThis)),
37
+ : javaPart_(jni::make_global(jThis)),
38
38
  uiScheduler_(
39
39
  std::make_shared<UISchedulerWrapper>(jni::make_global(jThis))) {}
40
40
 
@@ -49,8 +49,8 @@ void AndroidUIScheduler::triggerUI() {
49
49
 
50
50
  void AndroidUIScheduler::scheduleTriggerOnUI() {
51
51
  static const auto method =
52
- javaPart_.lockLocal()->getClass()->getMethod<void()>("scheduleTriggerOnUI");
53
- method(javaPart_.lockLocal());
52
+ javaPart_->getClass()->getMethod<void()>("scheduleTriggerOnUI");
53
+ method(javaPart_.get());
54
54
  }
55
55
 
56
56
  void AndroidUIScheduler::registerNatives() {
@@ -33,7 +33,7 @@ class AndroidUIScheduler : public jni::HybridClass<AndroidUIScheduler> {
33
33
 
34
34
  void triggerUI();
35
35
 
36
- jni::weak_ref<AndroidUIScheduler::javaobject> javaPart_;
36
+ jni::global_ref<AndroidUIScheduler::javaobject> javaPart_;
37
37
  std::shared_ptr<UIScheduler> uiScheduler_;
38
38
 
39
39
  explicit AndroidUIScheduler(
@@ -100,23 +100,10 @@ void LayoutAnimations::setFindPrecedingViewTagForTransition(
100
100
  findPrecedingViewTagForTransitionBlock;
101
101
  }
102
102
 
103
- void LayoutAnimations::setGetSharedGroupBlock(GetSharedGroupBlock getSharedGroupBlock) {
104
- getSharedGroupBlock_ = getSharedGroupBlock;
105
- }
106
-
107
103
  int LayoutAnimations::findPrecedingViewTagForTransition(int tag) {
108
104
  return findPrecedingViewTagForTransitionBlock_(tag);
109
105
  }
110
106
 
111
- jni::local_ref<JArrayInt> LayoutAnimations::getSharedGroup(int tag) {
112
- std::vector<int> group = getSharedGroupBlock_(tag);
113
- auto jGroup = JArrayInt::newArray(group.size());
114
- for (int i = 0; i < group.size(); i++) {
115
- jGroup->setRegion(0, group.size(), group.data());
116
- }
117
- return jGroup;
118
- }
119
-
120
107
  void LayoutAnimations::registerNatives() {
121
108
  registerHybrid({
122
109
  makeNativeMethod("initHybrid", LayoutAnimations::initHybrid),
@@ -137,9 +124,6 @@ void LayoutAnimations::registerNatives() {
137
124
  makeNativeMethod(
138
125
  "findPrecedingViewTagForTransition",
139
126
  LayoutAnimations::findPrecedingViewTagForTransition),
140
- makeNativeMethod(
141
- "getSharedGroup",
142
- LayoutAnimations::getSharedGroup),
143
127
  #ifndef NDEBUG
144
128
  makeNativeMethod(
145
129
  "checkDuplicateSharedTag", LayoutAnimations::checkDuplicateSharedTag),
@@ -22,7 +22,6 @@ class LayoutAnimations : public jni::HybridClass<LayoutAnimations> {
22
22
  using ClearAnimationConfigBlock = std::function<void(int)>;
23
23
  using CancelAnimationBlock = std::function<void(int)>;
24
24
  using FindPrecedingViewTagForTransitionBlock = std::function<int(int)>;
25
- using GetSharedGroupBlock = std::function<std::vector<int>(int)>;
26
25
 
27
26
  public:
28
27
  static auto constexpr kJavaDescriptor =
@@ -54,7 +53,6 @@ class LayoutAnimations : public jni::HybridClass<LayoutAnimations> {
54
53
  void setFindPrecedingViewTagForTransition(
55
54
  FindPrecedingViewTagForTransitionBlock
56
55
  findPrecedingViewTagForTransitionBlock);
57
- void setGetSharedGroupBlock(GetSharedGroupBlock getSharedGroupBlock);
58
56
 
59
57
  void progressLayoutAnimation(
60
58
  int tag,
@@ -64,7 +62,6 @@ class LayoutAnimations : public jni::HybridClass<LayoutAnimations> {
64
62
  void clearAnimationConfigForTag(int tag);
65
63
  void cancelAnimationForTag(int tag);
66
64
  int findPrecedingViewTagForTransition(int tag);
67
- jni::local_ref<JArrayInt> getSharedGroup(int tag);
68
65
 
69
66
  private:
70
67
  friend HybridBase;
@@ -76,7 +73,6 @@ class LayoutAnimations : public jni::HybridClass<LayoutAnimations> {
76
73
  CancelAnimationBlock cancelAnimationBlock_;
77
74
  FindPrecedingViewTagForTransitionBlock
78
75
  findPrecedingViewTagForTransitionBlock_;
79
- GetSharedGroupBlock getSharedGroupBlock_;
80
76
  #ifndef NDEBUG
81
77
  CheckDuplicateSharedTag checkDuplicateSharedTag_;
82
78
  #endif
@@ -652,16 +652,6 @@ void NativeProxy::setupLayoutAnimations() {
652
652
  return -1;
653
653
  }
654
654
  });
655
-
656
- layoutAnimations_->cthis()->setGetSharedGroupBlock(
657
- [weakNativeReanimatedModule](int tag) -> std::vector<int> {
658
- if (auto nativeReanimatedModule = weakNativeReanimatedModule.lock()) {
659
- return nativeReanimatedModule->layoutAnimationsManager()
660
- .getSharedGroup(tag);
661
- } else {
662
- return {};
663
- }
664
- });
665
655
  }
666
656
 
667
657
  } // namespace reanimated
@@ -494,7 +494,7 @@ public class AnimationsManager implements ViewHierarchyObserver {
494
494
  }
495
495
 
496
496
  public boolean hasAnimationForTag(int tag, int type) {
497
- return mNativeMethodsHolder != null && mNativeMethodsHolder.hasAnimation(tag, type);
497
+ return mNativeMethodsHolder.hasAnimation(tag, type);
498
498
  }
499
499
 
500
500
  public boolean isLayoutAnimationEnabled() {
@@ -680,7 +680,7 @@ public class AnimationsManager implements ViewHierarchyObserver {
680
680
  }
681
681
  }
682
682
 
683
- protected View resolveView(int tag) {
683
+ private View resolveView(int tag) {
684
684
  if (mExitingViews.containsKey(tag)) {
685
685
  return mExitingViews.get(tag);
686
686
  } else {
@@ -718,14 +718,6 @@ public class AnimationsManager implements ViewHierarchyObserver {
718
718
  mSharedTransitionManager.screenDidLayout(view);
719
719
  }
720
720
 
721
- public void navigationTabChanged(View previousTab, View newTab) {
722
- mSharedTransitionManager.navigationTabChanged(previousTab, newTab);
723
- }
724
-
725
- public void visitNativeTreeAndMakeSnapshot(View view) {
726
- mSharedTransitionManager.visitNativeTreeAndMakeSnapshot(view);
727
- }
728
-
729
721
  public void viewDidLayout(View view) {
730
722
  mSharedTransitionManager.viewDidLayout(view);
731
723
  }
@@ -52,8 +52,6 @@ public class LayoutAnimations {
52
52
 
53
53
  public native int findPrecedingViewTagForTransition(int tag);
54
54
 
55
- public native int[] getSharedGroup(int tag);
56
-
57
55
  private void endLayoutAnimation(int tag, boolean removeView) {
58
56
  AnimationsManager animationsManager = getAnimationsManager();
59
57
  if (animationsManager == null) {
@@ -18,6 +18,4 @@ public interface NativeMethodsHolder {
18
18
  int findPrecedingViewTagForTransition(int tag);
19
19
 
20
20
  void checkDuplicateSharedTag(int viewTag, int screenTag);
21
-
22
- int[] getSharedGroup(int viewTag);
23
21
  }
@@ -1,19 +1,10 @@
1
1
  package com.swmansion.reanimated.layoutReanimation;
2
2
 
3
- import android.content.Context;
4
3
  import android.os.Build;
5
4
  import android.util.Log;
6
5
  import android.view.View;
7
6
  import android.view.ViewGroup;
8
-
9
- import androidx.annotation.NonNull;
10
7
  import androidx.annotation.Nullable;
11
- import androidx.fragment.app.Fragment;
12
- import androidx.fragment.app.FragmentManager;
13
- import androidx.lifecycle.Lifecycle;
14
- import androidx.lifecycle.LifecycleObserver;
15
- import androidx.lifecycle.OnLifecycleEvent;
16
-
17
8
  import com.facebook.react.bridge.ReactApplicationContext;
18
9
  import com.facebook.react.bridge.ReactContext;
19
10
  import com.facebook.react.bridge.UiThreadUtil;
@@ -30,15 +21,10 @@ import com.facebook.react.uimanager.layoutanimation.LayoutAnimationListener;
30
21
  import com.swmansion.reanimated.ReanimatedModule;
31
22
  import java.lang.ref.WeakReference;
32
23
  import java.lang.reflect.Field;
33
- import java.lang.reflect.InvocationTargetException;
34
- import java.lang.reflect.Method;
35
24
  import java.lang.reflect.Modifier;
36
25
  import java.util.ArrayList;
37
- import java.util.Arrays;
38
26
  import java.util.HashMap;
39
27
  import java.util.HashSet;
40
- import java.util.List;
41
- import java.util.Map;
42
28
  import java.util.Set;
43
29
 
44
30
  class ReaLayoutAnimator extends LayoutAnimationController {
@@ -228,14 +214,12 @@ public class ReanimatedNativeHierarchyManager extends NativeViewHierarchyManager
228
214
  private final ReaLayoutAnimator mReaLayoutAnimator;
229
215
  private final HashMap<Integer, Set<Integer>> mPendingDeletionsForTag = new HashMap<>();
230
216
  private boolean initOk = true;
231
- private final TabNavigatorObserver tabNavigatorObserver;
232
217
 
233
218
  public ReanimatedNativeHierarchyManager(
234
219
  ViewManagerRegistry viewManagers, ReactApplicationContext reactContext) {
235
220
  super(viewManagers);
236
221
 
237
222
  mReaLayoutAnimator = new ReaLayoutAnimator(reactContext, this);
238
- tabNavigatorObserver = new TabNavigatorObserver(mReaLayoutAnimator);
239
223
 
240
224
  Class<?> clazz = this.getClass().getSuperclass();
241
225
  if (clazz == null) {
@@ -309,14 +293,6 @@ public class ReanimatedNativeHierarchyManager extends NativeViewHierarchyManager
309
293
  if (!hasHeader || !container.isLayoutRequested()) {
310
294
  mReaLayoutAnimator.getAnimationsManager().screenDidLayout(container);
311
295
  }
312
- View screen = resolveView(tag);
313
- View screenFragmentManager = (View) screen.getParent();
314
- if (screenFragmentManager != null) {
315
- View screenHolder = (View) screenFragmentManager.getParent();
316
- if (screenHolder.getClass().getSimpleName().equals("ScreenContainer")) {
317
- tabNavigatorObserver.handleScreenContainerUpdate(screen);
318
- }
319
- }
320
296
  }
321
297
  View view = resolveView(tag);
322
298
  if (view != null && mReaLayoutAnimator != null) {
@@ -325,8 +301,6 @@ public class ReanimatedNativeHierarchyManager extends NativeViewHierarchyManager
325
301
  } catch (IllegalViewOperationException e) {
326
302
  // (IllegalViewOperationException) == (vm == null)
327
303
  e.printStackTrace();
328
- } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
329
- throw new RuntimeException(e);
330
304
  }
331
305
  }
332
306
 
@@ -5,9 +5,6 @@ import android.util.Log;
5
5
  import android.view.View;
6
6
  import android.view.ViewGroup;
7
7
  import android.view.ViewParent;
8
-
9
- import androidx.fragment.app.Fragment;
10
-
11
8
  import com.facebook.react.bridge.ReactContext;
12
9
  import com.facebook.react.uimanager.IllegalViewOperationException;
13
10
  import com.facebook.react.uimanager.PixelUtil;
@@ -19,9 +16,6 @@ import com.facebook.react.uimanager.events.EventDispatcher;
19
16
  import com.facebook.react.uimanager.events.EventDispatcherListener;
20
17
  import com.facebook.react.views.view.ReactViewGroup;
21
18
  import com.swmansion.reanimated.Utils;
22
-
23
- import java.lang.reflect.InvocationTargetException;
24
- import java.lang.reflect.Method;
25
19
  import java.util.ArrayList;
26
20
  import java.util.Collections;
27
21
  import java.util.HashMap;
@@ -271,29 +265,17 @@ public class SharedTransitionManager {
271
265
  mNativeMethodsHolder.findPrecedingViewTagForTransition(sharedView.getId());
272
266
  }
273
267
  }
274
-
275
268
  boolean bothAreRemoved = !addedNewScreen && viewTags.contains(targetViewTag);
276
269
  if (targetViewTag < 0) {
277
270
  continue;
278
271
  }
279
-
280
- View siblingView = null;
281
- try {
282
- siblingView = reanimatedNativeHierarchyManager.resolveView(targetViewTag);
283
- } catch (IllegalViewOperationException e){
284
- // TODO: figure out why this happens
285
- continue;
286
- }
287
-
288
- siblingView = tabNavigatorWorkaround(sharedView, siblingView);
289
-
290
272
  View viewSource, viewTarget;
291
273
  if (addedNewScreen) {
292
- viewSource = siblingView;
274
+ viewSource = reanimatedNativeHierarchyManager.resolveView(targetViewTag);
293
275
  viewTarget = sharedView;
294
276
  } else {
295
277
  viewSource = sharedView;
296
- viewTarget = siblingView;
278
+ viewTarget = reanimatedNativeHierarchyManager.resolveView(targetViewTag);
297
279
  }
298
280
  if (bothAreRemoved) {
299
281
  // case for nested stack
@@ -311,41 +293,33 @@ public class SharedTransitionManager {
311
293
  continue;
312
294
  }
313
295
 
314
- ViewGroup sourceStack = (ViewGroup) findStack(viewSourceScreen);
315
- if (sourceStack == null) {
296
+ ViewGroup stack = (ViewGroup) findStack(viewSourceScreen);
297
+ if (stack == null) {
316
298
  continue;
317
299
  }
318
- int stackId = sourceStack.getId();
319
- ViewGroupManager stackViewManager = (ViewGroupManager)reanimatedNativeHierarchyManager.resolveViewManager(stackId);
320
- boolean isInSameStack = false;
321
- for (int i = 0; i < stackViewManager.getChildCount(sourceStack); i++) {
322
- if (stackViewManager.getChildAt(sourceStack, i) == viewTargetScreen) {
323
- isInSameStack = true;
324
- }
300
+
301
+ ViewGroupManager stackViewGroupManager =
302
+ (ViewGroupManager) reanimatedNativeHierarchyManager.resolveViewManager(stack.getId());
303
+ int screensCount = stackViewGroupManager.getChildCount(stack);
304
+
305
+ if (screensCount < 2) {
306
+ continue;
325
307
  }
326
- if (isInSameStack) {
327
- ViewGroupManager stackViewGroupManager =
328
- (ViewGroupManager) reanimatedNativeHierarchyManager.resolveViewManager(sourceStack.getId());
329
- int screensCount = stackViewGroupManager.getChildCount(sourceStack);
330
- if (screensCount < 2) {
331
- continue;
332
- }
333
308
 
334
- View topScreen = stackViewGroupManager.getChildAt(sourceStack, screensCount - 1);
335
- View secondScreen = stackViewGroupManager.getChildAt(sourceStack, screensCount - 2);
336
- boolean isValidConfiguration;
337
- if (addedNewScreen) {
338
- isValidConfiguration =
339
- secondScreen.getId() == viewSourceScreen.getId()
340
- && topScreen.getId() == viewTargetScreen.getId();
341
- } else {
342
- isValidConfiguration =
343
- topScreen.getId() == viewSourceScreen.getId()
344
- && secondScreen.getId() == viewTargetScreen.getId();
345
- }
346
- if (!isValidConfiguration) {
347
- continue;
348
- }
309
+ View topScreen = stackViewGroupManager.getChildAt(stack, screensCount - 1);
310
+ View secondScreen = stackViewGroupManager.getChildAt(stack, screensCount - 2);
311
+ boolean isValidConfiguration;
312
+ if (addedNewScreen) {
313
+ isValidConfiguration =
314
+ secondScreen.getId() == viewSourceScreen.getId()
315
+ && topScreen.getId() == viewTargetScreen.getId();
316
+ } else {
317
+ isValidConfiguration =
318
+ topScreen.getId() == viewSourceScreen.getId()
319
+ && secondScreen.getId() == viewTargetScreen.getId();
320
+ }
321
+ if (!isValidConfiguration) {
322
+ continue;
349
323
  }
350
324
  }
351
325
 
@@ -366,7 +340,7 @@ public class SharedTransitionManager {
366
340
  }
367
341
  Snapshot targetViewSnapshot = mSnapshotRegistry.get(viewTarget.getId());
368
342
  if (targetViewSnapshot == null) {
369
- makeSnapshot(viewTarget);
343
+ continue;
370
344
  }
371
345
 
372
346
  newTransitionViews.add(viewSource);
@@ -405,57 +379,6 @@ public class SharedTransitionManager {
405
379
  return sharedElements;
406
380
  }
407
381
 
408
- View tabNavigatorWorkaround(View sharedView, View siblingView) {
409
- View maybeTabNavigatorForSharedView = getTabNavigator(sharedView);
410
-
411
- if (maybeTabNavigatorForSharedView == null) {
412
- return siblingView;
413
- }
414
-
415
- int siblingTag = siblingView.getId();
416
- int[] sharedGroup = mNativeMethodsHolder.getSharedGroup(sharedView.getId());
417
- int siblingIndex = -1;
418
- for (int i = 0; i < sharedGroup.length; i++) {
419
- if (sharedGroup[i] == siblingTag) {
420
- siblingIndex = i;
421
- }
422
- }
423
-
424
- for (int i = siblingIndex; i >= 0; i--) {
425
- int viewTag = sharedGroup[i];
426
- View view = mAnimationsManager.resolveView(viewTag);
427
- if (maybeTabNavigatorForSharedView == getTabNavigator(view)) {
428
- return view;
429
- }
430
- }
431
-
432
- return siblingView;
433
- }
434
-
435
- View getTabNavigator(View view) {
436
- View currentView = view;
437
- while (currentView != null) {
438
- if (currentView.getClass().getSimpleName().equals("ScreenContainer")) {
439
- return currentView;
440
- }
441
- if (currentView.getClass().getSimpleName().equals("Screen")
442
- && currentView.getParent() != null
443
- && currentView.getParent().getClass().getSimpleName().equals("ScreensCoordinatorLayout")) {
444
- View screen = currentView;
445
- Class<?> screenClass = screen.getClass();
446
- try {
447
- Method getContainer = screenClass.getMethod("getContainer");
448
- currentView = (View)getContainer.invoke(screen);
449
- } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ignored) {}
450
- } else if (currentView.getParent() instanceof View) {
451
- currentView = (View) currentView.getParent();
452
- } else {
453
- break;
454
- }
455
- }
456
- return null;
457
- }
458
-
459
382
  private void setupTransitionContainer() {
460
383
  if (mTransitionContainer == null) {
461
384
  ReactContext context = mAnimationsManager.getContext();
@@ -717,14 +640,6 @@ public class SharedTransitionManager {
717
640
  }
718
641
 
719
642
  void visitNativeTreeAndMakeSnapshot(View view) {
720
- if (view.getClass().getSimpleName().equals("ScreenStack")) {
721
- View screen = view;
722
- Class<?> screenClass = screen.getClass();
723
- try {
724
- Method getTopScreen = screenClass.getMethod("getTopScreen");
725
- view = (View)getTopScreen.invoke(screen);
726
- } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ignored) {}
727
- }
728
643
  if (!(view instanceof ViewGroup)) {
729
644
  return;
730
645
  }
@@ -781,82 +696,4 @@ public class SharedTransitionManager {
781
696
  }
782
697
  }
783
698
  }
784
-
785
- public void navigationTabChanged(View previousTab, View newTab) {
786
- mAddedSharedViews.clear();
787
- List<SharedElement> sharedElements = new ArrayList<>();
788
- List<View> sharedViews = new ArrayList<>();
789
- findSharedViewsForScreen(previousTab, sharedViews);
790
- sortViewsByTags(sharedViews);
791
- for (View sharedView : sharedViews) {
792
- int[] sharedGroup = mNativeMethodsHolder.getSharedGroup(sharedView.getId());
793
- for (int i = sharedGroup.length - 1; i >= 0; i--) {
794
- View targetView = mAnimationsManager.resolveView(sharedGroup[i]);
795
- if (isChildOfScreen(targetView, newTab)) {
796
- Snapshot sourceViewSnapshot = mSnapshotRegistry.get(sharedView.getId());
797
- if (sourceViewSnapshot == null) {
798
- continue;
799
- }
800
- SharedElement sharedElement = new SharedElement(
801
- sharedView,
802
- sourceViewSnapshot,
803
- targetView,
804
- new Snapshot(targetView)
805
- );
806
- sharedElements.add(sharedElement);
807
- break;
808
- }
809
- }
810
- }
811
- if (sharedElements.isEmpty()) {
812
- return;
813
- }
814
- mSharedElements = sharedElements;
815
- mSharedElementsWithAnimation.clear();
816
- for (SharedElement sharedElement : sharedElements) {
817
- mSharedElementsLookup.put(sharedElement.sourceView.getId(), sharedElement);
818
- mSharedElementsWithAnimation.add(sharedElement);
819
- }
820
- setupTransitionContainer();
821
- reparentSharedViewsForCurrentTransition(sharedElements);
822
- startSharedTransition(mSharedElementsWithAnimation, LayoutAnimations.Types.SHARED_ELEMENT_TRANSITION);
823
- }
824
-
825
- private void findSharedViewsForScreen(View view, List<View> sharedViews) {
826
- if (view.getClass().getSimpleName().equals("ScreenStack")) {
827
- View screen = view;
828
- Class<?> screenClass = screen.getClass();
829
- try {
830
- Method getTopScreen = screenClass.getMethod("getTopScreen");
831
- view = (View)getTopScreen.invoke(screen);
832
- } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ignored) {}
833
- }
834
- if (!(view instanceof ViewGroup)) {
835
- return;
836
- }
837
- ViewGroup viewGroup = (ViewGroup) view;
838
- if (mAnimationsManager.hasAnimationForTag(
839
- view.getId(), LayoutAnimations.Types.SHARED_ELEMENT_TRANSITION)) {
840
- sharedViews.add(view);
841
- }
842
- for (int i = 0; i < viewGroup.getChildCount(); i++) {
843
- View child = viewGroup.getChildAt(i);
844
- findSharedViewsForScreen(child, sharedViews);
845
- }
846
- }
847
-
848
- private boolean isChildOfScreen(View view, View screen) {
849
- View currentView = view;
850
- while (currentView != null) {
851
- if (currentView == screen) {
852
- return true;
853
- }
854
- if (!(currentView.getParent() instanceof View)) {
855
- return false;
856
- }
857
- currentView = (View) currentView.getParent();
858
- }
859
- return false;
860
- }
861
-
862
699
  }
@@ -6,9 +6,6 @@ import com.facebook.react.uimanager.IllegalViewOperationException;
6
6
  import com.facebook.react.uimanager.NativeViewHierarchyManager;
7
7
  import com.facebook.react.uimanager.ViewManager;
8
8
  import com.swmansion.reanimated.ReactNativeUtils;
9
-
10
- import java.lang.reflect.InvocationTargetException;
11
- import java.lang.reflect.Method;
12
9
  import java.util.ArrayList;
13
10
  import java.util.Arrays;
14
11
  import java.util.HashMap;
@@ -120,36 +117,9 @@ public class Snapshot {
120
117
  borderRadii = new ReactNativeUtils.BorderRadii(0, 0, 0, 0, 0);
121
118
  }
122
119
 
123
- private int[] tryToFixLocation(View view) {
124
- int[] location = new int[2];
125
- View currentView = view;
126
- while (currentView != null) {
127
- location[0] += currentView.getX();
128
- location[1] += currentView.getY();
129
- if (currentView.getParent() != null
130
- && currentView.getParent().getClass().getSimpleName().equals("ScreensCoordinatorLayout")
131
- && currentView.getClass().getSimpleName().equals("Screen")) {
132
- View screen = currentView;
133
- Class<?> screenClass = screen.getClass();
134
- try {
135
- Method getContainer = screenClass.getMethod("getContainer");
136
- currentView = (View)getContainer.invoke(screen);
137
- } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ignored) {}
138
- } else if (currentView.getParent() instanceof View) {
139
- currentView = (View) currentView.getParent();
140
- } else {
141
- break;
142
- }
143
- }
144
- return location;
145
- }
146
-
147
120
  public Snapshot(View view) {
148
121
  int[] location = new int[2];
149
122
  view.getLocationOnScreen(location);
150
- if (location[0] == 0 && location[1] == 0) {
151
- location = tryToFixLocation(view);
152
- }
153
123
  originX = location[0];
154
124
  originY = location[1];
155
125
  width = view.getWidth();
@@ -6,17 +6,16 @@ import android.provider.Settings;
6
6
  import android.util.Log;
7
7
  import com.facebook.jni.HybridData;
8
8
  import com.facebook.proguard.annotations.DoNotStrip;
9
- import com.facebook.react.ReactApplication;
10
9
  import com.facebook.react.bridge.NativeModule;
11
10
  import com.facebook.react.bridge.ReactApplicationContext;
12
11
  import com.facebook.react.bridge.ReadableArray;
13
12
  import com.facebook.react.bridge.ReadableMap;
14
13
  import com.facebook.react.bridge.ReadableNativeArray;
15
- import com.facebook.react.devsupport.interfaces.DevSupportManager;
16
14
  import com.facebook.soloader.SoLoader;
17
15
  import com.swmansion.common.GestureHandlerStateManager;
18
16
  import com.swmansion.reanimated.AndroidUIScheduler;
19
17
  import com.swmansion.reanimated.BuildConfig;
18
+ import com.swmansion.reanimated.DevMenuUtils;
20
19
  import com.swmansion.reanimated.NativeProxy;
21
20
  import com.swmansion.reanimated.NodesManager;
22
21
  import com.swmansion.reanimated.ReanimatedModule;
@@ -83,16 +82,7 @@ public abstract class NativeProxyCommon {
83
82
 
84
83
  private void addDevMenuOption() {
85
84
  // In Expo, `ApplicationContext` is not an instance of `ReactApplication`
86
- if (mContext.get().getApplicationContext() instanceof ReactApplication) {
87
- final DevSupportManager devSupportManager =
88
- ((ReactApplication) mContext.get().getApplicationContext())
89
- .getReactNativeHost()
90
- .getReactInstanceManager()
91
- .getDevSupportManager();
92
-
93
- devSupportManager.addCustomDevOption(
94
- "Toggle slow animations (Reanimated)", this::toggleSlowAnimations);
95
- }
85
+ DevMenuUtils.addDevMenuOption(mContext.get(), this::toggleSlowAnimations);
96
86
  }
97
87
 
98
88
  @DoNotStrip