react-native-morph-card 0.1.8 → 0.1.10

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
- // 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
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 (blockerView != null) {
509
- wrapper.removeView(blockerView)
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
@@ -665,7 +681,7 @@ class MorphCardSourceView(context: Context) : ReactViewGroup(context) {
665
681
  target.width.toFloat(), target.height.toFloat())
666
682
  }
667
683
 
668
- target.showSnapshot(bitmap, ImageView.ScaleType.FIT_XY, frame, cornerRadius, cardBgColor)
684
+ target.showSnapshot(bitmap, ImageView.ScaleType.FIT_XY, frame, cornerRadius, null)
669
685
  Log.d(TAG, "transferSnapshot: handed snapshot to MorphCardTargetView")
670
686
  }
671
687
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-morph-card",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Native card-to-modal morph transition for React Native. iOS App Store-style expand animation.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",