@sbaiahmed1/react-native-blur 4.2.1 → 4.2.2
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.
package/android/build.gradle
CHANGED
|
@@ -74,7 +74,7 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
|
74
74
|
dependencies {
|
|
75
75
|
implementation "com.facebook.react:react-android"
|
|
76
76
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
77
|
-
implementation 'com.qmdeve:
|
|
77
|
+
implementation 'com.qmdeve.blurview:core:1.0.5'
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
react {
|
|
@@ -31,7 +31,7 @@ class ReactNativeBlurView : BlurViewGroup {
|
|
|
31
31
|
|
|
32
32
|
companion object {
|
|
33
33
|
private const val TAG = "ReactNativeBlurView"
|
|
34
|
-
private const val MAX_BLUR_RADIUS =
|
|
34
|
+
private const val MAX_BLUR_RADIUS = 100f
|
|
35
35
|
private const val DEFAULT_BLUR_RADIUS = 10f
|
|
36
36
|
private const val DEBUG = false // Set to true for debug builds
|
|
37
37
|
|
|
@@ -83,7 +83,7 @@ class ReactNativeBlurView : BlurViewGroup {
|
|
|
83
83
|
// setBlurRadius takes Float, setOverlayColor takes Int, setCornerRadius takes Float (in dp)
|
|
84
84
|
super.setBlurRadius(currentBlurRadius)
|
|
85
85
|
super.setOverlayColor(currentOverlayColor)
|
|
86
|
-
super.setDownsampleFactor(
|
|
86
|
+
super.setDownsampleFactor(6.0F)
|
|
87
87
|
updateCornerRadius()
|
|
88
88
|
|
|
89
89
|
// Set transparent background to prevent visual artifacts
|
|
@@ -326,12 +326,12 @@ class ReactNativeBlurView : BlurViewGroup {
|
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
-
override fun generateDefaultLayoutParams():
|
|
330
|
-
return
|
|
329
|
+
override fun generateDefaultLayoutParams(): BlurViewGroup.LayoutParams {
|
|
330
|
+
return BlurViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
-
override fun generateLayoutParams(attrs: AttributeSet?):
|
|
334
|
-
return
|
|
333
|
+
override fun generateLayoutParams(attrs: AttributeSet?): BlurViewGroup.LayoutParams {
|
|
334
|
+
return BlurViewGroup.LayoutParams(context, attrs)
|
|
335
335
|
}
|
|
336
336
|
|
|
337
337
|
override fun generateLayoutParams(p: ViewGroup.LayoutParams?): ViewGroup.LayoutParams {
|
package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeProgressiveBlurView.kt
CHANGED
|
@@ -19,14 +19,14 @@ import androidx.core.graphics.toColorInt
|
|
|
19
19
|
* Android implementation of React Native ProgressiveBlurView component.
|
|
20
20
|
* Uses a combination of normal blur (BlurView) + linear gradient mask to create
|
|
21
21
|
* a progressive blur effect that transitions from blurred to clear.
|
|
22
|
-
*
|
|
22
|
+
*
|
|
23
23
|
* This approach is more reliable than using the library's ProgressiveBlurView,
|
|
24
24
|
* which has limited control over gradient direction and appearance.
|
|
25
25
|
*/
|
|
26
26
|
class ReactNativeProgressiveBlurView : FrameLayout {
|
|
27
27
|
private var blurView: BlurView? = null
|
|
28
28
|
private val gradientPaint = Paint(Paint.ANTI_ALIAS_FLAG)
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
private var currentBlurRadius = DEFAULT_BLUR_RADIUS
|
|
31
31
|
private var currentOverlayColor = Color.TRANSPARENT
|
|
32
32
|
private var currentDirection = "topToBottom"
|
|
@@ -35,7 +35,7 @@ class ReactNativeProgressiveBlurView : FrameLayout {
|
|
|
35
35
|
|
|
36
36
|
companion object {
|
|
37
37
|
private const val TAG = "ReactNativeProgressiveBlur"
|
|
38
|
-
private const val MAX_BLUR_RADIUS =
|
|
38
|
+
private const val MAX_BLUR_RADIUS = 100f
|
|
39
39
|
private const val DEFAULT_BLUR_RADIUS = 10f
|
|
40
40
|
private const val DEBUG = true
|
|
41
41
|
|
|
@@ -87,7 +87,9 @@ class ReactNativeProgressiveBlurView : FrameLayout {
|
|
|
87
87
|
blurView = BlurView(context, null).apply {
|
|
88
88
|
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
|
89
89
|
setBlurRadius(currentBlurRadius)
|
|
90
|
-
|
|
90
|
+
setDownsampleFactor(6.0F)
|
|
91
|
+
blurRounds = 3
|
|
92
|
+
overlayColor = currentOverlayColor
|
|
91
93
|
setBackgroundColor(Color.TRANSPARENT)
|
|
92
94
|
}
|
|
93
95
|
addView(blurView)
|
|
@@ -95,7 +97,7 @@ class ReactNativeProgressiveBlurView : FrameLayout {
|
|
|
95
97
|
// Set up the gradient paint
|
|
96
98
|
gradientPaint.style = Paint.Style.FILL
|
|
97
99
|
setWillNotDraw(false) // Enable onDraw for gradient overlay
|
|
98
|
-
|
|
100
|
+
|
|
99
101
|
// Set transparent background for the container
|
|
100
102
|
super.setBackgroundColor(Color.TRANSPARENT)
|
|
101
103
|
|
|
@@ -176,12 +178,12 @@ class ReactNativeProgressiveBlurView : FrameLayout {
|
|
|
176
178
|
floatArrayOf(0f, 1f),
|
|
177
179
|
Shader.TileMode.CLAMP
|
|
178
180
|
)
|
|
179
|
-
|
|
181
|
+
|
|
180
182
|
gradientPaint.shader = gradient
|
|
181
|
-
|
|
183
|
+
|
|
182
184
|
logDebug("Updated gradient: direction=$currentDirection, start=($x0,$y0), end=($x1,$y1), offset=$currentStartOffset")
|
|
183
185
|
invalidate()
|
|
184
|
-
|
|
186
|
+
|
|
185
187
|
} catch (e: Exception) {
|
|
186
188
|
logError("Failed to update gradient: ${e.message}", e)
|
|
187
189
|
}
|
|
@@ -195,15 +197,15 @@ class ReactNativeProgressiveBlurView : FrameLayout {
|
|
|
195
197
|
|
|
196
198
|
// Use a layer to apply the gradient mask
|
|
197
199
|
val saveCount = canvas.saveLayer(0f, 0f, width.toFloat(), height.toFloat(), null)
|
|
198
|
-
|
|
200
|
+
|
|
199
201
|
// Draw the blur view
|
|
200
202
|
super.dispatchDraw(canvas)
|
|
201
|
-
|
|
203
|
+
|
|
202
204
|
// Apply gradient mask using DST_IN to make the blur gradually transparent
|
|
203
205
|
gradientPaint.xfermode = PorterDuffXfermode(PorterDuff.Mode.DST_IN)
|
|
204
206
|
canvas.drawRect(0f, 0f, width.toFloat(), height.toFloat(), gradientPaint)
|
|
205
207
|
gradientPaint.xfermode = null
|
|
206
|
-
|
|
208
|
+
|
|
207
209
|
canvas.restoreToCount(saveCount)
|
|
208
210
|
}
|
|
209
211
|
|
|
@@ -212,7 +214,7 @@ class ReactNativeProgressiveBlurView : FrameLayout {
|
|
|
212
214
|
*/
|
|
213
215
|
override fun setBackgroundColor(color: Int) {
|
|
214
216
|
logDebug("setBackgroundColor called: $color")
|
|
215
|
-
|
|
217
|
+
|
|
216
218
|
if (color != Color.TRANSPARENT) {
|
|
217
219
|
hasExplicitBackground = true
|
|
218
220
|
logDebug("Stored explicit background color: $color")
|
|
@@ -288,13 +290,13 @@ class ReactNativeProgressiveBlurView : FrameLayout {
|
|
|
288
290
|
/**
|
|
289
291
|
* Set the start offset for the progressive blur.
|
|
290
292
|
* Controls where the gradient transition begins.
|
|
291
|
-
*
|
|
293
|
+
*
|
|
292
294
|
* @param offset The offset value (0.0 to 1.0) - where 0 starts immediately, 1 delays to the end
|
|
293
295
|
*/
|
|
294
296
|
fun setStartOffset(offset: Float) {
|
|
295
297
|
currentStartOffset = offset.coerceIn(0.0f, 1.0f)
|
|
296
298
|
logDebug("setStartOffset: $offset -> clamped to $currentStartOffset")
|
|
297
|
-
|
|
299
|
+
|
|
298
300
|
try {
|
|
299
301
|
updateGradient()
|
|
300
302
|
} catch (e: Exception) {
|
|
@@ -328,7 +330,7 @@ class ReactNativeProgressiveBlurView : FrameLayout {
|
|
|
328
330
|
logDebug("Cleared reduced transparency fallback color")
|
|
329
331
|
return
|
|
330
332
|
}
|
|
331
|
-
|
|
333
|
+
|
|
332
334
|
try {
|
|
333
335
|
val fallbackColor = color.toColorInt()
|
|
334
336
|
logDebug("setReducedTransparencyFallbackColor: $color -> ${Integer.toHexString(fallbackColor)}")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sbaiahmed1/react-native-blur",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "React native modern blur view",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"tagName": "v${version}"
|
|
117
117
|
},
|
|
118
118
|
"npm": {
|
|
119
|
-
"publish":
|
|
119
|
+
"publish": false
|
|
120
120
|
},
|
|
121
121
|
"github": {
|
|
122
122
|
"release": true
|