@sbaiahmed1/react-native-blur 4.5.5-beta.4 → 4.5.5-beta.6

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.
@@ -188,10 +188,17 @@ class ReactNativeBlurView : BlurViewGroup {
188
188
 
189
189
  /**
190
190
  * Finds the optimal view to use as blur capture root.
191
- * Priority: nearest react-native-screens Screen > android.R.id.content > parent
191
+ *
192
+ * Returns the nearest react-native-screens Screen ancestor if found, which scopes
193
+ * the blur to the current screen and prevents capturing navigation transitions.
194
+ *
195
+ * Returns null when no Screen ancestor exists (e.g. modals, standalone usage).
196
+ * A null return means swapBlurRootToScreenAncestor() is a no-op and QmBlurView
197
+ * keeps its default decor view as the blur root — this is correct for modals
198
+ * because they need to blur the content behind them (in the main activity window).
192
199
  */
193
200
  private fun findOptimalBlurRoot(): ViewGroup? {
194
- return findNearestScreenAncestor() ?: getContentViewFallback()
201
+ return findNearestScreenAncestor()
195
202
  }
196
203
 
197
204
  /**
@@ -209,19 +216,6 @@ class ReactNativeBlurView : BlurViewGroup {
209
216
  return null
210
217
  }
211
218
 
212
- /**
213
- * Falls back to android.R.id.content or the activity root view.
214
- */
215
- private fun getContentViewFallback(): ViewGroup? {
216
- try {
217
- val activity = context as? android.app.Activity
218
- activity?.findViewById<ViewGroup>(android.R.id.content)?.let { return it }
219
- } catch (e: Exception) {
220
- logDebug("Could not access activity content view: ${e.message}")
221
- }
222
- return this.parent as? ViewGroup
223
- }
224
-
225
219
  /**
226
220
  * Initialize the blur view with current settings.
227
221
  * Called after the view is attached and the blur root has been swapped.
@@ -1,8 +1,6 @@
1
1
  package com.sbaiahmed1.reactnativeblur
2
2
 
3
- import android.app.Activity
4
3
  import android.content.Context
5
- import android.content.ContextWrapper
6
4
  import android.graphics.Canvas
7
5
  import android.graphics.Color
8
6
  import android.graphics.LinearGradient
@@ -16,7 +14,6 @@ import android.view.View
16
14
  import android.view.ViewGroup
17
15
  import android.widget.FrameLayout
18
16
  import android.view.View.MeasureSpec
19
- import com.facebook.react.bridge.ReactContext
20
17
  import com.qmdeve.blurview.widget.BlurView
21
18
  import kotlin.math.max
22
19
 
@@ -207,10 +204,17 @@ class ReactNativeProgressiveBlurView : FrameLayout {
207
204
 
208
205
  /**
209
206
  * Finds the optimal view to use as blur capture root.
210
- * Priority: nearest react-native-screens Screen > android.R.id.content > parent
207
+ *
208
+ * Returns the nearest react-native-screens Screen ancestor if found, which scopes
209
+ * the blur to the current screen and prevents capturing navigation transitions.
210
+ *
211
+ * Returns null when no Screen ancestor exists (e.g. modals, standalone usage).
212
+ * A null return means swapBlurRootToScreenAncestor() is a no-op and QmBlurView
213
+ * keeps its default decor view as the blur root — this is correct for modals
214
+ * because they need to blur the content behind them (in the main activity window).
211
215
  */
212
216
  private fun findOptimalBlurRoot(): ViewGroup? {
213
- return findNearestScreenAncestor() ?: getContentViewFallback()
217
+ return findNearestScreenAncestor()
214
218
  }
215
219
 
216
220
  /**
@@ -227,37 +231,6 @@ class ReactNativeProgressiveBlurView : FrameLayout {
227
231
  return null
228
232
  }
229
233
 
230
- /**
231
- * Falls back to android.R.id.content or the activity root view.
232
- * Tries ReactContext.currentActivity first, then unwraps ContextWrapper chain.
233
- */
234
- private fun getContentViewFallback(): ViewGroup? {
235
- try {
236
- val activity = getActivityFromContext()
237
- activity?.findViewById<ViewGroup>(android.R.id.content)?.let { return it }
238
- } catch (e: Exception) {
239
- logDebug("Could not access activity content view: ${e.message}")
240
- }
241
- return this.parent as? ViewGroup
242
- }
243
-
244
- /**
245
- * Resolves an Activity from the view's context.
246
- * Priority: ReactContext.currentActivity > ContextWrapper unwrap chain.
247
- */
248
- private fun getActivityFromContext(): Activity? {
249
- // Try ReactContext first (most common in React Native)
250
- (context as? ReactContext)?.currentActivity?.let { return it }
251
-
252
- // Unwrap ContextWrapper chain to find an Activity
253
- var ctx: Context? = context
254
- while (ctx != null) {
255
- if (ctx is Activity) return ctx
256
- ctx = (ctx as? ContextWrapper)?.baseContext
257
- }
258
- return null
259
- }
260
-
261
234
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
262
235
  val width = MeasureSpec.getSize(widthMeasureSpec)
263
236
  val height = MeasureSpec.getSize(heightMeasureSpec)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sbaiahmed1/react-native-blur",
3
- "version": "4.5.5-beta.4",
3
+ "version": "4.5.5-beta.6",
4
4
  "description": "React native modern blur view",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",