@sbaiahmed1/react-native-blur 4.5.5-beta.5 → 4.5.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.
@@ -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.Color
7
5
  import android.graphics.Outline
8
6
  import android.util.AttributeSet
@@ -12,7 +10,6 @@ import android.view.View
12
10
  import android.view.ViewGroup
13
11
  import android.view.ViewOutlineProvider
14
12
  import android.view.ViewTreeObserver
15
- import com.facebook.react.bridge.ReactContext
16
13
  import com.qmdeve.blurview.widget.BlurViewGroup
17
14
  import com.qmdeve.blurview.base.BaseBlurViewGroup
18
15
  import androidx.core.graphics.toColorInt
@@ -191,13 +188,17 @@ class ReactNativeBlurView : BlurViewGroup {
191
188
 
192
189
  /**
193
190
  * Finds the optimal view to use as blur capture root.
194
- * Priority: nearest react-native-screens Screen > android.R.id.content in parent chain > activity content > parent
195
191
  *
196
- * This handles both regular screens and modals modals have their own window/view tree,
197
- * so we walk up the parent chain for android.R.id.content before falling back to the activity.
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).
198
199
  */
199
200
  private fun findOptimalBlurRoot(): ViewGroup? {
200
- return findNearestScreenAncestor() ?: getAppRootFallback()
201
+ return findNearestScreenAncestor()
201
202
  }
202
203
 
203
204
  /**
@@ -215,46 +216,6 @@ class ReactNativeBlurView : BlurViewGroup {
215
216
  return null
216
217
  }
217
218
 
218
- /**
219
- * Walks up the view parent chain looking for android.R.id.content (works in modals
220
- * which have their own content root), then falls back to the activity's content view.
221
- */
222
- private fun getAppRootFallback(): ViewGroup? {
223
- // Walk up the parent chain — catches modals which have their own android.R.id.content
224
- var parent = this.parent
225
- while (parent != null) {
226
- if (parent is ViewGroup && parent.id == android.R.id.content) {
227
- return parent
228
- }
229
- parent = parent.parent
230
- }
231
-
232
- // Fall back to the activity's content view
233
- try {
234
- val activity = getActivityFromContext()
235
- activity?.findViewById<ViewGroup>(android.R.id.content)?.let { return it }
236
- } catch (e: Exception) {
237
- logDebug("Could not access activity root view: ${e.message}")
238
- }
239
-
240
- return this.parent as? ViewGroup
241
- }
242
-
243
- /**
244
- * Resolves an Activity from the view's context.
245
- * Priority: ReactContext.currentActivity > ContextWrapper unwrap chain.
246
- */
247
- private fun getActivityFromContext(): Activity? {
248
- (context as? ReactContext)?.currentActivity?.let { return it }
249
-
250
- var ctx: Context? = context
251
- while (ctx != null) {
252
- if (ctx is Activity) return ctx
253
- ctx = (ctx as? ContextWrapper)?.baseContext
254
- }
255
- return null
256
- }
257
-
258
219
  /**
259
220
  * Initialize the blur view with current settings.
260
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,13 +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 in parent chain > activity content > parent
211
207
  *
212
- * This handles both regular screens and modals modals have their own window/view tree,
213
- * so we walk up the parent chain for android.R.id.content before falling back to the activity.
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).
214
215
  */
215
216
  private fun findOptimalBlurRoot(): ViewGroup? {
216
- return findNearestScreenAncestor() ?: getAppRootFallback()
217
+ return findNearestScreenAncestor()
217
218
  }
218
219
 
219
220
  /**
@@ -230,48 +231,6 @@ class ReactNativeProgressiveBlurView : FrameLayout {
230
231
  return null
231
232
  }
232
233
 
233
- /**
234
- * Walks up the view parent chain looking for android.R.id.content (works in modals
235
- * which have their own content root), then falls back to the activity's content view.
236
- */
237
- private fun getAppRootFallback(): ViewGroup? {
238
- // Walk up the parent chain — catches modals which have their own android.R.id.content
239
- var parent = this.parent
240
- while (parent != null) {
241
- if (parent is ViewGroup && parent.id == android.R.id.content) {
242
- return parent
243
- }
244
- parent = parent.parent
245
- }
246
-
247
- // Fall back to the activity's content view
248
- try {
249
- val activity = getActivityFromContext()
250
- activity?.findViewById<ViewGroup>(android.R.id.content)?.let { return it }
251
- } catch (e: Exception) {
252
- logDebug("Could not access activity root view: ${e.message}")
253
- }
254
-
255
- return this.parent as? ViewGroup
256
- }
257
-
258
- /**
259
- * Resolves an Activity from the view's context.
260
- * Priority: ReactContext.currentActivity > ContextWrapper unwrap chain.
261
- */
262
- private fun getActivityFromContext(): Activity? {
263
- // Try ReactContext first (most common in React Native)
264
- (context as? ReactContext)?.currentActivity?.let { return it }
265
-
266
- // Unwrap ContextWrapper chain to find an Activity
267
- var ctx: Context? = context
268
- while (ctx != null) {
269
- if (ctx is Activity) return ctx
270
- ctx = (ctx as? ContextWrapper)?.baseContext
271
- }
272
- return null
273
- }
274
-
275
234
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
276
235
  val width = MeasureSpec.getSize(widthMeasureSpec)
277
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.5",
3
+ "version": "4.5.5",
4
4
  "description": "React native modern blur view",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",