@sbaiahmed1/react-native-blur 4.2.0 → 4.2.1

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.
@@ -5,9 +5,12 @@ import android.graphics.Color
5
5
  import android.util.AttributeSet
6
6
  import android.util.Log
7
7
  import android.util.TypedValue
8
+ import android.view.ViewGroup
8
9
  import com.qmdeve.blurview.widget.BlurViewGroup
9
10
  import androidx.core.graphics.toColorInt
10
11
 
12
+ import android.view.View.MeasureSpec
13
+
11
14
  /**
12
15
  * Android implementation of React Native BlurView component.
13
16
  * Provides cross-platform blur effects using the QmBlurView library.
@@ -80,6 +83,7 @@ class ReactNativeBlurView : BlurViewGroup {
80
83
  // setBlurRadius takes Float, setOverlayColor takes Int, setCornerRadius takes Float (in dp)
81
84
  super.setBlurRadius(currentBlurRadius)
82
85
  super.setOverlayColor(currentOverlayColor)
86
+ super.setDownsampleFactor(4.0F)
83
87
  updateCornerRadius()
84
88
 
85
89
  // Set transparent background to prevent visual artifacts
@@ -322,31 +326,37 @@ class ReactNativeBlurView : BlurViewGroup {
322
326
  }
323
327
  }
324
328
 
329
+ override fun generateDefaultLayoutParams(): ViewGroup.LayoutParams {
330
+ return ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
331
+ }
332
+
333
+ override fun generateLayoutParams(attrs: AttributeSet?): ViewGroup.LayoutParams {
334
+ return ViewGroup.MarginLayoutParams(context, attrs)
335
+ }
336
+
337
+ override fun generateLayoutParams(p: ViewGroup.LayoutParams?): ViewGroup.LayoutParams {
338
+ return ViewGroup.MarginLayoutParams(p)
339
+ }
340
+
341
+ override fun checkLayoutParams(p: ViewGroup.LayoutParams?): Boolean {
342
+ return p is ViewGroup.MarginLayoutParams
343
+ }
344
+
345
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
346
+ // Trust React Native to provide correct dimensions
347
+ setMeasuredDimension(
348
+ MeasureSpec.getSize(widthMeasureSpec),
349
+ MeasureSpec.getSize(heightMeasureSpec)
350
+ )
351
+ }
352
+
325
353
  /**
326
354
  * Override onLayout to properly position children according to React Native's Yoga layout.
327
- * This prevents children from stacking on top of each other and ensures they follow
328
- * the flexbox layout calculated by React Native.
329
- *
330
- * React Native's Yoga layout system calculates positions for all children, but we need
331
- * to explicitly apply those positions in onLayout. Without this, BlurViewGroup's default
332
- * FrameLayout-like behavior would stack all children at (0,0).
333
355
  */
334
356
  override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
335
- // Position each child according to its layout calculated by React Native's Yoga
336
- for (i in 0 until childCount) {
337
- val child = getChildAt(i)
338
- if (child.visibility != GONE) {
339
- // React Native stores the calculated layout in the view's properties
340
- // We just need to apply them by calling layout() with the correct coordinates
341
- val childLeft = child.left
342
- val childTop = child.top
343
- val childRight = child.right
344
- val childBottom = child.bottom
345
-
346
- child.layout(childLeft, childTop, childRight, childBottom)
347
-
348
- logDebug("Laid out child $i at ($childLeft, $childTop, $childRight, $childBottom)")
349
- }
350
- }
357
+ // No-op: Layout is handled by React Native's UIManager.
358
+ // We override this to prevent the superclass (BlurViewGroup/FrameLayout) from
359
+ // re-positioning children based on its own logic (e.g. gravity), which would
360
+ // conflict with React Native's layout.
351
361
  }
352
362
  }
@@ -11,6 +11,7 @@ import android.graphics.Shader
11
11
  import android.util.AttributeSet
12
12
  import android.util.Log
13
13
  import android.widget.FrameLayout
14
+ import android.view.View.MeasureSpec
14
15
  import com.qmdeve.blurview.widget.BlurView
15
16
  import androidx.core.graphics.toColorInt
16
17
 
@@ -106,6 +107,27 @@ class ReactNativeProgressiveBlurView : FrameLayout {
106
107
  }
107
108
  }
108
109
 
110
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
111
+ val width = MeasureSpec.getSize(widthMeasureSpec)
112
+ val height = MeasureSpec.getSize(heightMeasureSpec)
113
+ setMeasuredDimension(width, height)
114
+
115
+ // Measure the internal blurView to match the parent size
116
+ blurView?.measure(
117
+ MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
118
+ MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)
119
+ )
120
+ }
121
+
122
+ override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
123
+ // Layout the internal blurView to fill the parent
124
+ val width = right - left
125
+ val height = bottom - top
126
+ blurView?.layout(0, 0, width, height)
127
+
128
+ // Do NOT call super.onLayout to avoid interfering with React Native children
129
+ }
130
+
109
131
  override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
110
132
  super.onSizeChanged(w, h, oldw, oldh)
111
133
  if (w > 0 && h > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sbaiahmed1/react-native-blur",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "React native modern blur view",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",