react-native-morph-card 0.1.4 → 0.1.5
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.
|
@@ -228,7 +228,8 @@ class MorphCardSourceView(context: Context) : ReactViewGroup(context) {
|
|
|
228
228
|
* Walk the view tree and hide any screen container that isn't already known.
|
|
229
229
|
* This catches modal screens added to separate ScreenStacks (e.g. transparentModal).
|
|
230
230
|
*/
|
|
231
|
-
private fun hideNewScreenContainers(root: ViewGroup, knownScreens: Set<View>) {
|
|
231
|
+
private fun hideNewScreenContainers(root: ViewGroup, knownScreens: Set<View>): Int {
|
|
232
|
+
var count = 0
|
|
232
233
|
fun walk(group: ViewGroup) {
|
|
233
234
|
val name = group.javaClass.name
|
|
234
235
|
if (name.contains("ScreenStack") || name.contains("ScreenContainer")) {
|
|
@@ -236,6 +237,7 @@ class MorphCardSourceView(context: Context) : ReactViewGroup(context) {
|
|
|
236
237
|
val child = group.getChildAt(i)
|
|
237
238
|
if (!knownScreens.contains(child) && child.visibility == View.VISIBLE) {
|
|
238
239
|
child.visibility = View.INVISIBLE
|
|
240
|
+
count++
|
|
239
241
|
Log.d(TAG, "preDraw: hid new screen ${child.javaClass.simpleName} in ${group.javaClass.simpleName}")
|
|
240
242
|
}
|
|
241
243
|
}
|
|
@@ -246,6 +248,7 @@ class MorphCardSourceView(context: Context) : ReactViewGroup(context) {
|
|
|
246
248
|
}
|
|
247
249
|
}
|
|
248
250
|
walk(root)
|
|
251
|
+
return count
|
|
249
252
|
}
|
|
250
253
|
|
|
251
254
|
/**
|
|
@@ -353,8 +356,16 @@ class MorphCardSourceView(context: Context) : ReactViewGroup(context) {
|
|
|
353
356
|
val knownScreens = collectExistingScreens(decorView)
|
|
354
357
|
Log.d(TAG, "prepareExpand: tracking ${knownScreens.size} existing screens")
|
|
355
358
|
val pdListener = ViewTreeObserver.OnPreDrawListener {
|
|
356
|
-
hideNewScreenContainers(decorView, knownScreens)
|
|
357
|
-
|
|
359
|
+
val hidCount = hideNewScreenContainers(decorView, knownScreens)
|
|
360
|
+
if (hidCount > 0) {
|
|
361
|
+
// Cancel this draw frame — the new screen was visible and we just hid it.
|
|
362
|
+
// Returning false prevents this frame from rendering, so the screen
|
|
363
|
+
// is never shown. The next frame will re-check and proceed.
|
|
364
|
+
Log.d(TAG, "preDraw: cancelled draw frame (hid $hidCount screens)")
|
|
365
|
+
false
|
|
366
|
+
} else {
|
|
367
|
+
true
|
|
368
|
+
}
|
|
358
369
|
}
|
|
359
370
|
decorView.viewTreeObserver.addOnPreDrawListener(pdListener)
|
|
360
371
|
preDrawListener = pdListener
|
|
@@ -366,11 +377,10 @@ class MorphCardSourceView(context: Context) : ReactViewGroup(context) {
|
|
|
366
377
|
// being visible. We use PixelCopy to capture the current screen with
|
|
367
378
|
// hardware rendering preserved (clipToOutline, borderRadius, etc.).
|
|
368
379
|
val fullScreenOverlay = FrameLayout(context)
|
|
369
|
-
fullScreenOverlay.layoutParams = FrameLayout.LayoutParams(
|
|
370
|
-
FrameLayout.LayoutParams.MATCH_PARENT,
|
|
371
|
-
FrameLayout.LayoutParams.MATCH_PARENT
|
|
372
|
-
)
|
|
380
|
+
fullScreenOverlay.layoutParams = FrameLayout.LayoutParams(decorView.width, decorView.height)
|
|
373
381
|
fullScreenOverlay.isClickable = true
|
|
382
|
+
// Ensure the overlay renders above any views with elevation (e.g. ScreenStack children)
|
|
383
|
+
fullScreenOverlay.translationZ = 1000f
|
|
374
384
|
|
|
375
385
|
// PixelCopy captures from the surface (hardware-rendered, preserves outlines).
|
|
376
386
|
// We use a background HandlerThread for the callback to avoid deadlocking main.
|
|
@@ -382,9 +392,7 @@ class MorphCardSourceView(context: Context) : ReactViewGroup(context) {
|
|
|
382
392
|
val copyHandler = Handler(copyThread.looper)
|
|
383
393
|
val latch = java.util.concurrent.CountDownLatch(1)
|
|
384
394
|
android.view.PixelCopy.request(window, blockerBitmap, { result ->
|
|
385
|
-
|
|
386
|
-
Log.d(TAG, "prepareExpand: PixelCopy failed with result=$result")
|
|
387
|
-
}
|
|
395
|
+
Log.d(TAG, "prepareExpand: PixelCopy result=$result (0=SUCCESS)")
|
|
388
396
|
latch.countDown()
|
|
389
397
|
}, copyHandler)
|
|
390
398
|
// Wait for the copy (typically <5ms)
|
package/package.json
CHANGED