react-native-morph-card 0.1.8 → 0.1.9
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.
|
@@ -7,6 +7,10 @@ import android.graphics.Canvas
|
|
|
7
7
|
import android.graphics.Color
|
|
8
8
|
import android.graphics.Outline
|
|
9
9
|
import android.graphics.RectF
|
|
10
|
+
import android.graphics.Paint
|
|
11
|
+
import android.graphics.PorterDuff
|
|
12
|
+
import android.graphics.PorterDuffXfermode
|
|
13
|
+
import android.graphics.drawable.BitmapDrawable
|
|
10
14
|
import android.graphics.drawable.ColorDrawable
|
|
11
15
|
import android.os.Handler
|
|
12
16
|
import android.os.Looper
|
|
@@ -497,16 +501,21 @@ class MorphCardSourceView(context: Context) : ReactViewGroup(context) {
|
|
|
497
501
|
// Stop intercepting new screens — animation is taking over
|
|
498
502
|
removeHierarchyListener()
|
|
499
503
|
|
|
500
|
-
//
|
|
501
|
-
//
|
|
502
|
-
//
|
|
503
|
-
|
|
504
|
-
val blockerView = wrapper.findViewWithTag<FrameLayout>("morphCardWrapper")?.let { cardW ->
|
|
505
|
-
// The blocker is any child of the overlay that isn't the card wrapper
|
|
504
|
+
// The PixelCopy blocker bitmap contains the source card at its original position.
|
|
505
|
+
// Clear the card area so the card wrapper animates without a duplicate underneath.
|
|
506
|
+
// We keep the blocker in place to prevent the target screen from flashing.
|
|
507
|
+
val blockerImg = wrapper.findViewWithTag<FrameLayout>("morphCardWrapper")?.let { cardW ->
|
|
506
508
|
(0 until wrapper.childCount).map { wrapper.getChildAt(it) }.firstOrNull { it !== cardW }
|
|
507
|
-
}
|
|
508
|
-
if (
|
|
509
|
-
|
|
509
|
+
} as? ImageView
|
|
510
|
+
if (blockerImg != null) {
|
|
511
|
+
val bmp = (blockerImg.drawable as? BitmapDrawable)?.bitmap
|
|
512
|
+
if (bmp != null) {
|
|
513
|
+
val clearCanvas = Canvas(bmp)
|
|
514
|
+
val clearPaint = Paint()
|
|
515
|
+
clearPaint.xfermode = PorterDuffXfermode(PorterDuff.Mode.CLEAR)
|
|
516
|
+
clearCanvas.drawRect(cardLeft, cardTop, cardLeft + cardWidth, cardTop + cardHeight, clearPaint)
|
|
517
|
+
blockerImg.invalidate()
|
|
518
|
+
}
|
|
510
519
|
}
|
|
511
520
|
|
|
512
521
|
// Read target position (now settled after delay)
|
|
@@ -582,6 +591,13 @@ class MorphCardSourceView(context: Context) : ReactViewGroup(context) {
|
|
|
582
591
|
val sourceScreen2 = sourceScreenContainerRef?.get()
|
|
583
592
|
if (targetScreen != null && targetScreen !== sourceScreen2) {
|
|
584
593
|
mainHandler.postDelayed({
|
|
594
|
+
// Remove the blocker so the target screen can fade in underneath the card wrapper
|
|
595
|
+
val blocker = wrapper.findViewWithTag<FrameLayout>("morphCardWrapper")?.let { cardW ->
|
|
596
|
+
(0 until wrapper.childCount).map { wrapper.getChildAt(it) }.firstOrNull { it !== cardW }
|
|
597
|
+
}
|
|
598
|
+
if (blocker != null) {
|
|
599
|
+
(blocker.parent as? ViewGroup)?.removeView(blocker)
|
|
600
|
+
}
|
|
585
601
|
// Switch from INVISIBLE to VISIBLE but with alpha=0
|
|
586
602
|
targetScreen.alpha = 0f
|
|
587
603
|
targetScreen.visibility = View.VISIBLE
|
package/package.json
CHANGED