react-native-morph-card 0.1.6 → 0.1.8
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.
|
@@ -384,7 +384,10 @@ class MorphCardSourceView(context: Context) : ReactViewGroup(context) {
|
|
|
384
384
|
|
|
385
385
|
// PixelCopy captures from the surface (hardware-rendered, preserves outlines).
|
|
386
386
|
// We use a background HandlerThread for the callback to avoid deadlocking main.
|
|
387
|
-
|
|
387
|
+
// Note: context may be ThemedReactContext, not Activity directly.
|
|
388
|
+
val activity = (context as? android.app.Activity)
|
|
389
|
+
?: (context as? com.facebook.react.bridge.ReactContext)?.currentActivity
|
|
390
|
+
val window = activity?.window
|
|
388
391
|
if (window != null) {
|
|
389
392
|
val blockerBitmap = Bitmap.createBitmap(decorView.width, decorView.height, Bitmap.Config.ARGB_8888)
|
|
390
393
|
val copyThread = android.os.HandlerThread("PixelCopyThread")
|
|
@@ -494,6 +497,18 @@ class MorphCardSourceView(context: Context) : ReactViewGroup(context) {
|
|
|
494
497
|
// Stop intercepting new screens — animation is taking over
|
|
495
498
|
removeHierarchyListener()
|
|
496
499
|
|
|
500
|
+
// Remove the PixelCopy blocker bitmap — it was only needed to prevent the
|
|
501
|
+
// modal screen from flashing before it was hidden. Now that the target screen
|
|
502
|
+
// is INVISIBLE, the blocker would show a stale copy of the source card
|
|
503
|
+
// at the original position while the card wrapper animates away.
|
|
504
|
+
val blockerView = wrapper.findViewWithTag<FrameLayout>("morphCardWrapper")?.let { cardW ->
|
|
505
|
+
// The blocker is any child of the overlay that isn't the card wrapper
|
|
506
|
+
(0 until wrapper.childCount).map { wrapper.getChildAt(it) }.firstOrNull { it !== cardW }
|
|
507
|
+
}
|
|
508
|
+
if (blockerView != null) {
|
|
509
|
+
wrapper.removeView(blockerView)
|
|
510
|
+
}
|
|
511
|
+
|
|
497
512
|
// Read target position (now settled after delay)
|
|
498
513
|
val d = density
|
|
499
514
|
val targetLoc = if (targetView != null) getLocationInWindow(targetView) else intArrayOf(cardLeft.toInt(), cardTop.toInt())
|
|
@@ -562,17 +577,11 @@ class MorphCardSourceView(context: Context) : ReactViewGroup(context) {
|
|
|
562
577
|
}
|
|
563
578
|
|
|
564
579
|
// Crossfade: at 15% of animation, make target screen VISIBLE with alpha=0
|
|
565
|
-
// then fade alpha to 1 over 50% of duration.
|
|
580
|
+
// then fade alpha to 1 over 50% of duration.
|
|
566
581
|
val targetScreen = targetScreenContainerRef?.get()
|
|
567
582
|
val sourceScreen2 = sourceScreenContainerRef?.get()
|
|
568
|
-
// Find the blocker image (first child of the full-screen overlay, before the card wrapper)
|
|
569
|
-
val blockerView = if (wrapper.childCount > 1) wrapper.getChildAt(0) else null
|
|
570
583
|
if (targetScreen != null && targetScreen !== sourceScreen2) {
|
|
571
584
|
mainHandler.postDelayed({
|
|
572
|
-
// Remove blocker — source screen is visible underneath
|
|
573
|
-
if (blockerView != null && blockerView.tag != "morphCardWrapper") {
|
|
574
|
-
(blockerView.parent as? ViewGroup)?.removeView(blockerView)
|
|
575
|
-
}
|
|
576
585
|
// Switch from INVISIBLE to VISIBLE but with alpha=0
|
|
577
586
|
targetScreen.alpha = 0f
|
|
578
587
|
targetScreen.visibility = View.VISIBLE
|
package/package.json
CHANGED