@sbaiahmed1/react-native-blur 4.0.1 → 4.1.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.
- package/README.md +155 -47
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/BlurType.kt +63 -0
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurPackage.kt +1 -0
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt +63 -43
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurViewManager.kt +14 -26
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeProgressiveBlurView.kt +320 -0
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeProgressiveBlurViewManager.kt +81 -0
- package/ios/Helpers/BlurStyleHelpers.swift +20 -0
- package/ios/Helpers/ReactNativeProgressiveBlurViewHelper.swift +39 -0
- package/ios/ReactNativeBlurView.mm +2 -4
- package/ios/ReactNativeProgressiveBlurView.h +14 -0
- package/ios/ReactNativeProgressiveBlurView.mm +213 -0
- package/ios/ReactNativeProgressiveBlurViewManager.h +4 -0
- package/ios/ReactNativeProgressiveBlurViewManager.mm +137 -0
- package/ios/Views/ProgressiveBlurView.swift +124 -0
- package/ios/Views/VariableBlurView.swift +142 -0
- package/lib/module/BlurView.js +23 -12
- package/lib/module/BlurView.js.map +1 -1
- package/lib/module/LiquidGlassView.js +3 -1
- package/lib/module/LiquidGlassView.js.map +1 -1
- package/lib/module/ProgressiveBlurView.js +98 -0
- package/lib/module/ProgressiveBlurView.js.map +1 -0
- package/lib/module/ReactNativeBlurViewNativeComponent.ts +11 -1
- package/lib/module/ReactNativeProgressiveBlurViewNativeComponent.ts +45 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/BlurView.d.ts.map +1 -1
- package/lib/typescript/src/LiquidGlassView.d.ts.map +1 -1
- package/lib/typescript/src/ProgressiveBlurView.d.ts +97 -0
- package/lib/typescript/src/ProgressiveBlurView.d.ts.map +1 -0
- package/lib/typescript/src/ReactNativeBlurViewNativeComponent.d.ts +1 -1
- package/lib/typescript/src/ReactNativeBlurViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/ReactNativeProgressiveBlurViewNativeComponent.d.ts +14 -0
- package/lib/typescript/src/ReactNativeProgressiveBlurViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/BlurView.tsx +21 -17
- package/src/LiquidGlassView.tsx +3 -4
- package/src/ProgressiveBlurView.tsx +161 -0
- package/src/ReactNativeBlurViewNativeComponent.ts +11 -1
- package/src/ReactNativeProgressiveBlurViewNativeComponent.ts +45 -0
- package/src/index.tsx +6 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @sbaiahmed1/react-native-blur
|
|
2
2
|
|
|
3
|
-
A modern React Native library providing **
|
|
3
|
+
A modern React Native library providing **three specialized components** for advanced visual effects: `BlurView` for native blur effects, `LiquidGlassView` for cutting-edge liquid glass effects on iOS 26+ (with Android fallback to enhanced blur) and `ProgressiveBlurView` for smooth, variable blur transitions.`
|
|
4
4
|
|
|
5
5
|
> **📦 Current Version: 4.0.0** | **⚠️ Breaking Changes**: If upgrading from 3.x, see [Breaking Changes](#️-breaking-changes-in-v400) section.
|
|
6
6
|
|
|
@@ -35,13 +35,13 @@ A modern React Native library providing **two specialized components** for advan
|
|
|
35
35
|
|
|
36
36
|
## Requirements
|
|
37
37
|
|
|
38
|
-
| Platform
|
|
39
|
-
|
|
40
|
-
| **iOS**
|
|
41
|
-
| **Xcode**
|
|
42
|
-
| **React Native**
|
|
43
|
-
| **Android**
|
|
44
|
-
| **Android Gradle Plugin** | 8.9.1+
|
|
38
|
+
| Platform | Minimum Version |
|
|
39
|
+
| ------------------------- | -------------------------------------- |
|
|
40
|
+
| **iOS** | iOS 13.0+ |
|
|
41
|
+
| **Xcode** | Xcode 26.0+ (for liquid glass support) |
|
|
42
|
+
| **React Native** | 0.68+ (New Architecture) |
|
|
43
|
+
| **Android** | API 24+ (Android 7.0) |
|
|
44
|
+
| **Android Gradle Plugin** | 8.9.1+ |
|
|
45
45
|
|
|
46
46
|
> ⚠️ **Note**: LiquidGlassView requires Xcode 26.0+ and iOS 26+ for full glass effects. The component automatically falls back to enhanced blur on older versions.
|
|
47
47
|
|
|
@@ -56,10 +56,10 @@ In version 3.x, we had a **single `BlurView` component** with a `type` prop that
|
|
|
56
56
|
```tsx
|
|
57
57
|
// ❌ Old API (v3.x) - DEPRECATED
|
|
58
58
|
<BlurView
|
|
59
|
-
type="blur"
|
|
59
|
+
type="blur" // or "liquidGlass"
|
|
60
60
|
blurType="light"
|
|
61
61
|
blurAmount={10}
|
|
62
|
-
glassType="regular"
|
|
62
|
+
glassType="regular" // Mixed blur and glass props
|
|
63
63
|
glassTintColor="#007AFF"
|
|
64
64
|
/>
|
|
65
65
|
```
|
|
@@ -87,6 +87,7 @@ import { BlurView, LiquidGlassView } from '@sbaiahmed1/react-native-blur';
|
|
|
87
87
|
### Migration from 3.x to 4.0.0
|
|
88
88
|
|
|
89
89
|
**If you were using blur mode:**
|
|
90
|
+
|
|
90
91
|
```tsx
|
|
91
92
|
// Before (3.x)
|
|
92
93
|
<BlurView type="blur" blurType="light" blurAmount={10} />
|
|
@@ -96,6 +97,7 @@ import { BlurView, LiquidGlassView } from '@sbaiahmed1/react-native-blur';
|
|
|
96
97
|
```
|
|
97
98
|
|
|
98
99
|
**If you were using liquid glass mode:**
|
|
100
|
+
|
|
99
101
|
```tsx
|
|
100
102
|
// Before (3.x)
|
|
101
103
|
<BlurView
|
|
@@ -103,7 +105,7 @@ import { BlurView, LiquidGlassView } from '@sbaiahmed1/react-native-blur';
|
|
|
103
105
|
glassType="regular"
|
|
104
106
|
glassTintColor="#007AFF"
|
|
105
107
|
glassOpacity={0.8}
|
|
106
|
-
|
|
108
|
+
/>;
|
|
107
109
|
|
|
108
110
|
// After (4.0.0)
|
|
109
111
|
import { LiquidGlassView } from '@sbaiahmed1/react-native-blur';
|
|
@@ -112,7 +114,7 @@ import { LiquidGlassView } from '@sbaiahmed1/react-native-blur';
|
|
|
112
114
|
glassType="regular"
|
|
113
115
|
glassTintColor="#007AFF"
|
|
114
116
|
glassOpacity={0.8}
|
|
115
|
-
|
|
117
|
+
/>;
|
|
116
118
|
```
|
|
117
119
|
|
|
118
120
|
### Why This Change?
|
|
@@ -131,8 +133,9 @@ import { LiquidGlassView } from '@sbaiahmed1/react-native-blur';
|
|
|
131
133
|
|
|
132
134
|
## Features
|
|
133
135
|
|
|
134
|
-
- � **
|
|
136
|
+
- � **Three Specialized Components**:
|
|
135
137
|
- `BlurView` - Dedicated blur effects component with multiple blur types
|
|
138
|
+
- `ProgressiveBlurView` - Variable/gradient blur transitions (iOS & Android)
|
|
136
139
|
- `LiquidGlassView` - Separate component for iOS 26+ liquid glass effects
|
|
137
140
|
- �🌊 **Liquid Glass Effects**: Revolutionary glass effects using iOS 26+ UIGlassEffect API
|
|
138
141
|
- 🎨 **Multiple Blur Types**: Support for various blur styles including system materials on iOS
|
|
@@ -158,12 +161,14 @@ import { LiquidGlassView } from '@sbaiahmed1/react-native-blur';
|
|
|
158
161
|
- **Full TypeScript**: Complete type definitions for both components
|
|
159
162
|
|
|
160
163
|
### vs. @react-native-community/blur
|
|
164
|
+
|
|
161
165
|
- ✅ Dedicated components vs single component with mode switching
|
|
162
166
|
- ✅ Liquid glass effects (iOS 26+)
|
|
163
167
|
- ✅ Better new architecture support
|
|
164
168
|
- ✅ Separate prop types for each component
|
|
165
169
|
|
|
166
170
|
### vs. expo-blur
|
|
171
|
+
|
|
167
172
|
- ✅ No Expo dependency required
|
|
168
173
|
- ✅ Real Android blur (not experimental)
|
|
169
174
|
- ✅ Works with bare React Native projects
|
|
@@ -192,14 +197,15 @@ import { BlurView, LiquidGlassView } from '@sbaiahmed1/react-native-blur';
|
|
|
192
197
|
```tsx
|
|
193
198
|
// Before
|
|
194
199
|
import { BlurView } from 'expo-blur';
|
|
195
|
-
<BlurView intensity={50} tint="light"
|
|
200
|
+
<BlurView intensity={50} tint="light" />;
|
|
196
201
|
|
|
197
202
|
// After
|
|
198
203
|
import { BlurView } from '@sbaiahmed1/react-native-blur';
|
|
199
|
-
<BlurView blurAmount={50} blurType="light"
|
|
204
|
+
<BlurView blurAmount={50} blurType="light" />;
|
|
200
205
|
```
|
|
201
206
|
|
|
202
207
|
**Migration Steps:**
|
|
208
|
+
|
|
203
209
|
1. Uninstall old library: `npm uninstall @react-native-community/blur expo-blur`
|
|
204
210
|
2. Install: `npm install @sbaiahmed1/react-native-blur`
|
|
205
211
|
3. Update imports
|
|
@@ -231,23 +237,26 @@ The library uses native Android blur with automatic platform detection. No addit
|
|
|
231
237
|
- **Android Gradle Plugin:** 8.9.1+
|
|
232
238
|
|
|
233
239
|
> ⚠️ **AGP Requirement**: Requires Android Gradle Plugin **8.9.1 or newer**. Check `android/build.gradle`:
|
|
240
|
+
>
|
|
234
241
|
> ```gradle
|
|
235
242
|
> classpath "com.android.tools.build:gradle:8.9.1" // or higher
|
|
236
243
|
> ```
|
|
237
244
|
|
|
238
245
|
> 📦 **Dependency**: The library uses [QmBlurView](https://github.com/QmDeve/QmBlurView) from Maven Central:
|
|
246
|
+
>
|
|
239
247
|
> ```gradle
|
|
240
248
|
> implementation 'com.qmdeve:QmBlurView:1.0.4.3'
|
|
241
249
|
> ```
|
|
242
250
|
|
|
243
251
|
The implementation automatically handles different Android versions:
|
|
244
|
-
|
|
252
|
+
|
|
253
|
+
- Android 12+: Uses `RenderEffectBlur`
|
|
245
254
|
- Android 10-11: Falls back to `RenderScriptBlur`
|
|
246
255
|
- Older versions: Lightweight overlay fallback
|
|
247
256
|
|
|
248
257
|
## Usage
|
|
249
258
|
|
|
250
|
-
The library now provides **
|
|
259
|
+
The library now provides **three specialized components** for different visual effects:
|
|
251
260
|
|
|
252
261
|
### BlurView - Standard Blur Effects
|
|
253
262
|
|
|
@@ -305,6 +314,59 @@ function MyComponent() {
|
|
|
305
314
|
}
|
|
306
315
|
```
|
|
307
316
|
|
|
317
|
+
### ProgressiveBlurView - Variable/Gradient Blur
|
|
318
|
+
|
|
319
|
+
NOTE: Progressive blur offset works different between android and iOS
|
|
320
|
+
|
|
321
|
+
Use `ProgressiveBlurView` for smooth, gradient blur transitions. This component works on both **iOS** and **Android**.
|
|
322
|
+
|
|
323
|
+
```tsx
|
|
324
|
+
import React from 'react';
|
|
325
|
+
import { ProgressiveBlurView } from '@sbaiahmed1/react-native-blur';
|
|
326
|
+
|
|
327
|
+
function GradientBlurComponent() {
|
|
328
|
+
return (
|
|
329
|
+
<ProgressiveBlurView
|
|
330
|
+
blurType="light"
|
|
331
|
+
blurAmount={30}
|
|
332
|
+
direction="blurredTopClearBottom"
|
|
333
|
+
startOffset={0}
|
|
334
|
+
style={{ height: 200 }}
|
|
335
|
+
>
|
|
336
|
+
<Text>Progressive blur from top (blurred) to bottom (clear)</Text>
|
|
337
|
+
</ProgressiveBlurView>
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
#### Locked Content Example
|
|
343
|
+
|
|
344
|
+
Perfect for paywall/premium content:
|
|
345
|
+
|
|
346
|
+
```tsx
|
|
347
|
+
<View style={{ position: 'relative' }}>
|
|
348
|
+
<Text>Long content here...</Text>
|
|
349
|
+
|
|
350
|
+
{/* Progressive blur overlay */}
|
|
351
|
+
<ProgressiveBlurView
|
|
352
|
+
blurType="light"
|
|
353
|
+
blurAmount={20}
|
|
354
|
+
direction="blurredBottomClearTop"
|
|
355
|
+
startOffset={0.2}
|
|
356
|
+
style={{
|
|
357
|
+
position: 'absolute',
|
|
358
|
+
bottom: 0,
|
|
359
|
+
left: 0,
|
|
360
|
+
right: 0,
|
|
361
|
+
height: 200,
|
|
362
|
+
}}
|
|
363
|
+
>
|
|
364
|
+
<Text>🔒 Unlock to Read More</Text>
|
|
365
|
+
<Button title="Purchase" />
|
|
366
|
+
</ProgressiveBlurView>
|
|
367
|
+
</View>
|
|
368
|
+
```
|
|
369
|
+
|
|
308
370
|
### LiquidGlassView - Liquid Glass Effects (iOS 26+)
|
|
309
371
|
|
|
310
372
|
Use `LiquidGlassView` for cutting-edge liquid glass effects. **Note:** This component automatically falls back to enhanced blur on Android and older iOS versions.
|
|
@@ -342,7 +404,7 @@ function InteractiveGlass() {
|
|
|
342
404
|
glassType="regular"
|
|
343
405
|
glassTintColor="#007AFF"
|
|
344
406
|
glassOpacity={0.9}
|
|
345
|
-
isInteractive={true}
|
|
407
|
+
isInteractive={true} // Enables touch interaction (iOS 26+ only)
|
|
346
408
|
ignoreSafeArea={false}
|
|
347
409
|
style={{
|
|
348
410
|
flex: 1,
|
|
@@ -363,29 +425,47 @@ The library now provides two separate components with their own props:
|
|
|
363
425
|
|
|
364
426
|
All props are optional and have sensible defaults.
|
|
365
427
|
|
|
366
|
-
| Prop
|
|
367
|
-
|
|
368
|
-
| `blurType`
|
|
369
|
-
| `blurAmount`
|
|
370
|
-
| `ignoreSafeArea`
|
|
371
|
-
| `reducedTransparencyFallbackColor` | `string`
|
|
372
|
-
| `style`
|
|
373
|
-
| `children`
|
|
428
|
+
| Prop | Type | Default | Description |
|
|
429
|
+
| ---------------------------------- | ----------- | ----------- | ----------------------------------------------------------------------------- |
|
|
430
|
+
| `blurType` | `BlurType` | `'xlight'` | The type of blur effect to apply |
|
|
431
|
+
| `blurAmount` | `number` | `10.0` | The intensity of the blur effect (0-100) |
|
|
432
|
+
| `ignoreSafeArea` | `boolean` | `false` | (iOS only) Controls whether the blur effect should ignore all safe area edges |
|
|
433
|
+
| `reducedTransparencyFallbackColor` | `string` | `'#FFFFFF'` | Fallback color when reduced transparency is enabled |
|
|
434
|
+
| `style` | `ViewStyle` | `undefined` | Style object for the blur view |
|
|
435
|
+
| `children` | `ReactNode` | `undefined` | Child components to render inside the blur view |
|
|
436
|
+
|
|
437
|
+
### ProgressiveBlurView Props
|
|
438
|
+
|
|
439
|
+
All props are optional and have sensible defaults.
|
|
440
|
+
|
|
441
|
+
| Prop | Type | Default | Description |
|
|
442
|
+
| ---------------------------------- | ---------------------------------------------------- | ------------------------- | --------------------------------------------------- |
|
|
443
|
+
| `blurType` | `BlurType` | `'regular'` | The type of blur effect to apply |
|
|
444
|
+
| `blurAmount` | `number` | `20.0` | Maximum blur radius in pixels |
|
|
445
|
+
| `direction` | `'blurredTopClearBottom' \| 'blurredBottomClearTop'` | `'blurredTopClearBottom'` | Direction of the blur gradient |
|
|
446
|
+
| `startOffset` | `number` | `0.0` | Where the gradient starts (0.0 to 1.0) |
|
|
447
|
+
| `reducedTransparencyFallbackColor` | `string` | `'#FFFFFF'` | Fallback color when reduced transparency is enabled |
|
|
448
|
+
| `style` | `ViewStyle` | `undefined` | Style object for the blur view |
|
|
449
|
+
| `children` | `ReactNode` | `undefined` | Child components to render inside the blur view |
|
|
450
|
+
|
|
451
|
+
> **Platform Note**: `ProgressiveBlurView` works on both **iOS** and **Android**.
|
|
452
|
+
> - **iOS**: Uses private Core Animation filters for variable blur effects
|
|
453
|
+
> - **Android**: Extends QMBlur's BlurView with custom gradient masking to create progressive blur effect
|
|
374
454
|
|
|
375
455
|
### LiquidGlassView Props
|
|
376
456
|
|
|
377
457
|
All props are optional and have sensible defaults.
|
|
378
458
|
|
|
379
|
-
| Prop
|
|
380
|
-
|
|
381
|
-
| `glassType`
|
|
382
|
-
| `glassTintColor`
|
|
383
|
-
| `glassOpacity`
|
|
384
|
-
| `isInteractive`
|
|
385
|
-
| `ignoreSafeArea`
|
|
386
|
-
| `reducedTransparencyFallbackColor` | `string`
|
|
387
|
-
| `style`
|
|
388
|
-
| `children`
|
|
459
|
+
| Prop | Type | Default | Description |
|
|
460
|
+
| ---------------------------------- | ----------- | ----------- | ------------------------------------------------------------------------------------------ |
|
|
461
|
+
| `glassType` | `GlassType` | `'clear'` | The type of glass effect (iOS 26+ only) |
|
|
462
|
+
| `glassTintColor` | `string` | `'clear'` | The tint color for glass effect. Accepts hex colors or color names |
|
|
463
|
+
| `glassOpacity` | `number` | `1.0` | The opacity of glass effect (0-1) |
|
|
464
|
+
| `isInteractive` | `boolean` | `true` | (iOS 26+ only) Controls whether the liquid glass effect is interactive and reacts to touch |
|
|
465
|
+
| `ignoreSafeArea` | `boolean` | `false` | (iOS only) Controls whether the glass effect should ignore all safe area edges |
|
|
466
|
+
| `reducedTransparencyFallbackColor` | `string` | `'#FFFFFF'` | Fallback color when reduced transparency is enabled or on older iOS versions |
|
|
467
|
+
| `style` | `ViewStyle` | `undefined` | Style object for the glass view |
|
|
468
|
+
| `children` | `ReactNode` | `undefined` | Child components to render inside the glass view |
|
|
389
469
|
|
|
390
470
|
> **Note**: The `BlurType` and `GlassType` are exported types from the library. See [Blur Types](#blur-types) and [Glass Types](#glass-types) sections below for all available values.
|
|
391
471
|
|
|
@@ -395,13 +475,10 @@ All props are optional and have sensible defaults.
|
|
|
395
475
|
|
|
396
476
|
The following blur types are supported for `BlurView`:
|
|
397
477
|
|
|
398
|
-
### iOS & Android
|
|
399
478
|
- `'light'` - Light blur effect
|
|
400
479
|
- `'dark'` - Dark blur effect
|
|
401
480
|
- `'xlight'` - Extra light blur effect
|
|
402
481
|
- `'extraDark'` - Extra dark blur effect
|
|
403
|
-
|
|
404
|
-
### iOS Only (with fallbacks on Android)
|
|
405
482
|
- `'regular'` - Regular blur (iOS 10+)
|
|
406
483
|
- `'prominent'` - Prominent blur (iOS 10+)
|
|
407
484
|
- `'systemUltraThinMaterial'` - Ultra thin material (iOS 13+)
|
|
@@ -409,6 +486,16 @@ The following blur types are supported for `BlurView`:
|
|
|
409
486
|
- `'systemMaterial'` - Material (iOS 13+)
|
|
410
487
|
- `'systemThickMaterial'` - Thick material (iOS 13+)
|
|
411
488
|
- `'systemChromeMaterial'` - Chrome material (iOS 13+)
|
|
489
|
+
- `'systemUltraThinMaterialLight'` - Ultra thin light material (iOS 13+)
|
|
490
|
+
- `'systemThinMaterialLight'` - Thin light material (iOS 13+)
|
|
491
|
+
- `'systemMaterialLight'` - Light material (iOS 13+)
|
|
492
|
+
- `'systemThickMaterialLight'` - Thick light material (iOS 13+)
|
|
493
|
+
- `'systemChromeMaterialLight'` - Chrome light material (iOS 13+)
|
|
494
|
+
- `'systemUltraThinMaterialDark'` - Ultra thin dark material (iOS 13+)
|
|
495
|
+
- `'systemThinMaterialDark'` - Thin dark material (iOS 13+)
|
|
496
|
+
- `'systemMaterialDark'` - Dark material (iOS 13+)
|
|
497
|
+
- `'systemThickMaterialDark'` - Thick dark material (iOS 13+)
|
|
498
|
+
- `'systemChromeMaterialDark'` - Chrome dark material (iOS 13+)
|
|
412
499
|
|
|
413
500
|
## Glass Types (LiquidGlassView)
|
|
414
501
|
|
|
@@ -426,11 +513,13 @@ The following glass types are supported for `LiquidGlassView` on iOS 26+:
|
|
|
426
513
|
Both components have been completely rewritten using **SwiftUI** for modern performance and features:
|
|
427
514
|
|
|
428
515
|
#### BlurView
|
|
516
|
+
|
|
429
517
|
- **iOS 13+**: Uses native `UIVisualEffectView` with precise blur intensity control
|
|
430
518
|
- **Older iOS**: Graceful fallback to standard blur effects
|
|
431
519
|
- **SwiftUI Integration**: Leverages SwiftUI's declarative UI for better performance and maintainability
|
|
432
520
|
|
|
433
521
|
#### LiquidGlassView
|
|
522
|
+
|
|
434
523
|
- **iOS 26+**: Uses native `UIGlassEffect` API for true liquid glass effects with customizable tint colors and opacity
|
|
435
524
|
- **iOS < 26**: Automatically falls back to `BlurView` with enhanced blur effects
|
|
436
525
|
- **SwiftUI Implementation**: Full hardware-accelerated glass effects with interactive touch support
|
|
@@ -438,9 +527,11 @@ Both components have been completely rewritten using **SwiftUI** for modern perf
|
|
|
438
527
|
### Android
|
|
439
528
|
|
|
440
529
|
#### BlurView
|
|
530
|
+
|
|
441
531
|
The component uses the QmBlurView library to provide real blur effects with hardware acceleration. The implementation supports multiple blur algorithms and gracefully falls back to translucent overlay approximation on devices with limited graphics capabilities.
|
|
442
532
|
|
|
443
533
|
#### LiquidGlassView
|
|
534
|
+
|
|
444
535
|
**⚠️ Platform Limitation**: Liquid glass effects are **iOS 26+ exclusive**. On Android, `LiquidGlassView` automatically falls back to `BlurView` with enhanced blur and tint overlay to approximate the visual effect.
|
|
445
536
|
|
|
446
537
|
## Accessibility
|
|
@@ -448,10 +539,12 @@ The component uses the QmBlurView library to provide real blur effects with hard
|
|
|
448
539
|
Both components automatically respect the "Reduce Transparency" accessibility setting:
|
|
449
540
|
|
|
450
541
|
### BlurView
|
|
542
|
+
|
|
451
543
|
- **iOS**: When reduce transparency is enabled, the blur view is hidden and a fallback view with solid color is shown
|
|
452
544
|
- **Android**: The fallback color is always used as the base for the blur approximation
|
|
453
545
|
|
|
454
546
|
### LiquidGlassView
|
|
547
|
+
|
|
455
548
|
- **iOS 26+**: When reduce transparency is enabled, the liquid glass effect is hidden and a fallback view with solid color is shown
|
|
456
549
|
- **iOS < 26 & Android**: Automatically falls back to `BlurView` behavior
|
|
457
550
|
|
|
@@ -462,13 +555,13 @@ You can customize the fallback color using the `reducedTransparencyFallbackColor
|
|
|
462
555
|
This package includes full TypeScript definitions for both components:
|
|
463
556
|
|
|
464
557
|
```tsx
|
|
465
|
-
import {
|
|
466
|
-
BlurView,
|
|
558
|
+
import {
|
|
559
|
+
BlurView,
|
|
467
560
|
LiquidGlassView,
|
|
468
|
-
BlurType,
|
|
469
|
-
GlassType,
|
|
561
|
+
BlurType,
|
|
562
|
+
GlassType,
|
|
470
563
|
BlurViewProps,
|
|
471
|
-
LiquidGlassViewProps
|
|
564
|
+
LiquidGlassViewProps,
|
|
472
565
|
} from '@sbaiahmed1/react-native-blur';
|
|
473
566
|
|
|
474
567
|
// BlurType is exported for type checking
|
|
@@ -527,24 +620,27 @@ yarn android
|
|
|
527
620
|
## Performance Considerations
|
|
528
621
|
|
|
529
622
|
### BlurView
|
|
623
|
+
|
|
530
624
|
- **iOS**:
|
|
531
625
|
- **SwiftUI Implementation**: Enhanced performance with declarative UI updates
|
|
532
626
|
- **Native Blur Effects**: Hardware-accelerated `UIVisualEffectView` for performant rendering
|
|
533
627
|
- **Precise Control**: Adjustable blur intensity with smooth animations
|
|
534
|
-
- **Android**:
|
|
628
|
+
- **Android**:
|
|
535
629
|
- Real blur effects are hardware-accelerated with QmBlurView
|
|
536
630
|
- Fallback to lightweight overlay when needed on limited devices
|
|
537
631
|
|
|
538
632
|
### LiquidGlassView
|
|
633
|
+
|
|
539
634
|
- **iOS 26+**:
|
|
540
635
|
- **Hardware-Accelerated Glass**: Native `UIGlassEffect` API with minimal performance impact
|
|
541
636
|
- **Interactive Effects**: Smooth touch interactions without performance degradation
|
|
542
637
|
- **SwiftUI Powered**: Optimized declarative UI updates
|
|
543
|
-
- **iOS < 26 & Android**:
|
|
638
|
+
- **iOS < 26 & Android**:
|
|
544
639
|
- Automatic fallback to `BlurView` with enhanced blur effects
|
|
545
640
|
- Same performance characteristics as `BlurView`
|
|
546
641
|
|
|
547
642
|
### General Tips
|
|
643
|
+
|
|
548
644
|
- Avoid using too many blur/glass views simultaneously on lower-end devices
|
|
549
645
|
- Consider using `reducedTransparencyFallbackColor` for better accessibility
|
|
550
646
|
- `LiquidGlassView` automatically falls back to `BlurView` on unsupported platforms
|
|
@@ -555,6 +651,7 @@ yarn android
|
|
|
555
651
|
> **⚠️ Breaking Changes**: v4.0.0 introduces a major API redesign. See [Breaking Changes](#️-breaking-changes-in-v400) section above for migration guide.
|
|
556
652
|
|
|
557
653
|
### 🎯 Component Separation (BREAKING CHANGE)
|
|
654
|
+
|
|
558
655
|
- **Two Specialized Components**: Split single `BlurView` into dedicated `BlurView` and `LiquidGlassView` components
|
|
559
656
|
- **Removed `type` prop**: No more switching between blur/liquidGlass modes - use the appropriate component instead
|
|
560
657
|
- **Cleaner APIs**: Each component has focused props without mixing blur and glass properties
|
|
@@ -562,6 +659,7 @@ yarn android
|
|
|
562
659
|
- **Improved Type Safety**: Separate TypeScript definitions prevent incompatible prop combinations
|
|
563
660
|
|
|
564
661
|
### 🌊 Liquid Glass Effects (iOS 26+)
|
|
662
|
+
|
|
565
663
|
- Revolutionary glass effects using Apple's new UIGlassEffect API
|
|
566
664
|
- Dedicated `LiquidGlassView` component for glass-specific effects
|
|
567
665
|
- Customizable glass types: `clear` and `regular`
|
|
@@ -569,18 +667,21 @@ yarn android
|
|
|
569
667
|
- Automatic fallback to enhanced blur on older iOS versions and Android
|
|
570
668
|
|
|
571
669
|
### 🔄 SwiftUI Rewrite
|
|
670
|
+
|
|
572
671
|
- Complete iOS implementation rewritten using SwiftUI
|
|
573
672
|
- Enhanced performance with declarative UI updates
|
|
574
673
|
- Better integration with React Native's new architecture
|
|
575
674
|
- Improved blur intensity control with precise animation handling
|
|
576
675
|
|
|
577
676
|
### 📱 Enhanced Example App
|
|
677
|
+
|
|
578
678
|
- Separate demonstrations for BlurView and LiquidGlassView
|
|
579
679
|
- Interactive property controls for real-time customization
|
|
580
680
|
- Practical use case examples (cards, modals, overlays)
|
|
581
681
|
- Comparison views showing both components side by side
|
|
582
682
|
|
|
583
683
|
### 🛠️ Developer Experience
|
|
684
|
+
|
|
584
685
|
- Full TypeScript support with separate prop types for each component (`BlurViewProps`, `LiquidGlassViewProps`)
|
|
585
686
|
- Cleaner, more intuitive API design
|
|
586
687
|
- Improved component layout handling
|
|
@@ -608,6 +709,13 @@ MIT
|
|
|
608
709
|
|
|
609
710
|
## Credits
|
|
610
711
|
|
|
611
|
-
|
|
712
|
+
**Progressive Blur Implementation:**
|
|
713
|
+
|
|
714
|
+
- VariableBlur by [@nikstar](https://github.com/nikstar): https://github.com/nikstar/VariableBlur
|
|
715
|
+
- Original concept by [@jtrivedi](https://github.com/jtrivedi): https://github.com/jtrivedi/VariableBlurView
|
|
716
|
+
|
|
717
|
+
**Android Blur:**
|
|
718
|
+
|
|
719
|
+
- QMBlur library: https://github.com/QmDeve/QmBlurView
|
|
612
720
|
|
|
613
721
|
Built with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
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:QmBlurView:1.0.4.
|
|
77
|
+
implementation 'com.qmdeve:QmBlurView:1.0.4.5'
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
react {
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
package com.sbaiahmed1.reactnativeblur
|
|
2
|
+
|
|
3
|
+
import android.graphics.Color
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Enum representing different blur types with their corresponding overlay colors.
|
|
7
|
+
* Maps iOS blur types to Android overlay colors to approximate the visual appearance.
|
|
8
|
+
*/
|
|
9
|
+
enum class BlurType(val overlayColor: Int) {
|
|
10
|
+
XLIGHT(Color.argb(140, 240, 240, 240)),
|
|
11
|
+
LIGHT(Color.argb(42, 255, 255, 255)),
|
|
12
|
+
DARK(Color.argb(120, 26, 22, 22)),
|
|
13
|
+
EXTRA_DARK(Color.argb(102, 35, 35, 35)),
|
|
14
|
+
REGULAR(Color.argb(35, 255, 255, 255)),
|
|
15
|
+
PROMINENT(Color.argb(140, 240, 240, 240)),
|
|
16
|
+
SYSTEM_ULTRA_THIN_MATERIAL(Color.argb(75, 240, 240, 240)),
|
|
17
|
+
SYSTEM_ULTRA_THIN_MATERIAL_LIGHT(Color.argb(77, 240, 240, 240)),
|
|
18
|
+
SYSTEM_ULTRA_THIN_MATERIAL_DARK(Color.argb(65, 40, 40, 40)),
|
|
19
|
+
SYSTEM_THIN_MATERIAL(Color.argb(102, 240, 240, 240)),
|
|
20
|
+
SYSTEM_THIN_MATERIAL_LIGHT(Color.argb(105, 240, 240, 240)),
|
|
21
|
+
SYSTEM_THIN_MATERIAL_DARK(Color.argb(102, 35, 35, 35)),
|
|
22
|
+
SYSTEM_MATERIAL(Color.argb(140, 245, 245, 245)),
|
|
23
|
+
SYSTEM_MATERIAL_LIGHT(Color.argb(140, 248, 248, 248)),
|
|
24
|
+
SYSTEM_MATERIAL_DARK(Color.argb(215, 65, 60, 60)),
|
|
25
|
+
SYSTEM_THICK_MATERIAL(Color.argb(210, 248, 248, 248)),
|
|
26
|
+
SYSTEM_THICK_MATERIAL_LIGHT(Color.argb(212, 248, 248, 248)),
|
|
27
|
+
SYSTEM_THICK_MATERIAL_DARK(Color.argb(165, 35, 35, 35)),
|
|
28
|
+
SYSTEM_CHROME_MATERIAL(Color.argb(165, 248, 248, 248)),
|
|
29
|
+
SYSTEM_CHROME_MATERIAL_LIGHT(Color.argb(167, 248, 248, 248)),
|
|
30
|
+
SYSTEM_CHROME_MATERIAL_DARK(Color.argb(100, 32, 32, 32));
|
|
31
|
+
|
|
32
|
+
companion object {
|
|
33
|
+
/**
|
|
34
|
+
* Get BlurType from string, with fallback to LIGHT for unknown types.
|
|
35
|
+
*/
|
|
36
|
+
fun fromString(type: String): BlurType {
|
|
37
|
+
return when (type.lowercase()) {
|
|
38
|
+
"xlight" -> XLIGHT
|
|
39
|
+
"light" -> LIGHT
|
|
40
|
+
"dark" -> DARK
|
|
41
|
+
"extradark" -> EXTRA_DARK
|
|
42
|
+
"regular" -> REGULAR
|
|
43
|
+
"prominent" -> PROMINENT
|
|
44
|
+
"systemultrathinmaterial" -> SYSTEM_ULTRA_THIN_MATERIAL
|
|
45
|
+
"systemultrathinmateriallight" -> SYSTEM_ULTRA_THIN_MATERIAL_LIGHT
|
|
46
|
+
"systemultrathinmaterialdark" -> SYSTEM_ULTRA_THIN_MATERIAL_DARK
|
|
47
|
+
"systemthinmaterial" -> SYSTEM_THIN_MATERIAL
|
|
48
|
+
"systemthinmateriallight" -> SYSTEM_THIN_MATERIAL_LIGHT
|
|
49
|
+
"systemthinmaterialdark" -> SYSTEM_THIN_MATERIAL_DARK
|
|
50
|
+
"systemmaterial" -> SYSTEM_MATERIAL
|
|
51
|
+
"systemmateriallight" -> SYSTEM_MATERIAL_LIGHT
|
|
52
|
+
"systemmaterialdark" -> SYSTEM_MATERIAL_DARK
|
|
53
|
+
"systemthickmaterial" -> SYSTEM_THICK_MATERIAL
|
|
54
|
+
"systemthickmateriallight" -> SYSTEM_THICK_MATERIAL_LIGHT
|
|
55
|
+
"systemthickmaterialdark" -> SYSTEM_THICK_MATERIAL_DARK
|
|
56
|
+
"systemchromematerial" -> SYSTEM_CHROME_MATERIAL
|
|
57
|
+
"systemchromemateriallight" -> SYSTEM_CHROME_MATERIAL_LIGHT
|
|
58
|
+
"systemchromematerialdark" -> SYSTEM_CHROME_MATERIAL_DARK
|
|
59
|
+
else -> XLIGHT // default fallback
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -10,6 +10,7 @@ class ReactNativeBlurViewPackage : ReactPackage {
|
|
|
10
10
|
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
11
11
|
val viewManagers: MutableList<ViewManager<*, *>> = ArrayList()
|
|
12
12
|
viewManagers.add(ReactNativeBlurViewManager())
|
|
13
|
+
viewManagers.add(ReactNativeProgressiveBlurViewManager())
|
|
13
14
|
return viewManagers
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -4,7 +4,8 @@ import android.content.Context
|
|
|
4
4
|
import android.graphics.Color
|
|
5
5
|
import android.util.AttributeSet
|
|
6
6
|
import android.util.Log
|
|
7
|
-
import
|
|
7
|
+
import android.util.TypedValue
|
|
8
|
+
import com.qmdeve.blurview.widget.BlurViewGroup
|
|
8
9
|
import androidx.core.graphics.toColorInt
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -14,7 +15,7 @@ import androidx.core.graphics.toColorInt
|
|
|
14
15
|
* QmBlurView is a high-performance blur library that uses native blur algorithms
|
|
15
16
|
* implemented with underlying Native calls for optimal performance.
|
|
16
17
|
*/
|
|
17
|
-
class ReactNativeBlurView :
|
|
18
|
+
class ReactNativeBlurView : BlurViewGroup {
|
|
18
19
|
private var currentBlurRadius = DEFAULT_BLUR_RADIUS
|
|
19
20
|
private var currentOverlayColor = Color.TRANSPARENT
|
|
20
21
|
private var currentCornerRadius = 0f
|
|
@@ -79,7 +80,7 @@ class ReactNativeBlurView : BlurView {
|
|
|
79
80
|
// setBlurRadius takes Float, setOverlayColor takes Int, setCornerRadius takes Float (in dp)
|
|
80
81
|
super.setBlurRadius(currentBlurRadius)
|
|
81
82
|
super.setOverlayColor(currentOverlayColor)
|
|
82
|
-
|
|
83
|
+
updateCornerRadius()
|
|
83
84
|
|
|
84
85
|
// Set transparent background to prevent visual artifacts
|
|
85
86
|
super.setBackgroundColor(Color.TRANSPARENT)
|
|
@@ -150,46 +151,6 @@ class ReactNativeBlurView : BlurView {
|
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
|
|
153
|
-
/**
|
|
154
|
-
* Enum representing different blur types with their corresponding overlay colors.
|
|
155
|
-
* Maps iOS blur types to Android overlay colors to approximate the visual appearance.
|
|
156
|
-
*/
|
|
157
|
-
enum class BlurType(val overlayColor: Int) {
|
|
158
|
-
XLIGHT(Color.argb(25, 255, 255, 255)),
|
|
159
|
-
LIGHT(Color.argb(40, 255, 255, 255)),
|
|
160
|
-
DARK(Color.argb(60, 0, 0, 0)),
|
|
161
|
-
EXTRA_DARK(Color.argb(80, 0, 0, 0)),
|
|
162
|
-
REGULAR(Color.argb(50, 255, 255, 255)),
|
|
163
|
-
PROMINENT(Color.argb(70, 255, 255, 255)),
|
|
164
|
-
SYSTEM_ULTRA_THIN_MATERIAL(Color.argb(20, 255, 255, 255)),
|
|
165
|
-
SYSTEM_THIN_MATERIAL(Color.argb(35, 255, 255, 255)),
|
|
166
|
-
SYSTEM_MATERIAL(Color.argb(50, 255, 255, 255)),
|
|
167
|
-
SYSTEM_THICK_MATERIAL(Color.argb(65, 255, 255, 255)),
|
|
168
|
-
SYSTEM_CHROME_MATERIAL(Color.argb(45, 240, 240, 240));
|
|
169
|
-
|
|
170
|
-
companion object {
|
|
171
|
-
/**
|
|
172
|
-
* Get BlurType from string, with fallback to LIGHT for unknown types.
|
|
173
|
-
*/
|
|
174
|
-
fun fromString(type: String): BlurType {
|
|
175
|
-
return when (type.lowercase()) {
|
|
176
|
-
"xlight" -> XLIGHT
|
|
177
|
-
"light" -> LIGHT
|
|
178
|
-
"dark" -> DARK
|
|
179
|
-
"extradark" -> EXTRA_DARK
|
|
180
|
-
"regular" -> REGULAR
|
|
181
|
-
"prominent" -> PROMINENT
|
|
182
|
-
"systemultrathinmaterial" -> SYSTEM_ULTRA_THIN_MATERIAL
|
|
183
|
-
"systemthinmaterial" -> SYSTEM_THIN_MATERIAL
|
|
184
|
-
"systemmaterial" -> SYSTEM_MATERIAL
|
|
185
|
-
"systemthickmaterial" -> SYSTEM_THICK_MATERIAL
|
|
186
|
-
"systemchromematerial" -> SYSTEM_CHROME_MATERIAL
|
|
187
|
-
else -> LIGHT // default fallback
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
154
|
/**
|
|
194
155
|
* Set the blur type which determines the overlay color.
|
|
195
156
|
* @param type The blur type string (case-insensitive)
|
|
@@ -329,4 +290,63 @@ class ReactNativeBlurView : BlurView {
|
|
|
329
290
|
}
|
|
330
291
|
}
|
|
331
292
|
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Set the border radius from React Native StyleSheet.
|
|
296
|
+
* React Native provides values in logical pixels (dp), which we convert for the native view.
|
|
297
|
+
* @param radius The border radius value in dp
|
|
298
|
+
*/
|
|
299
|
+
fun setBorderRadius(radius: Float) {
|
|
300
|
+
currentCornerRadius = radius
|
|
301
|
+
logDebug("setBorderRadius: $radius dp")
|
|
302
|
+
updateCornerRadius()
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Convert pixels to density-independent pixels and update the corner radius.
|
|
307
|
+
* QmBlurView's setCornerRadius expects values in pixels, and React Native already
|
|
308
|
+
* provides values in dp, so we need to convert from dp to pixels.
|
|
309
|
+
*/
|
|
310
|
+
private fun updateCornerRadius() {
|
|
311
|
+
try {
|
|
312
|
+
// Convert from dp (React Native) to pixels (Android)
|
|
313
|
+
val radiusInPixels = TypedValue.applyDimension(
|
|
314
|
+
TypedValue.COMPLEX_UNIT_DIP,
|
|
315
|
+
currentCornerRadius,
|
|
316
|
+
context.resources.displayMetrics
|
|
317
|
+
)
|
|
318
|
+
super.setCornerRadius(radiusInPixels)
|
|
319
|
+
logDebug("Updated corner radius: ${currentCornerRadius}dp -> ${radiusInPixels}px")
|
|
320
|
+
} catch (e: Exception) {
|
|
321
|
+
logError("Failed to update corner radius: ${e.message}", e)
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* 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
|
+
*/
|
|
334
|
+
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
|
+
}
|
|
351
|
+
}
|
|
332
352
|
}
|