react-native-morph-card 0.1.3 → 0.1.4

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.
@@ -362,17 +362,45 @@ class MorphCardSourceView(context: Context) : ReactViewGroup(context) {
362
362
  // Capture snapshot
363
363
  val cardImage = captureSnapshot()
364
364
 
365
- // Create a full-screen overlay container that blocks the modal target screen
366
- // from being visible. We use a transparent overlay the source screen remains
367
- // visible underneath. The overlay just ensures our card wrapper is above everything.
365
+ // Create a full-screen overlay that blocks the modal target screen from
366
+ // being visible. We use PixelCopy to capture the current screen with
367
+ // hardware rendering preserved (clipToOutline, borderRadius, etc.).
368
368
  val fullScreenOverlay = FrameLayout(context)
369
369
  fullScreenOverlay.layoutParams = FrameLayout.LayoutParams(
370
370
  FrameLayout.LayoutParams.MATCH_PARENT,
371
371
  FrameLayout.LayoutParams.MATCH_PARENT
372
372
  )
373
- // Intercept all touches while overlay is up
374
373
  fullScreenOverlay.isClickable = true
375
374
 
375
+ // PixelCopy captures from the surface (hardware-rendered, preserves outlines).
376
+ // We use a background HandlerThread for the callback to avoid deadlocking main.
377
+ val window = (context as? android.app.Activity)?.window
378
+ if (window != null) {
379
+ val blockerBitmap = Bitmap.createBitmap(decorView.width, decorView.height, Bitmap.Config.ARGB_8888)
380
+ val copyThread = android.os.HandlerThread("PixelCopyThread")
381
+ copyThread.start()
382
+ val copyHandler = Handler(copyThread.looper)
383
+ val latch = java.util.concurrent.CountDownLatch(1)
384
+ android.view.PixelCopy.request(window, blockerBitmap, { result ->
385
+ if (result != android.view.PixelCopy.SUCCESS) {
386
+ Log.d(TAG, "prepareExpand: PixelCopy failed with result=$result")
387
+ }
388
+ latch.countDown()
389
+ }, copyHandler)
390
+ // Wait for the copy (typically <5ms)
391
+ try { latch.await(100, java.util.concurrent.TimeUnit.MILLISECONDS) } catch (_: Exception) {}
392
+ copyThread.quitSafely()
393
+
394
+ val blockerImg = ImageView(context)
395
+ blockerImg.setImageBitmap(blockerBitmap)
396
+ blockerImg.scaleType = ImageView.ScaleType.FIT_XY
397
+ blockerImg.layoutParams = FrameLayout.LayoutParams(
398
+ FrameLayout.LayoutParams.MATCH_PARENT,
399
+ FrameLayout.LayoutParams.MATCH_PARENT
400
+ )
401
+ fullScreenOverlay.addView(blockerImg)
402
+ }
403
+
376
404
  // Create card overlay at source position (on top of screen capture)
377
405
  val bgColor = cardBgColor
378
406
  val wrapper = FrameLayout(context)
@@ -526,11 +554,17 @@ class MorphCardSourceView(context: Context) : ReactViewGroup(context) {
526
554
  }
527
555
 
528
556
  // Crossfade: at 15% of animation, make target screen VISIBLE with alpha=0
529
- // then fade alpha to 1 over 50% of duration
557
+ // then fade alpha to 1 over 50% of duration. Also remove the blocker image.
530
558
  val targetScreen = targetScreenContainerRef?.get()
531
- val sourceScreen = sourceScreenContainerRef?.get()
532
- if (targetScreen != null && targetScreen !== sourceScreen) {
559
+ val sourceScreen2 = sourceScreenContainerRef?.get()
560
+ // Find the blocker image (first child of the full-screen overlay, before the card wrapper)
561
+ val blockerView = if (wrapper.childCount > 1) wrapper.getChildAt(0) else null
562
+ if (targetScreen != null && targetScreen !== sourceScreen2) {
533
563
  mainHandler.postDelayed({
564
+ // Remove blocker — source screen is visible underneath
565
+ if (blockerView != null && blockerView.tag != "morphCardWrapper") {
566
+ (blockerView.parent as? ViewGroup)?.removeView(blockerView)
567
+ }
534
568
  // Switch from INVISIBLE to VISIBLE but with alpha=0
535
569
  targetScreen.alpha = 0f
536
570
  targetScreen.visibility = View.VISIBLE
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-morph-card",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
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",