@sbaiahmed1/react-native-blur 4.4.1 → 4.5.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 +58 -10
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeProgressiveBlurView.kt +72 -33
- package/ios/Helpers/BlurStyleHelpers.swift +3 -1
- package/ios/Helpers/ReactNativeVibrancyViewHelper.swift +22 -0
- package/ios/ReactNativeVibrancyView.h +15 -0
- package/ios/ReactNativeVibrancyView.mm +92 -0
- package/ios/ReactNativeVibrancyViewManager.h +5 -0
- package/ios/ReactNativeVibrancyViewManager.mm +32 -0
- package/ios/Views/LiquidGlassContainerView.swift +30 -4
- package/ios/Views/VariableBlurView.swift +139 -13
- package/ios/Views/VibrancyEffectView.swift +124 -0
- package/lib/module/ProgressiveBlurView.js +1 -8
- package/lib/module/ProgressiveBlurView.js.map +1 -1
- package/lib/module/ReactNativeProgressiveBlurViewNativeComponent.ts +2 -1
- package/lib/module/ReactNativeVibrancyViewNativeComponent.ts +38 -0
- package/lib/module/VibrancyView.js +43 -0
- package/lib/module/VibrancyView.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/ProgressiveBlurView.d.ts +1 -0
- package/lib/typescript/src/ProgressiveBlurView.d.ts.map +1 -1
- package/lib/typescript/src/ReactNativeProgressiveBlurViewNativeComponent.d.ts +1 -1
- package/lib/typescript/src/ReactNativeProgressiveBlurViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/ReactNativeVibrancyViewNativeComponent.d.ts +10 -0
- package/lib/typescript/src/ReactNativeVibrancyViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/VibrancyView.d.ts +37 -0
- package/lib/typescript/src/VibrancyView.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/ProgressiveBlurView.tsx +2 -5
- package/src/ReactNativeProgressiveBlurViewNativeComponent.ts +2 -1
- package/src/ReactNativeVibrancyViewNativeComponent.ts +38 -0
- package/src/VibrancyView.tsx +80 -0
- package/src/index.tsx +4 -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 **six specialized components** for advanced visual effects: `BlurView` for native blur effects, `VibrancyView` for iOS vibrancy effects, `LiquidGlassView` for cutting-edge liquid glass effects on iOS 26+ (with Android fallback to enhanced blur), `LiquidGlassContainer` for iOS 26+ glass container effects with configurable spacing, `ProgressiveBlurView` for smooth, variable blur transitions, and `BlurSwitch` for beautiful blur switch buttons on Android.
|
|
4
4
|
|
|
5
5
|
> **⚠️ Breaking Changes**: If upgrading from 3.x, see [Breaking Changes](#️-breaking-changes-in-v400) section.
|
|
6
6
|
|
|
@@ -28,6 +28,12 @@ A modern React Native library providing **five specialized components** for adva
|
|
|
28
28
|
<br>
|
|
29
29
|
<em>iOS (left) and Android (right) blur effects in action</em>
|
|
30
30
|
<br>
|
|
31
|
+
<br>
|
|
32
|
+
<video src="demos/vibrancy_iOS.mov" width="300" autoplay loop muted playsinline></video>
|
|
33
|
+
<br>
|
|
34
|
+
<em>Vibrancy Effect (iOS only)</em>
|
|
35
|
+
<br>
|
|
36
|
+
<br>
|
|
31
37
|
<em>Liquid Glass effect in action (iOS 26+ only)</em>
|
|
32
38
|
<br>
|
|
33
39
|
<strong>⚠️ Android automatically falls back to enhanced blur with tint overlay</strong>
|
|
@@ -258,7 +264,7 @@ The implementation automatically handles different Android versions:
|
|
|
258
264
|
|
|
259
265
|
## Usage
|
|
260
266
|
|
|
261
|
-
The library now provides **
|
|
267
|
+
The library now provides **six specialized components** for different visual effects:
|
|
262
268
|
|
|
263
269
|
### BlurView - Standard Blur Effects
|
|
264
270
|
|
|
@@ -341,6 +347,29 @@ function GradientBlurComponent() {
|
|
|
341
347
|
}
|
|
342
348
|
```
|
|
343
349
|
|
|
350
|
+
#### Center Blur (new direction)
|
|
351
|
+
|
|
352
|
+
`direction="blurredCenterClearTopAndBottom"` creates a long blur body that peaks in the center and fades to clear at both edges.
|
|
353
|
+
|
|
354
|
+
```tsx
|
|
355
|
+
<ProgressiveBlurView
|
|
356
|
+
blurType="regular"
|
|
357
|
+
blurAmount={35}
|
|
358
|
+
direction="blurredCenterClearTopAndBottom"
|
|
359
|
+
startOffset={0} // keep 0 for longest blur body; raise toward 0.3 to shorten
|
|
360
|
+
style={{ height: 220, borderRadius: 16 }}
|
|
361
|
+
>
|
|
362
|
+
<Text>Clear at top</Text>
|
|
363
|
+
<Text>Blurred at center</Text>
|
|
364
|
+
<Text>Clear at bottom</Text>
|
|
365
|
+
</ProgressiveBlurView>
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
Tips:
|
|
369
|
+
- `startOffset` shifts where the blur plateau begins; 0 = longest body, higher = shorter.
|
|
370
|
+
- `blurAmount` controls peak intensity; center direction balances strength per platform.
|
|
371
|
+
- Works on iOS and Android with matching props.
|
|
372
|
+
|
|
344
373
|
#### Locked Content Example
|
|
345
374
|
|
|
346
375
|
Perfect for paywall/premium content:
|
|
@@ -588,6 +617,17 @@ All props are optional and have sensible defaults.
|
|
|
588
617
|
| `style` | `ViewStyle` | `undefined` | Style object for the blur view |
|
|
589
618
|
| `children` | `ReactNode` | `undefined` | Child components to render inside the blur view |
|
|
590
619
|
|
|
620
|
+
### VibrancyView Props
|
|
621
|
+
|
|
622
|
+
All props are optional and have sensible defaults.
|
|
623
|
+
|
|
624
|
+
| Prop | Type | Default | Description |
|
|
625
|
+
| ------------ | ------------ | ----------- | ----------------------------------------------- |
|
|
626
|
+
| `blurType` | `BlurType` | `'xlight'` | The type of blur/vibrancy effect to apply |
|
|
627
|
+
| `blurAmount` | `number` | `10.0` | The intensity of the blur effect (0-100) |
|
|
628
|
+
| `style` | `ViewStyle` | `undefined` | Style object for the vibrancy view |
|
|
629
|
+
| `children` | `ReactNode` | `undefined` | Child components to render inside the vibrancy view |
|
|
630
|
+
|
|
591
631
|
### ProgressiveBlurView Props
|
|
592
632
|
|
|
593
633
|
All props are optional and have sensible defaults.
|
|
@@ -596,7 +636,7 @@ All props are optional and have sensible defaults.
|
|
|
596
636
|
| ---------------------------------- | ---------------------------------------------------- | ------------------------- | ---------------------------------------------------- |
|
|
597
637
|
| `blurType` | `BlurType` | `'regular'` | The type of blur effect to apply |
|
|
598
638
|
| `blurAmount` | `number` | `20.0` | Maximum blur radius in pixels |
|
|
599
|
-
| `direction` | `'blurredTopClearBottom' \| 'blurredBottomClearTop'` | `'blurredTopClearBottom'` | Direction of the blur gradient |
|
|
639
|
+
| `direction` | `'blurredTopClearBottom' \| 'blurredBottomClearTop' \| 'blurredCenterClearTopAndBottom'` | `'blurredTopClearBottom'` | Direction of the blur gradient |
|
|
600
640
|
| `startOffset` | `number` | `0.0` | Where the gradient starts (0.0 to 1.0) |
|
|
601
641
|
| `reducedTransparencyFallbackColor` | `string` | `'#FFFFFF'` | Fallback color when reduced transparency is enabled |
|
|
602
642
|
| `overlayColor` | `ColorValue` | `undefined` | The overlay color to apply on top of the blur effect |
|
|
@@ -700,6 +740,11 @@ Both components have been completely rewritten using **SwiftUI** for modern perf
|
|
|
700
740
|
- **Older iOS**: Graceful fallback to standard blur effects
|
|
701
741
|
- **SwiftUI Integration**: Leverages SwiftUI's declarative UI for better performance and maintainability
|
|
702
742
|
|
|
743
|
+
#### VibrancyView
|
|
744
|
+
|
|
745
|
+
- **iOS**: Uses native `UIVibrancyEffect` to create vibrant content that shines through the blur
|
|
746
|
+
- **Integration**: Works seamlessly with `UIVisualEffectView` hierarchies
|
|
747
|
+
|
|
703
748
|
#### LiquidGlassView
|
|
704
749
|
|
|
705
750
|
- **iOS 26+**: Uses native `UIGlassEffect` API for true liquid glass effects with customizable tint colors and opacity
|
|
@@ -712,11 +757,7 @@ Both components have been completely rewritten using **SwiftUI** for modern perf
|
|
|
712
757
|
|
|
713
758
|
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.
|
|
714
759
|
|
|
715
|
-
####
|
|
716
|
-
|
|
717
|
-
**⚠️ 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.
|
|
718
|
-
|
|
719
|
-
## Accessibility
|
|
760
|
+
#### L+ssibility
|
|
720
761
|
|
|
721
762
|
All components automatically respect the "Reduce Transparency" accessibility setting:
|
|
722
763
|
|
|
@@ -747,14 +788,16 @@ import {
|
|
|
747
788
|
LiquidGlassView,
|
|
748
789
|
LiquidGlassContainer,
|
|
749
790
|
ProgressiveBlurView,
|
|
750
|
-
|
|
791
|
+
BlurView,
|
|
792
|
+
VibrancySwitch,
|
|
751
793
|
BlurType,
|
|
752
794
|
GlassType,
|
|
753
795
|
BlurViewProps,
|
|
754
796
|
LiquidGlassViewProps,
|
|
755
797
|
LiquidGlassContainerProps,
|
|
756
798
|
ProgressiveBlurViewProps,
|
|
757
|
-
|
|
799
|
+
BlurViewProps,
|
|
800
|
+
VibrancySwitchProps,
|
|
758
801
|
} from '@sbaiahmed1/react-native-blur';
|
|
759
802
|
|
|
760
803
|
// BlurType is exported for type checking
|
|
@@ -768,6 +811,11 @@ interface MyBlurComponentProps {
|
|
|
768
811
|
blurProps: BlurViewProps;
|
|
769
812
|
}
|
|
770
813
|
|
|
814
|
+
// VibrancyViewProps for vibrancy component props
|
|
815
|
+
interface MyVibrancyComponentProps {
|
|
816
|
+
vibrancyProps: VibrancyViewProps;
|
|
817
|
+
}
|
|
818
|
+
|
|
771
819
|
// LiquidGlassViewProps for glass component props
|
|
772
820
|
interface MyGlassComponentProps {
|
|
773
821
|
glassProps: LiquidGlassViewProps;
|
package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeProgressiveBlurView.kt
CHANGED
|
@@ -14,6 +14,7 @@ import android.widget.FrameLayout
|
|
|
14
14
|
import android.view.View.MeasureSpec
|
|
15
15
|
import com.qmdeve.blurview.widget.BlurView
|
|
16
16
|
import androidx.core.graphics.toColorInt
|
|
17
|
+
import kotlin.math.max
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Android implementation of React Native ProgressiveBlurView component.
|
|
@@ -146,42 +147,74 @@ class ReactNativeProgressiveBlurView : FrameLayout {
|
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
try {
|
|
149
|
-
val
|
|
150
|
-
"
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
val
|
|
154
|
-
|
|
150
|
+
val gradient = when (currentDirection) {
|
|
151
|
+
"center" -> {
|
|
152
|
+
val startEdge = max(currentStartOffset, 0.01f)
|
|
153
|
+
val endEdge = 1f - startEdge
|
|
154
|
+
val centerLow = 0.2f + startEdge
|
|
155
|
+
val centerHigh = 0.8f - startEdge
|
|
156
|
+
|
|
157
|
+
LinearGradient(
|
|
158
|
+
0f,
|
|
159
|
+
0f,
|
|
160
|
+
0f,
|
|
161
|
+
height.toFloat(),
|
|
162
|
+
intArrayOf(
|
|
163
|
+
Color.TRANSPARENT,
|
|
164
|
+
Color.TRANSPARENT,
|
|
165
|
+
Color.WHITE,
|
|
166
|
+
Color.WHITE,
|
|
167
|
+
Color.TRANSPARENT,
|
|
168
|
+
Color.TRANSPARENT
|
|
169
|
+
),
|
|
170
|
+
floatArrayOf(
|
|
171
|
+
0f,
|
|
172
|
+
startEdge,
|
|
173
|
+
centerLow,
|
|
174
|
+
centerHigh,
|
|
175
|
+
endEdge,
|
|
176
|
+
1f
|
|
177
|
+
),
|
|
178
|
+
Shader.TileMode.CLAMP
|
|
179
|
+
)
|
|
155
180
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
181
|
+
else -> {
|
|
182
|
+
val (x0, y0, x1, y1) = when (currentDirection) {
|
|
183
|
+
"bottomToTop" -> {
|
|
184
|
+
// Blur at bottom, clear at top
|
|
185
|
+
// point0 (TRANSPARENT/clear) at top, point1 (WHITE/blur) at bottom adjusted by offset
|
|
186
|
+
val offsetPixels = height * currentStartOffset
|
|
187
|
+
floatArrayOf(0f, 0f, 0f, height - offsetPixels)
|
|
188
|
+
}
|
|
189
|
+
"topToBottom" -> {
|
|
190
|
+
// Blur at top, clear at bottom (default)
|
|
191
|
+
// point0 (TRANSPARENT/clear) at bottom, point1 (WHITE/blur) at top adjusted by offset
|
|
192
|
+
val offsetPixels = height * currentStartOffset
|
|
193
|
+
floatArrayOf(0f, height.toFloat(), 0f, offsetPixels)
|
|
194
|
+
}
|
|
195
|
+
"leftToRight" -> {
|
|
196
|
+
val offsetPixels = width * currentStartOffset
|
|
197
|
+
floatArrayOf(offsetPixels, 0f, width.toFloat(), 0f)
|
|
198
|
+
}
|
|
199
|
+
"rightToLeft" -> {
|
|
200
|
+
val offsetPixels = width * currentStartOffset
|
|
201
|
+
floatArrayOf(width.toFloat(), 0f, offsetPixels, 0f)
|
|
202
|
+
}
|
|
203
|
+
else -> floatArrayOf(0f, 0f, 0f, height.toFloat())
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
LinearGradient(
|
|
207
|
+
x0, y0, x1, y1,
|
|
208
|
+
intArrayOf(Color.TRANSPARENT, Color.WHITE),
|
|
209
|
+
floatArrayOf(0f, 1f),
|
|
210
|
+
Shader.TileMode.CLAMP
|
|
211
|
+
)
|
|
161
212
|
}
|
|
162
|
-
"leftToRight" -> {
|
|
163
|
-
val offsetPixels = width * currentStartOffset
|
|
164
|
-
floatArrayOf(offsetPixels, 0f, width.toFloat(), 0f)
|
|
165
|
-
}
|
|
166
|
-
"rightToLeft" -> {
|
|
167
|
-
val offsetPixels = width * currentStartOffset
|
|
168
|
-
floatArrayOf(width.toFloat(), 0f, offsetPixels, 0f)
|
|
169
|
-
}
|
|
170
|
-
else -> floatArrayOf(0f, 0f, 0f, height.toFloat())
|
|
171
213
|
}
|
|
172
214
|
|
|
173
|
-
// Create gradient: fully transparent -> fully opaque
|
|
174
|
-
// This masks the blur: opaque = blur visible, transparent = blur hidden (clear)
|
|
175
|
-
val gradient = LinearGradient(
|
|
176
|
-
x0, y0, x1, y1,
|
|
177
|
-
intArrayOf(Color.TRANSPARENT, Color.WHITE),
|
|
178
|
-
floatArrayOf(0f, 1f),
|
|
179
|
-
Shader.TileMode.CLAMP
|
|
180
|
-
)
|
|
181
|
-
|
|
182
215
|
gradientPaint.shader = gradient
|
|
183
216
|
|
|
184
|
-
logDebug("Updated gradient: direction=$currentDirection,
|
|
217
|
+
logDebug("Updated gradient: direction=$currentDirection, offset=$currentStartOffset")
|
|
185
218
|
invalidate()
|
|
186
219
|
|
|
187
220
|
} catch (e: Exception) {
|
|
@@ -232,8 +265,13 @@ class ReactNativeProgressiveBlurView : FrameLayout {
|
|
|
232
265
|
* @param amount The blur amount value (0-100), will be mapped to Android's 0-25 radius range
|
|
233
266
|
*/
|
|
234
267
|
fun setBlurAmount(amount: Float) {
|
|
235
|
-
|
|
236
|
-
|
|
268
|
+
var radius = mapBlurAmountToRadius(amount)
|
|
269
|
+
if (currentDirection == "center") {
|
|
270
|
+
// Center direction tends to look stronger; scale it down for parity with iOS
|
|
271
|
+
radius *= 0.35f
|
|
272
|
+
}
|
|
273
|
+
currentBlurRadius = radius
|
|
274
|
+
logDebug("setBlurAmount: $amount -> $currentBlurRadius (direction=$currentDirection)")
|
|
237
275
|
|
|
238
276
|
try {
|
|
239
277
|
blurView?.setBlurRadius(currentBlurRadius)
|
|
@@ -251,8 +289,9 @@ class ReactNativeProgressiveBlurView : FrameLayout {
|
|
|
251
289
|
currentDirection = when (direction.lowercase()) {
|
|
252
290
|
"blurredbottomcleartop", "bottomtotop", "bottom" -> "bottomToTop"
|
|
253
291
|
"blurredtopclearbottom", "toptobottom", "top" -> "topToBottom"
|
|
292
|
+
"blurredcentercleartopandbottom", "center" -> "center"
|
|
254
293
|
"blurredlefttoclearright", "lefttoright", "left" -> "leftToRight"
|
|
255
|
-
"
|
|
294
|
+
"blurredrighttoclearleft", "righttoleft", "right" -> "rightToLeft"
|
|
256
295
|
else -> {
|
|
257
296
|
logWarning("Unknown direction: $direction, defaulting to topToBottom")
|
|
258
297
|
"topToBottom"
|
|
@@ -56,8 +56,9 @@ func blurStyleFromString(_ styleString: String) -> UIBlurEffect.Style {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/// Maps string glass type names to Glass effect values (iOS 26.0+)
|
|
59
|
+
#if compiler(>=6.2)
|
|
59
60
|
@available(iOS 26.0, *)
|
|
60
|
-
func glassEffectFromString(_ glassTypeString: String) ->
|
|
61
|
+
func glassEffectFromString(_ glassTypeString: String) -> UIGlassEffect.Style {
|
|
61
62
|
switch glassTypeString {
|
|
62
63
|
case "regular":
|
|
63
64
|
return .regular
|
|
@@ -67,6 +68,7 @@ func glassEffectFromString(_ glassTypeString: String) -> Glass {
|
|
|
67
68
|
return .clear
|
|
68
69
|
}
|
|
69
70
|
}
|
|
71
|
+
#endif
|
|
70
72
|
|
|
71
73
|
// MARK: - Blur Amount Mapping
|
|
72
74
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
|
|
3
|
+
@objc public class ReactNativeVibrancyViewHelper: NSObject {
|
|
4
|
+
|
|
5
|
+
@objc public static func createVibrancyViewWithFrame(_ frame: CGRect) -> VibrancyEffectView {
|
|
6
|
+
let view = VibrancyEffectView(effect: nil)
|
|
7
|
+
view.frame = frame
|
|
8
|
+
return view
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@objc public static func updateVibrancyView(_ view: VibrancyEffectView, withBlurType blurType: String) {
|
|
12
|
+
view.blurType = blurType
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@objc public static func updateVibrancyView(_ view: VibrancyEffectView, withBlurAmount blurAmount: Double) {
|
|
16
|
+
view.blurAmount = blurAmount
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@objc public static func getContentView(_ view: VibrancyEffectView) -> UIView {
|
|
20
|
+
return view.contentView
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#import <React/RCTViewComponentView.h>
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
|
|
4
|
+
#ifndef ReactNativeVibrancyViewNativeComponent_h
|
|
5
|
+
#define ReactNativeVibrancyViewNativeComponent_h
|
|
6
|
+
|
|
7
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
8
|
+
|
|
9
|
+
@interface ReactNativeVibrancyView : RCTViewComponentView
|
|
10
|
+
|
|
11
|
+
@end
|
|
12
|
+
|
|
13
|
+
NS_ASSUME_NONNULL_END
|
|
14
|
+
|
|
15
|
+
#endif /* ReactNativeVibrancyViewNativeComponent_h */
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#import "ReactNativeVibrancyView.h"
|
|
2
|
+
|
|
3
|
+
#import <react/renderer/components/ReactNativeBlurViewSpec/ComponentDescriptors.h>
|
|
4
|
+
#import <react/renderer/components/ReactNativeBlurViewSpec/EventEmitters.h>
|
|
5
|
+
#import <react/renderer/components/ReactNativeBlurViewSpec/Props.h>
|
|
6
|
+
#import <react/renderer/components/ReactNativeBlurViewSpec/RCTComponentViewHelpers.h>
|
|
7
|
+
|
|
8
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
9
|
+
|
|
10
|
+
#if __has_include("ReactNativeBlur-Swift.h")
|
|
11
|
+
#import "ReactNativeBlur-Swift.h"
|
|
12
|
+
#else
|
|
13
|
+
#import <ReactNativeBlur/ReactNativeBlur-Swift.h>
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
using namespace facebook::react;
|
|
17
|
+
|
|
18
|
+
@interface ReactNativeVibrancyView () <RCTReactNativeVibrancyViewViewProtocol>
|
|
19
|
+
@end
|
|
20
|
+
|
|
21
|
+
@implementation ReactNativeVibrancyView {
|
|
22
|
+
VibrancyEffectView *_vibrancyView;
|
|
23
|
+
Props::Shared _props;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
27
|
+
{
|
|
28
|
+
return concreteComponentDescriptorProvider<ReactNativeVibrancyViewComponentDescriptor>();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
32
|
+
{
|
|
33
|
+
if (self = [super initWithFrame:frame]) {
|
|
34
|
+
static const auto defaultProps = std::make_shared<const ReactNativeVibrancyViewProps>();
|
|
35
|
+
_props = defaultProps;
|
|
36
|
+
|
|
37
|
+
_vibrancyView = [ReactNativeVibrancyViewHelper createVibrancyViewWithFrame:frame];
|
|
38
|
+
|
|
39
|
+
// Initialize props
|
|
40
|
+
const auto &props = *std::static_pointer_cast<const ReactNativeVibrancyViewProps>(_props);
|
|
41
|
+
NSString *blurType = [[NSString alloc] initWithUTF8String:toString(props.blurType).c_str()];
|
|
42
|
+
[ReactNativeVibrancyViewHelper updateVibrancyView:_vibrancyView withBlurType:blurType];
|
|
43
|
+
|
|
44
|
+
[ReactNativeVibrancyViewHelper updateVibrancyView:_vibrancyView withBlurAmount:props.blurAmount];
|
|
45
|
+
|
|
46
|
+
_vibrancyView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
47
|
+
[self addSubview:_vibrancyView];
|
|
48
|
+
}
|
|
49
|
+
return self;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
53
|
+
{
|
|
54
|
+
const auto &oldViewProps = *std::static_pointer_cast<ReactNativeVibrancyViewProps const>(_props);
|
|
55
|
+
const auto &newViewProps = *std::static_pointer_cast<ReactNativeVibrancyViewProps const>(props);
|
|
56
|
+
|
|
57
|
+
if (oldViewProps.blurType != newViewProps.blurType) {
|
|
58
|
+
NSString *blurType = [[NSString alloc] initWithUTF8String:toString(newViewProps.blurType).c_str()];
|
|
59
|
+
[ReactNativeVibrancyViewHelper updateVibrancyView:_vibrancyView withBlurType:blurType];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (oldViewProps.blurAmount != newViewProps.blurAmount) {
|
|
63
|
+
[ReactNativeVibrancyViewHelper updateVibrancyView:_vibrancyView withBlurAmount:newViewProps.blurAmount];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
_props = props;
|
|
67
|
+
[super updateProps:props oldProps:oldProps];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
- (void)layoutSubviews
|
|
71
|
+
{
|
|
72
|
+
[super layoutSubviews];
|
|
73
|
+
_vibrancyView.frame = self.bounds;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
77
|
+
{
|
|
78
|
+
UIView *contentView = [ReactNativeVibrancyViewHelper getContentView:_vibrancyView];
|
|
79
|
+
[contentView insertSubview:childComponentView atIndex:index];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
83
|
+
{
|
|
84
|
+
[childComponentView removeFromSuperview];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@end
|
|
88
|
+
|
|
89
|
+
Class<RCTComponentViewProtocol> ReactNativeVibrancyViewCls(void)
|
|
90
|
+
{
|
|
91
|
+
return ReactNativeVibrancyView.class;
|
|
92
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#import "ReactNativeVibrancyViewManager.h"
|
|
2
|
+
|
|
3
|
+
#if __has_include("ReactNativeBlur-Swift.h")
|
|
4
|
+
#import "ReactNativeBlur-Swift.h"
|
|
5
|
+
#else
|
|
6
|
+
#import <ReactNativeBlur/ReactNativeBlur-Swift.h>
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
#import <React/RCTUIManager.h>
|
|
10
|
+
|
|
11
|
+
@implementation ReactNativeVibrancyViewManager
|
|
12
|
+
|
|
13
|
+
RCT_EXPORT_MODULE(ReactNativeVibrancyView)
|
|
14
|
+
|
|
15
|
+
- (UIView *)view
|
|
16
|
+
{
|
|
17
|
+
return [ReactNativeVibrancyViewHelper createVibrancyViewWithFrame:CGRectZero];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
RCT_CUSTOM_VIEW_PROPERTY(blurType, NSString, VibrancyEffectView)
|
|
21
|
+
{
|
|
22
|
+
NSString *blurType = json ? [RCTConvert NSString:json] : @"xlight";
|
|
23
|
+
[ReactNativeVibrancyViewHelper updateVibrancyView:view withBlurType:blurType];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
RCT_CUSTOM_VIEW_PROPERTY(blurAmount, NSNumber, VibrancyEffectView)
|
|
27
|
+
{
|
|
28
|
+
double amount = json ? [RCTConvert double:json] : 10.0;
|
|
29
|
+
[ReactNativeVibrancyViewHelper updateVibrancyView:view withBlurAmount:amount];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@end
|
|
@@ -82,6 +82,7 @@ import UIKit
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
private func updateEffect() {
|
|
85
|
+
// Check if we can use the new API (iOS 26+)
|
|
85
86
|
if #available(iOS 26.0, *) {
|
|
86
87
|
#if compiler(>=6.2)
|
|
87
88
|
let style: UIGlassEffect.Style = glassType == "regular" ? .regular : .clear
|
|
@@ -96,6 +97,9 @@ import UIKit
|
|
|
96
97
|
currentGlassStyle = glassType
|
|
97
98
|
|
|
98
99
|
updateBorderRadius()
|
|
100
|
+
#else
|
|
101
|
+
// Fallback for older compilers (Xcode < 16.x) even on newer iOS
|
|
102
|
+
updateFallback()
|
|
99
103
|
#endif
|
|
100
104
|
} else {
|
|
101
105
|
// Fallback for iOS < 26
|
|
@@ -104,12 +108,34 @@ import UIKit
|
|
|
104
108
|
}
|
|
105
109
|
|
|
106
110
|
private func updateFallback() {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
} else {
|
|
111
|
+
// If reduce transparency is enabled, show solid color
|
|
112
|
+
if UIAccessibility.isReduceTransparencyEnabled {
|
|
110
113
|
backgroundColor = reducedTransparencyFallbackColor
|
|
111
|
-
|
|
114
|
+
glassEffectView?.effect = nil
|
|
115
|
+
} else {
|
|
116
|
+
backgroundColor = .clear
|
|
117
|
+
|
|
118
|
+
// Map glass types to blur styles for fallback
|
|
119
|
+
let style: UIBlurEffect.Style
|
|
120
|
+
switch glassType {
|
|
121
|
+
case "regular":
|
|
122
|
+
style = .systemMaterial
|
|
123
|
+
case "clear":
|
|
124
|
+
style = .systemUltraThinMaterial
|
|
125
|
+
default:
|
|
126
|
+
style = .regular
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
let effect = UIBlurEffect(style: style)
|
|
130
|
+
glassEffectView?.effect = effect
|
|
131
|
+
|
|
132
|
+
// Clear any background color on content view
|
|
133
|
+
glassEffectView?.contentView.backgroundColor = .clear
|
|
112
134
|
}
|
|
135
|
+
|
|
136
|
+
layer.cornerRadius = allBorderRadius
|
|
137
|
+
glassEffectView?.layer.cornerRadius = allBorderRadius
|
|
138
|
+
glassEffectView?.layer.masksToBounds = true
|
|
113
139
|
}
|
|
114
140
|
|
|
115
141
|
private func updateBorderRadius() {
|
|
@@ -9,11 +9,14 @@ import QuartzCore
|
|
|
9
9
|
public enum VariableBlurDirection: String {
|
|
10
10
|
case blurredTopClearBottom
|
|
11
11
|
case blurredBottomClearTop
|
|
12
|
+
case blurredCenterClearTopAndBottom
|
|
12
13
|
|
|
13
14
|
init(fromString string: String) {
|
|
14
15
|
switch string.lowercased() {
|
|
15
16
|
case "blurredbottomcleartop", "bottomtotop", "bottom":
|
|
16
17
|
self = .blurredBottomClearTop
|
|
18
|
+
case "blurredcentercleartopandbottom", "center":
|
|
19
|
+
self = .blurredCenterClearTopAndBottom
|
|
17
20
|
default:
|
|
18
21
|
self = .blurredTopClearBottom
|
|
19
22
|
}
|
|
@@ -122,21 +125,144 @@ open class VariableBlurView: UIVisualEffectView {
|
|
|
122
125
|
startOffset: CGFloat,
|
|
123
126
|
direction: VariableBlurDirection
|
|
124
127
|
) -> CGImage {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
ciGradientFilter
|
|
128
|
+
switch direction {
|
|
129
|
+
case .blurredCenterClearTopAndBottom:
|
|
130
|
+
return makeCenterGradientImage(
|
|
131
|
+
width: width,
|
|
132
|
+
height: height,
|
|
133
|
+
edgeOffset: startOffset
|
|
134
|
+
)
|
|
135
|
+
case .blurredTopClearBottom, .blurredBottomClearTop:
|
|
136
|
+
// Try smoothLinearGradient for smoother transitions
|
|
137
|
+
let ciGradientFilter = CIFilter.smoothLinearGradient()
|
|
138
|
+
ciGradientFilter.color0 = CIColor.black
|
|
139
|
+
ciGradientFilter.color1 = CIColor.clear
|
|
140
|
+
ciGradientFilter.point0 = CGPoint(x: 0, y: height)
|
|
141
|
+
ciGradientFilter.point1 = CGPoint(x: 0, y: startOffset * height)
|
|
142
|
+
|
|
143
|
+
if case .blurredBottomClearTop = direction {
|
|
144
|
+
ciGradientFilter.point0.y = 0
|
|
145
|
+
ciGradientFilter.point1.y = height - ciGradientFilter.point1.y
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
guard let output = ciGradientFilter.outputImage else {
|
|
149
|
+
return makeFallbackMask(width: width, height: height)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
guard let cg = CIContext().createCGImage(
|
|
153
|
+
output,
|
|
154
|
+
from: CGRect(x: 0, y: 0, width: width, height: height)
|
|
155
|
+
) else {
|
|
156
|
+
return makeFallbackMask(width: width, height: height)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return cg
|
|
135
160
|
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
private func makeCenterGradientImage(
|
|
164
|
+
width: CGFloat = 100,
|
|
165
|
+
height: CGFloat = 100,
|
|
166
|
+
edgeOffset: CGFloat
|
|
167
|
+
) -> CGImage {
|
|
168
|
+
let startEdge = max(min(edgeOffset, 0.2), 0.01)
|
|
169
|
+
let endEdge = 1 - startEdge
|
|
170
|
+
let colorSpace = CGColorSpaceCreateDeviceRGB()
|
|
136
171
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
172
|
+
let centerLow: CGFloat = 0.5
|
|
173
|
+
let centerHigh: CGFloat = 0.5
|
|
174
|
+
let locations: [CGFloat] = [
|
|
175
|
+
0.0,
|
|
176
|
+
startEdge,
|
|
177
|
+
centerLow,
|
|
178
|
+
centerHigh,
|
|
179
|
+
endEdge,
|
|
180
|
+
1.0
|
|
181
|
+
]
|
|
182
|
+
|
|
183
|
+
let colorComponents: [CGFloat] = [
|
|
184
|
+
0, 0, 0, 0, // top clear
|
|
185
|
+
0, 0, 0, 0, // clear until offset
|
|
186
|
+
0, 0, 0, 1, // ramp up to opaque
|
|
187
|
+
0, 0, 0, 1, // hold opaque plateau
|
|
188
|
+
0, 0, 0, 0, // back to clear
|
|
189
|
+
0, 0, 0, 0 // bottom clear
|
|
190
|
+
]
|
|
191
|
+
|
|
192
|
+
let context = CGContext(
|
|
193
|
+
data: nil,
|
|
194
|
+
width: Int(width),
|
|
195
|
+
height: Int(height),
|
|
196
|
+
bitsPerComponent: 8,
|
|
197
|
+
bytesPerRow: 0,
|
|
198
|
+
space: colorSpace,
|
|
199
|
+
bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue
|
|
140
200
|
)!
|
|
201
|
+
|
|
202
|
+
guard let gradient = CGGradient(
|
|
203
|
+
colorSpace: colorSpace,
|
|
204
|
+
colorComponents: colorComponents,
|
|
205
|
+
locations: locations,
|
|
206
|
+
count: locations.count
|
|
207
|
+
) else {
|
|
208
|
+
return makeFallbackMask(width: width, height: height)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
context.drawLinearGradient(
|
|
212
|
+
gradient,
|
|
213
|
+
start: CGPoint(x: 0, y: 0),
|
|
214
|
+
end: CGPoint(x: 0, y: height),
|
|
215
|
+
options: []
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
return context.makeImage() ?? makeFallbackMask(width: width, height: height)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private func makeFallbackMask(width: CGFloat, height: CGFloat) -> CGImage {
|
|
222
|
+
let fallback = CIFilter.smoothLinearGradient()
|
|
223
|
+
fallback.color0 = CIColor.black
|
|
224
|
+
fallback.color1 = CIColor.clear
|
|
225
|
+
fallback.point0 = CGPoint(x: 0, y: height)
|
|
226
|
+
fallback.point1 = CGPoint(x: 0, y: height / 2)
|
|
227
|
+
|
|
228
|
+
if let output = fallback.outputImage,
|
|
229
|
+
let cg = CIContext().createCGImage(
|
|
230
|
+
output,
|
|
231
|
+
from: CGRect(x: 0, y: 0, width: width, height: height)
|
|
232
|
+
) {
|
|
233
|
+
return cg
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Last-resort solid mask (fully opaque) to avoid crash loops
|
|
237
|
+
let colorSpace = CGColorSpaceCreateDeviceGray()
|
|
238
|
+
let bitmapInfo = CGImageAlphaInfo.none.rawValue
|
|
239
|
+
guard let context = CGContext(
|
|
240
|
+
data: nil,
|
|
241
|
+
width: Int(max(width, 1)),
|
|
242
|
+
height: Int(max(height, 1)),
|
|
243
|
+
bitsPerComponent: 8,
|
|
244
|
+
bytesPerRow: 0,
|
|
245
|
+
space: colorSpace,
|
|
246
|
+
bitmapInfo: bitmapInfo
|
|
247
|
+
) else {
|
|
248
|
+
// Should never happen; return a 1x1 opaque pixel
|
|
249
|
+
return CGImage(
|
|
250
|
+
width: 1,
|
|
251
|
+
height: 1,
|
|
252
|
+
bitsPerComponent: 8,
|
|
253
|
+
bitsPerPixel: 8,
|
|
254
|
+
bytesPerRow: 1,
|
|
255
|
+
space: colorSpace,
|
|
256
|
+
bitmapInfo: CGBitmapInfo(rawValue: bitmapInfo),
|
|
257
|
+
provider: CGDataProvider(data: Data([0xFF]) as CFData)!,
|
|
258
|
+
decode: nil,
|
|
259
|
+
shouldInterpolate: false,
|
|
260
|
+
intent: .defaultIntent
|
|
261
|
+
)!
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
context.setFillColor(CGColor(gray: 0, alpha: 1))
|
|
265
|
+
context.fill(CGRect(x: 0, y: 0, width: width, height: height))
|
|
266
|
+
return context.makeImage()!
|
|
141
267
|
}
|
|
142
268
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
|
|
3
|
+
@objc public class VibrancyEffectView: UIView {
|
|
4
|
+
|
|
5
|
+
private let blurEffectView = UIVisualEffectView()
|
|
6
|
+
private let vibrancyEffectView = UIVisualEffectView()
|
|
7
|
+
private var blurAnimator: UIViewPropertyAnimator?
|
|
8
|
+
|
|
9
|
+
@objc public var blurType: String = "xlight" {
|
|
10
|
+
didSet {
|
|
11
|
+
updateEffect()
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@objc public var blurAmount: Double = 10.0 {
|
|
16
|
+
didSet {
|
|
17
|
+
updateEffect()
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@objc public var contentView: UIView {
|
|
22
|
+
return vibrancyEffectView.contentView
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public override init(frame: CGRect) {
|
|
26
|
+
super.init(frame: frame)
|
|
27
|
+
setupViews()
|
|
28
|
+
updateEffect()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public init(effect: UIVisualEffect?) {
|
|
32
|
+
super.init(frame: .zero)
|
|
33
|
+
setupViews()
|
|
34
|
+
updateEffect()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
required init?(coder: NSCoder) {
|
|
38
|
+
super.init(coder: coder)
|
|
39
|
+
setupViews()
|
|
40
|
+
updateEffect()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private func setupViews() {
|
|
44
|
+
// Setup blur view
|
|
45
|
+
blurEffectView.frame = bounds
|
|
46
|
+
blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
47
|
+
addSubview(blurEffectView)
|
|
48
|
+
|
|
49
|
+
// Setup vibrancy view inside blur view's contentView
|
|
50
|
+
vibrancyEffectView.frame = blurEffectView.contentView.bounds
|
|
51
|
+
vibrancyEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
52
|
+
blurEffectView.contentView.addSubview(vibrancyEffectView)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private func updateEffect() {
|
|
56
|
+
// Clean up existing animator
|
|
57
|
+
if let animator = blurAnimator {
|
|
58
|
+
animator.stopAnimation(true)
|
|
59
|
+
animator.finishAnimation(at: .current)
|
|
60
|
+
}
|
|
61
|
+
blurAnimator = nil
|
|
62
|
+
|
|
63
|
+
// Reset effects
|
|
64
|
+
blurEffectView.effect = nil
|
|
65
|
+
vibrancyEffectView.effect = nil
|
|
66
|
+
|
|
67
|
+
let style = styleFromString(blurType)
|
|
68
|
+
let blurEffect = UIBlurEffect(style: style)
|
|
69
|
+
let vibrancyEffect = UIVibrancyEffect(blurEffect: blurEffect)
|
|
70
|
+
|
|
71
|
+
// Use animator to control blur intensity
|
|
72
|
+
blurAnimator = UIViewPropertyAnimator(duration: 1, curve: .linear)
|
|
73
|
+
blurAnimator?.addAnimations { [weak self] in
|
|
74
|
+
self?.blurEffectView.effect = blurEffect
|
|
75
|
+
self?.vibrancyEffectView.effect = vibrancyEffect
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Convert blurAmount (0-100) to intensity (0.0-1.0)
|
|
79
|
+
let intensity = min(max(blurAmount / 100.0, 0.0), 1.0)
|
|
80
|
+
blurAnimator?.fractionComplete = intensity
|
|
81
|
+
|
|
82
|
+
// Stop the animation at the current state
|
|
83
|
+
DispatchQueue.main.async { [weak self, weak blurAnimator] in
|
|
84
|
+
// Only stop the animator if it's still the current one
|
|
85
|
+
guard let self = self, let currentAnimator = self.blurAnimator, currentAnimator === blurAnimator else { return }
|
|
86
|
+
|
|
87
|
+
currentAnimator.stopAnimation(true)
|
|
88
|
+
currentAnimator.finishAnimation(at: .current)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
deinit {
|
|
93
|
+
guard let animator = blurAnimator, animator.state == .active else { return }
|
|
94
|
+
animator.stopAnimation(true)
|
|
95
|
+
animator.finishAnimation(at: .current)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Helper to parse string to UIBlurEffect.Style
|
|
99
|
+
private func styleFromString(_ style: String) -> UIBlurEffect.Style {
|
|
100
|
+
switch style {
|
|
101
|
+
case "xlight": return .extraLight
|
|
102
|
+
case "light": return .light
|
|
103
|
+
case "dark": return .dark
|
|
104
|
+
case "regular": return .regular
|
|
105
|
+
case "prominent": return .prominent
|
|
106
|
+
case "systemUltraThinMaterial": return .systemUltraThinMaterial
|
|
107
|
+
case "systemThinMaterial": return .systemThinMaterial
|
|
108
|
+
case "systemMaterial": return .systemMaterial
|
|
109
|
+
case "systemThickMaterial": return .systemThickMaterial
|
|
110
|
+
case "systemChromeMaterial": return .systemChromeMaterial
|
|
111
|
+
case "systemUltraThinMaterialLight": return .systemUltraThinMaterialLight
|
|
112
|
+
case "systemThinMaterialLight": return .systemThinMaterialLight
|
|
113
|
+
case "systemMaterialLight": return .systemMaterialLight
|
|
114
|
+
case "systemThickMaterialLight": return .systemThickMaterialLight
|
|
115
|
+
case "systemChromeMaterialLight": return .systemChromeMaterialLight
|
|
116
|
+
case "systemUltraThinMaterialDark": return .systemUltraThinMaterialDark
|
|
117
|
+
case "systemThinMaterialDark": return .systemThinMaterialDark
|
|
118
|
+
case "systemMaterialDark": return .systemMaterialDark
|
|
119
|
+
case "systemThickMaterialDark": return .systemThickMaterialDark
|
|
120
|
+
case "systemChromeMaterialDark": return .systemChromeMaterialDark
|
|
121
|
+
default: return .regular
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -83,10 +83,7 @@ export const ProgressiveBlurView = ({
|
|
|
83
83
|
reducedTransparencyFallbackColor: reducedTransparencyFallbackColor,
|
|
84
84
|
style: StyleSheet.absoluteFill,
|
|
85
85
|
...props
|
|
86
|
-
}),
|
|
87
|
-
style: styles.children,
|
|
88
|
-
children: children
|
|
89
|
-
})]
|
|
86
|
+
}), children]
|
|
90
87
|
});
|
|
91
88
|
};
|
|
92
89
|
export default ProgressiveBlurView;
|
|
@@ -94,10 +91,6 @@ const styles = StyleSheet.create({
|
|
|
94
91
|
container: {
|
|
95
92
|
position: 'relative',
|
|
96
93
|
overflow: 'hidden'
|
|
97
|
-
},
|
|
98
|
-
children: {
|
|
99
|
-
position: 'relative',
|
|
100
|
-
zIndex: 1
|
|
101
94
|
}
|
|
102
95
|
});
|
|
103
96
|
//# sourceMappingURL=ProgressiveBlurView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Children","StyleSheet","View","ReactNativeProgressiveBlurView","jsx","_jsx","jsxs","_jsxs","ProgressiveBlurView","blurType","blurAmount","direction","startOffset","reducedTransparencyFallbackColor","overlayColor","style","children","props","overlay","backgroundColor","count","styles","container","absoluteFill","create","position","overflow"
|
|
1
|
+
{"version":3,"names":["React","Children","StyleSheet","View","ReactNativeProgressiveBlurView","jsx","_jsx","jsxs","_jsxs","ProgressiveBlurView","blurType","blurAmount","direction","startOffset","reducedTransparencyFallbackColor","overlayColor","style","children","props","overlay","backgroundColor","count","styles","container","absoluteFill","create","position","overflow"],"sourceRoot":"../../src","sources":["ProgressiveBlurView.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAE/C,OAAOC,8BAA8B,MAG9B,iDAAiD;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAoEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAuD,GAAGA,CAAC;EACtEC,QAAQ,GAAG,SAAS;EACpBC,UAAU,GAAG,EAAE;EACfC,SAAS,GAAG,uBAAuB;EACnCC,WAAW,GAAG,GAAG;EACjBC,gCAAgC,GAAG,SAAS;EAC5CC,YAAY;EACZC,KAAK;EACLC,QAAQ;EACR,GAAGC;AACL,CAAC,KAAK;EACJ,MAAMC,OAAO,GAAG;IAAEC,eAAe,EAAEL;EAAa,CAAC;;EAEjD;EACA,IAAI,CAACd,QAAQ,CAACoB,KAAK,CAACJ,QAAQ,CAAC,EAAE;IAC7B,oBACEX,IAAA,CAACF,8BAA8B;MAC7BM,QAAQ,EAAEA,QAAS;MACnBC,UAAU,EAAEA,UAAW;MACvBC,SAAS,EAAEA,SAAU;MACrBC,WAAW,EAAEA,WAAY;MACzBC,gCAAgC,EAAEA,gCAAiC;MACnEE,KAAK,EAAE,CAACA,KAAK,EAAEG,OAAO,CAAE;MAAA,GACpBD;IAAK,CACV,CAAC;EAEN;;EAEA;EACA,oBACEV,KAAA,CAACL,IAAI;IAACa,KAAK,EAAE,CAACM,MAAM,CAACC,SAAS,EAAEP,KAAK,EAAEG,OAAO,CAAE;IAAAF,QAAA,gBAE9CX,IAAA,CAACF,8BAA8B;MAC7BM,QAAQ,EAAEA,QAAS;MACnBC,UAAU,EAAEA,UAAW;MACvBC,SAAS,EAAEA,SAAU;MACrBC,WAAW,EAAEA,WAAY;MACzBC,gCAAgC,EAAEA,gCAAiC;MACnEE,KAAK,EAAEd,UAAU,CAACsB,YAAa;MAAA,GAC3BN;IAAK,CACV,CAAC,EAEDD,QAAQ;EAAA,CACL,CAAC;AAEX,CAAC;AAED,eAAeR,mBAAmB;AAElC,MAAMa,MAAM,GAAGpB,UAAU,CAACuB,MAAM,CAAC;EAC/BF,SAAS,EAAE;IACTG,QAAQ,EAAE,UAAU;IACpBC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -30,7 +30,8 @@ export type BlurType =
|
|
|
30
30
|
|
|
31
31
|
export type ProgressiveBlurDirection =
|
|
32
32
|
| 'blurredTopClearBottom'
|
|
33
|
-
| 'blurredBottomClearTop'
|
|
33
|
+
| 'blurredBottomClearTop'
|
|
34
|
+
| 'blurredCenterClearTopAndBottom';
|
|
34
35
|
|
|
35
36
|
interface NativeProps extends ViewProps {
|
|
36
37
|
blurAmount?: WithDefault<Double, 20.0>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import type {
|
|
4
|
+
WithDefault,
|
|
5
|
+
Double,
|
|
6
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
7
|
+
|
|
8
|
+
export type BlurType =
|
|
9
|
+
| 'xlight'
|
|
10
|
+
| 'light'
|
|
11
|
+
| 'dark'
|
|
12
|
+
| 'extraDark'
|
|
13
|
+
| 'regular'
|
|
14
|
+
| 'prominent'
|
|
15
|
+
| 'systemUltraThinMaterial'
|
|
16
|
+
| 'systemThinMaterial'
|
|
17
|
+
| 'systemMaterial'
|
|
18
|
+
| 'systemThickMaterial'
|
|
19
|
+
| 'systemChromeMaterial'
|
|
20
|
+
| 'systemUltraThinMaterialLight'
|
|
21
|
+
| 'systemThinMaterialLight'
|
|
22
|
+
| 'systemMaterialLight'
|
|
23
|
+
| 'systemThickMaterialLight'
|
|
24
|
+
| 'systemChromeMaterialLight'
|
|
25
|
+
| 'systemUltraThinMaterialDark'
|
|
26
|
+
| 'systemThinMaterialDark'
|
|
27
|
+
| 'systemMaterialDark'
|
|
28
|
+
| 'systemThickMaterialDark'
|
|
29
|
+
| 'systemChromeMaterialDark';
|
|
30
|
+
|
|
31
|
+
interface NativeProps extends ViewProps {
|
|
32
|
+
blurAmount?: WithDefault<Double, 10.0>;
|
|
33
|
+
blurType?: WithDefault<BlurType, 'xlight'>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default codegenNativeComponent<NativeProps>('ReactNativeVibrancyView', {
|
|
37
|
+
excludedPlatforms: ['android'],
|
|
38
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Platform, StyleSheet } from 'react-native';
|
|
5
|
+
import ReactNativeVibrancyView from './ReactNativeVibrancyViewNativeComponent';
|
|
6
|
+
import BlurView from "./BlurView.js";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
/**
|
|
9
|
+
* A component that applies a vibrancy effect to its content.
|
|
10
|
+
*
|
|
11
|
+
* On iOS, this uses UIVibrancyEffect.
|
|
12
|
+
* On Android, this falls back to a simple View (or BlurView behavior if implemented).
|
|
13
|
+
*/
|
|
14
|
+
export const VibrancyView = ({
|
|
15
|
+
blurType = 'xlight',
|
|
16
|
+
blurAmount = 10,
|
|
17
|
+
style,
|
|
18
|
+
children,
|
|
19
|
+
...props
|
|
20
|
+
}) => {
|
|
21
|
+
if (Platform.OS === 'android') {
|
|
22
|
+
return /*#__PURE__*/_jsx(BlurView, {
|
|
23
|
+
blurType: blurType,
|
|
24
|
+
blurAmount: blurAmount,
|
|
25
|
+
style: style,
|
|
26
|
+
...props,
|
|
27
|
+
children: children
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return /*#__PURE__*/_jsx(ReactNativeVibrancyView, {
|
|
31
|
+
blurType: blurType,
|
|
32
|
+
blurAmount: blurAmount,
|
|
33
|
+
style: [styles.container, style],
|
|
34
|
+
...props,
|
|
35
|
+
children: children
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
const styles = StyleSheet.create({
|
|
39
|
+
container: {
|
|
40
|
+
backgroundColor: 'transparent'
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=VibrancyView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Platform","StyleSheet","ReactNativeVibrancyView","BlurView","jsx","_jsx","VibrancyView","blurType","blurAmount","style","children","props","OS","styles","container","create","backgroundColor"],"sourceRoot":"../../src","sources":["VibrancyView.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,EAAEC,UAAU,QAAQ,cAAc;AAEnD,OAAOC,uBAAuB,MAEvB,0CAA0C;AACjD,OAAOC,QAAQ,MAAM,eAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAgClC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAyC,GAAGA,CAAC;EACxDC,QAAQ,GAAG,QAAQ;EACnBC,UAAU,GAAG,EAAE;EACfC,KAAK;EACLC,QAAQ;EACR,GAAGC;AACL,CAAC,KAAK;EACJ,IAAIX,QAAQ,CAACY,EAAE,KAAK,SAAS,EAAE;IAC7B,oBACEP,IAAA,CAACF,QAAQ;MACPI,QAAQ,EAAEA,QAAS;MACnBC,UAAU,EAAEA,UAAW;MACvBC,KAAK,EAAEA,KAAM;MAAA,GACTE,KAAK;MAAAD,QAAA,EAERA;IAAQ,CACD,CAAC;EAEf;EACA,oBACEL,IAAA,CAACH,uBAAuB;IACtBK,QAAQ,EAAEA,QAAS;IACnBC,UAAU,EAAEA,UAAW;IACvBC,KAAK,EAAE,CAACI,MAAM,CAACC,SAAS,EAAEL,KAAK,CAAE;IAAA,GAC7BE,KAAK;IAAAD,QAAA,EAERA;EAAQ,CACc,CAAC;AAE9B,CAAC;AAED,MAAMG,MAAM,GAAGZ,UAAU,CAACc,MAAM,CAAC;EAC/BD,SAAS,EAAE;IACTE,eAAe,EAAE;EACnB;AACF,CAAC,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -11,4 +11,6 @@ export { default as ReactNativeLiquidGlassContainer } from './ReactNativeLiquidG
|
|
|
11
11
|
export { LiquidGlassContainer } from "./LiquidGlassContainer.js";
|
|
12
12
|
export { default as ReactNativeBlurSwitch } from './ReactNativeBlurSwitchNativeComponent';
|
|
13
13
|
export { BlurSwitch } from "./BlurSwitch.js";
|
|
14
|
+
export { default as ReactNativeVibrancyView } from './ReactNativeVibrancyViewNativeComponent';
|
|
15
|
+
export { VibrancyView } from "./VibrancyView.js";
|
|
14
16
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","ReactNativeBlurView","BlurView","ReactNativeLiquidGlassView","LiquidGlassView","ReactNativeProgressiveBlurView","ProgressiveBlurView","ReactNativeLiquidGlassContainer","LiquidGlassContainer","ReactNativeBlurSwitch","BlurSwitch"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,OAAO,IAAIC,mBAAmB,QAAQ,sCAAsC;AACrF,cAAc,sCAAsC;AAEpD,SAASC,QAAQ,IAAIF,OAAO,EAAEE,QAAQ,QAAQ,eAAY;AAG1D,SAASF,OAAO,IAAIG,0BAA0B,QAAQ,6CAA6C;AAGnG,SAASC,eAAe,QAAQ,sBAAmB;AAGnD,SAASJ,OAAO,IAAIK,8BAA8B,QAAQ,iDAAiD;AAG3G,SAASC,mBAAmB,QAAQ,0BAAuB;AAG3D,SAASN,OAAO,IAAIO,+BAA+B,QAAQ,kDAAkD;AAE7G,SAASC,oBAAoB,QAAQ,2BAAwB;AAG7D,SAASR,OAAO,IAAIS,qBAAqB,QAAQ,wCAAwC;AAGzF,SAASC,UAAU,QAAQ,iBAAc","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["default","ReactNativeBlurView","BlurView","ReactNativeLiquidGlassView","LiquidGlassView","ReactNativeProgressiveBlurView","ProgressiveBlurView","ReactNativeLiquidGlassContainer","LiquidGlassContainer","ReactNativeBlurSwitch","BlurSwitch","ReactNativeVibrancyView","VibrancyView"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,OAAO,IAAIC,mBAAmB,QAAQ,sCAAsC;AACrF,cAAc,sCAAsC;AAEpD,SAASC,QAAQ,IAAIF,OAAO,EAAEE,QAAQ,QAAQ,eAAY;AAG1D,SAASF,OAAO,IAAIG,0BAA0B,QAAQ,6CAA6C;AAGnG,SAASC,eAAe,QAAQ,sBAAmB;AAGnD,SAASJ,OAAO,IAAIK,8BAA8B,QAAQ,iDAAiD;AAG3G,SAASC,mBAAmB,QAAQ,0BAAuB;AAG3D,SAASN,OAAO,IAAIO,+BAA+B,QAAQ,kDAAkD;AAE7G,SAASC,oBAAoB,QAAQ,2BAAwB;AAG7D,SAASR,OAAO,IAAIS,qBAAqB,QAAQ,wCAAwC;AAGzF,SAASC,UAAU,QAAQ,iBAAc;AAGzC,SAASV,OAAO,IAAIW,uBAAuB,QAAQ,0CAA0C;AAC7F,SAASC,YAAY,QAAQ,mBAAgB","ignoreList":[]}
|
|
@@ -19,6 +19,7 @@ export interface ProgressiveBlurViewProps {
|
|
|
19
19
|
* @description The direction of the progressive blur gradient
|
|
20
20
|
* - 'blurredTopClearBottom': Blur starts at top, clear at bottom
|
|
21
21
|
* - 'blurredBottomClearTop': Blur starts at bottom, clear at top
|
|
22
|
+
* - 'blurredCenterClearTopAndBottom': Blur peaks at center, clear at both edges
|
|
22
23
|
*
|
|
23
24
|
* @default 'blurredTopClearBottom'
|
|
24
25
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressiveBlurView.d.ts","sourceRoot":"","sources":["../../../src/ProgressiveBlurView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrE,OAAuC,EACrC,KAAK,QAAQ,EACb,KAAK,wBAAwB,EAC9B,MAAM,iDAAiD,CAAC;AAEzD,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB
|
|
1
|
+
{"version":3,"file":"ProgressiveBlurView.d.ts","sourceRoot":"","sources":["../../../src/ProgressiveBlurView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrE,OAAuC,EACrC,KAAK,QAAQ,EACb,KAAK,wBAAwB,EAC9B,MAAM,iDAAiD,CAAC;AAEzD,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,wBAAwB,CAAC;IAErC;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;;OAMG;IACH,gCAAgC,CAAC,EAAE,MAAM,CAAC;IAE1C;;;;OAIG;IACH,YAAY,CAAC,EAAE,UAAU,CAAC;IAE1B;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAE7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA6ClE,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ViewProps } from 'react-native';
|
|
2
2
|
import type { WithDefault, Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
3
|
export type BlurType = 'xlight' | 'light' | 'dark' | 'extraDark' | 'regular' | 'prominent' | 'systemUltraThinMaterial' | 'systemThinMaterial' | 'systemMaterial' | 'systemThickMaterial' | 'systemChromeMaterial' | 'systemUltraThinMaterialLight' | 'systemThinMaterialLight' | 'systemMaterialLight' | 'systemThickMaterialLight' | 'systemChromeMaterialLight' | 'systemUltraThinMaterialDark' | 'systemThinMaterialDark' | 'systemMaterialDark' | 'systemThickMaterialDark' | 'systemChromeMaterialDark';
|
|
4
|
-
export type ProgressiveBlurDirection = 'blurredTopClearBottom' | 'blurredBottomClearTop';
|
|
4
|
+
export type ProgressiveBlurDirection = 'blurredTopClearBottom' | 'blurredBottomClearTop' | 'blurredCenterClearTopAndBottom';
|
|
5
5
|
interface NativeProps extends ViewProps {
|
|
6
6
|
blurAmount?: WithDefault<Double, 20.0>;
|
|
7
7
|
blurType?: WithDefault<BlurType, 'regular'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeProgressiveBlurViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/ReactNativeProgressiveBlurViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACP,MAAM,2CAA2C,CAAC;AAEnD,MAAM,MAAM,QAAQ,GAChB,QAAQ,GACR,OAAO,GACP,MAAM,GACN,WAAW,GACX,SAAS,GACT,WAAW,GACX,yBAAyB,GACzB,oBAAoB,GACpB,gBAAgB,GAChB,qBAAqB,GACrB,sBAAsB,GACtB,8BAA8B,GAC9B,yBAAyB,GACzB,qBAAqB,GACrB,0BAA0B,GAC1B,2BAA2B,GAC3B,6BAA6B,GAC7B,wBAAwB,GACxB,oBAAoB,GACpB,yBAAyB,GACzB,0BAA0B,CAAC;AAE/B,MAAM,MAAM,wBAAwB,GAChC,uBAAuB,GACvB,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"ReactNativeProgressiveBlurViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/ReactNativeProgressiveBlurViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACP,MAAM,2CAA2C,CAAC;AAEnD,MAAM,MAAM,QAAQ,GAChB,QAAQ,GACR,OAAO,GACP,MAAM,GACN,WAAW,GACX,SAAS,GACT,WAAW,GACX,yBAAyB,GACzB,oBAAoB,GACpB,gBAAgB,GAChB,qBAAqB,GACrB,sBAAsB,GACtB,8BAA8B,GAC9B,yBAAyB,GACzB,qBAAqB,GACrB,0BAA0B,GAC1B,2BAA2B,GAC3B,6BAA6B,GAC7B,wBAAwB,GACxB,oBAAoB,GACpB,yBAAyB,GACzB,0BAA0B,CAAC;AAE/B,MAAM,MAAM,wBAAwB,GAChC,uBAAuB,GACvB,uBAAuB,GACvB,gCAAgC,CAAC;AAErC,UAAU,WAAY,SAAQ,SAAS;IACrC,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC5C,SAAS,CAAC,EAAE,WAAW,CAAC,wBAAwB,EAAE,uBAAuB,CAAC,CAAC;IAC3E,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,gCAAgC,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACnE;;AAED,wBAEE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import type { WithDefault, Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
export type BlurType = 'xlight' | 'light' | 'dark' | 'extraDark' | 'regular' | 'prominent' | 'systemUltraThinMaterial' | 'systemThinMaterial' | 'systemMaterial' | 'systemThickMaterial' | 'systemChromeMaterial' | 'systemUltraThinMaterialLight' | 'systemThinMaterialLight' | 'systemMaterialLight' | 'systemThickMaterialLight' | 'systemChromeMaterialLight' | 'systemUltraThinMaterialDark' | 'systemThinMaterialDark' | 'systemMaterialDark' | 'systemThickMaterialDark' | 'systemChromeMaterialDark';
|
|
4
|
+
interface NativeProps extends ViewProps {
|
|
5
|
+
blurAmount?: WithDefault<Double, 10.0>;
|
|
6
|
+
blurType?: WithDefault<BlurType, 'xlight'>;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: import("react-native/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=ReactNativeVibrancyViewNativeComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReactNativeVibrancyViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/ReactNativeVibrancyViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACP,MAAM,2CAA2C,CAAC;AAEnD,MAAM,MAAM,QAAQ,GAChB,QAAQ,GACR,OAAO,GACP,MAAM,GACN,WAAW,GACX,SAAS,GACT,WAAW,GACX,yBAAyB,GACzB,oBAAoB,GACpB,gBAAgB,GAChB,qBAAqB,GACrB,sBAAsB,GACtB,8BAA8B,GAC9B,yBAAyB,GACzB,qBAAqB,GACrB,0BAA0B,GAC1B,2BAA2B,GAC3B,6BAA6B,GAC7B,wBAAwB,GACxB,oBAAoB,GACpB,yBAAyB,GACzB,0BAA0B,CAAC;AAE/B,UAAU,WAAY,SAAQ,SAAS;IACrC,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;CAC5C;;AAED,wBAEG"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ViewStyle, StyleProp } from 'react-native';
|
|
3
|
+
import { type BlurType } from './ReactNativeVibrancyViewNativeComponent';
|
|
4
|
+
export interface VibrancyViewProps {
|
|
5
|
+
/**
|
|
6
|
+
* @description The type of blur effect to apply
|
|
7
|
+
*
|
|
8
|
+
* @default 'xlight'
|
|
9
|
+
*/
|
|
10
|
+
blurType?: BlurType;
|
|
11
|
+
/**
|
|
12
|
+
* @description The intensity of the blur effect (0-100)
|
|
13
|
+
*
|
|
14
|
+
* @default 10
|
|
15
|
+
*/
|
|
16
|
+
blurAmount?: number;
|
|
17
|
+
/**
|
|
18
|
+
* @description style object for the vibrancy view
|
|
19
|
+
*
|
|
20
|
+
* @default undefined
|
|
21
|
+
*/
|
|
22
|
+
style?: StyleProp<ViewStyle>;
|
|
23
|
+
/**
|
|
24
|
+
* @description Child components to render inside the vibrancy view
|
|
25
|
+
*
|
|
26
|
+
* @default undefined
|
|
27
|
+
*/
|
|
28
|
+
children?: React.ReactNode;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A component that applies a vibrancy effect to its content.
|
|
32
|
+
*
|
|
33
|
+
* On iOS, this uses UIVibrancyEffect.
|
|
34
|
+
* On Android, this falls back to a simple View (or BlurView behavior if implemented).
|
|
35
|
+
*/
|
|
36
|
+
export declare const VibrancyView: React.FC<VibrancyViewProps>;
|
|
37
|
+
//# sourceMappingURL=VibrancyView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VibrancyView.d.ts","sourceRoot":"","sources":["../../../src/VibrancyView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzD,OAAgC,EAC9B,KAAK,QAAQ,EACd,MAAM,0CAA0C,CAAC;AAGlD,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAE7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA6BpD,CAAC"}
|
|
@@ -17,4 +17,7 @@ export { default as ReactNativeBlurSwitch } from './ReactNativeBlurSwitchNativeC
|
|
|
17
17
|
export type { ValueChangeEvent } from './ReactNativeBlurSwitchNativeComponent';
|
|
18
18
|
export { BlurSwitch } from './BlurSwitch';
|
|
19
19
|
export type { BlurSwitchProps } from './BlurSwitch';
|
|
20
|
+
export { default as ReactNativeVibrancyView } from './ReactNativeVibrancyViewNativeComponent';
|
|
21
|
+
export { VibrancyView } from './VibrancyView';
|
|
22
|
+
export type { VibrancyViewProps } from './VibrancyView';
|
|
20
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AACtF,cAAc,sCAAsC,CAAC;AAErD,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACpG,YAAY,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,iDAAiD,CAAC;AAC5G,YAAY,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,EAAE,OAAO,IAAI,+BAA+B,EAAE,MAAM,kDAAkD,CAAC;AAE9G,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAExE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AACtF,cAAc,sCAAsC,CAAC;AAErD,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACpG,YAAY,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,iDAAiD,CAAC;AAC5G,YAAY,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,EAAE,OAAO,IAAI,+BAA+B,EAAE,MAAM,kDAAkD,CAAC;AAE9G,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAExE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sbaiahmed1/react-native-blur",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.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",
|
|
@@ -166,7 +166,8 @@
|
|
|
166
166
|
"ReactNativeBlurView": "ReactNativeBlurView",
|
|
167
167
|
"ReactNativeLiquidGlassView": "ReactNativeLiquidGlassView",
|
|
168
168
|
"ReactNativeProgressiveBlurView": "ReactNativeProgressiveBlurView",
|
|
169
|
-
"ReactNativeLiquidGlassContainer": "ReactNativeLiquidGlassContainer"
|
|
169
|
+
"ReactNativeLiquidGlassContainer": "ReactNativeLiquidGlassContainer",
|
|
170
|
+
"ReactNativeVibrancyView": "ReactNativeVibrancyView"
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
173
|
},
|
|
@@ -26,6 +26,7 @@ export interface ProgressiveBlurViewProps {
|
|
|
26
26
|
* @description The direction of the progressive blur gradient
|
|
27
27
|
* - 'blurredTopClearBottom': Blur starts at top, clear at bottom
|
|
28
28
|
* - 'blurredBottomClearTop': Blur starts at bottom, clear at top
|
|
29
|
+
* - 'blurredCenterClearTopAndBottom': Blur peaks at center, clear at both edges
|
|
29
30
|
*
|
|
30
31
|
* @default 'blurredTopClearBottom'
|
|
31
32
|
*/
|
|
@@ -153,7 +154,7 @@ export const ProgressiveBlurView: React.FC<ProgressiveBlurViewProps> = ({
|
|
|
153
154
|
{...props}
|
|
154
155
|
/>
|
|
155
156
|
|
|
156
|
-
|
|
157
|
+
{children}
|
|
157
158
|
</View>
|
|
158
159
|
);
|
|
159
160
|
};
|
|
@@ -165,8 +166,4 @@ const styles = StyleSheet.create({
|
|
|
165
166
|
position: 'relative',
|
|
166
167
|
overflow: 'hidden',
|
|
167
168
|
},
|
|
168
|
-
children: {
|
|
169
|
-
position: 'relative',
|
|
170
|
-
zIndex: 1,
|
|
171
|
-
},
|
|
172
169
|
});
|
|
@@ -30,7 +30,8 @@ export type BlurType =
|
|
|
30
30
|
|
|
31
31
|
export type ProgressiveBlurDirection =
|
|
32
32
|
| 'blurredTopClearBottom'
|
|
33
|
-
| 'blurredBottomClearTop'
|
|
33
|
+
| 'blurredBottomClearTop'
|
|
34
|
+
| 'blurredCenterClearTopAndBottom';
|
|
34
35
|
|
|
35
36
|
interface NativeProps extends ViewProps {
|
|
36
37
|
blurAmount?: WithDefault<Double, 20.0>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import type {
|
|
4
|
+
WithDefault,
|
|
5
|
+
Double,
|
|
6
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
7
|
+
|
|
8
|
+
export type BlurType =
|
|
9
|
+
| 'xlight'
|
|
10
|
+
| 'light'
|
|
11
|
+
| 'dark'
|
|
12
|
+
| 'extraDark'
|
|
13
|
+
| 'regular'
|
|
14
|
+
| 'prominent'
|
|
15
|
+
| 'systemUltraThinMaterial'
|
|
16
|
+
| 'systemThinMaterial'
|
|
17
|
+
| 'systemMaterial'
|
|
18
|
+
| 'systemThickMaterial'
|
|
19
|
+
| 'systemChromeMaterial'
|
|
20
|
+
| 'systemUltraThinMaterialLight'
|
|
21
|
+
| 'systemThinMaterialLight'
|
|
22
|
+
| 'systemMaterialLight'
|
|
23
|
+
| 'systemThickMaterialLight'
|
|
24
|
+
| 'systemChromeMaterialLight'
|
|
25
|
+
| 'systemUltraThinMaterialDark'
|
|
26
|
+
| 'systemThinMaterialDark'
|
|
27
|
+
| 'systemMaterialDark'
|
|
28
|
+
| 'systemThickMaterialDark'
|
|
29
|
+
| 'systemChromeMaterialDark';
|
|
30
|
+
|
|
31
|
+
interface NativeProps extends ViewProps {
|
|
32
|
+
blurAmount?: WithDefault<Double, 10.0>;
|
|
33
|
+
blurType?: WithDefault<BlurType, 'xlight'>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default codegenNativeComponent<NativeProps>('ReactNativeVibrancyView', {
|
|
37
|
+
excludedPlatforms: ['android'],
|
|
38
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Platform, StyleSheet } from 'react-native';
|
|
3
|
+
import type { ViewStyle, StyleProp } from 'react-native';
|
|
4
|
+
import ReactNativeVibrancyView, {
|
|
5
|
+
type BlurType,
|
|
6
|
+
} from './ReactNativeVibrancyViewNativeComponent';
|
|
7
|
+
import BlurView from './BlurView';
|
|
8
|
+
|
|
9
|
+
export interface VibrancyViewProps {
|
|
10
|
+
/**
|
|
11
|
+
* @description The type of blur effect to apply
|
|
12
|
+
*
|
|
13
|
+
* @default 'xlight'
|
|
14
|
+
*/
|
|
15
|
+
blurType?: BlurType;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @description The intensity of the blur effect (0-100)
|
|
19
|
+
*
|
|
20
|
+
* @default 10
|
|
21
|
+
*/
|
|
22
|
+
blurAmount?: number;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @description style object for the vibrancy view
|
|
26
|
+
*
|
|
27
|
+
* @default undefined
|
|
28
|
+
*/
|
|
29
|
+
style?: StyleProp<ViewStyle>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @description Child components to render inside the vibrancy view
|
|
33
|
+
*
|
|
34
|
+
* @default undefined
|
|
35
|
+
*/
|
|
36
|
+
children?: React.ReactNode;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A component that applies a vibrancy effect to its content.
|
|
41
|
+
*
|
|
42
|
+
* On iOS, this uses UIVibrancyEffect.
|
|
43
|
+
* On Android, this falls back to a simple View (or BlurView behavior if implemented).
|
|
44
|
+
*/
|
|
45
|
+
export const VibrancyView: React.FC<VibrancyViewProps> = ({
|
|
46
|
+
blurType = 'xlight',
|
|
47
|
+
blurAmount = 10,
|
|
48
|
+
style,
|
|
49
|
+
children,
|
|
50
|
+
...props
|
|
51
|
+
}) => {
|
|
52
|
+
if (Platform.OS === 'android') {
|
|
53
|
+
return (
|
|
54
|
+
<BlurView
|
|
55
|
+
blurType={blurType}
|
|
56
|
+
blurAmount={blurAmount}
|
|
57
|
+
style={style}
|
|
58
|
+
{...props}
|
|
59
|
+
>
|
|
60
|
+
{children}
|
|
61
|
+
</BlurView>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
return (
|
|
65
|
+
<ReactNativeVibrancyView
|
|
66
|
+
blurType={blurType}
|
|
67
|
+
blurAmount={blurAmount}
|
|
68
|
+
style={[styles.container, style]}
|
|
69
|
+
{...props}
|
|
70
|
+
>
|
|
71
|
+
{children}
|
|
72
|
+
</ReactNativeVibrancyView>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const styles = StyleSheet.create({
|
|
77
|
+
container: {
|
|
78
|
+
backgroundColor: 'transparent',
|
|
79
|
+
},
|
|
80
|
+
});
|
package/src/index.tsx
CHANGED
|
@@ -26,3 +26,7 @@ export type { ValueChangeEvent } from './ReactNativeBlurSwitchNativeComponent';
|
|
|
26
26
|
|
|
27
27
|
export { BlurSwitch } from './BlurSwitch';
|
|
28
28
|
export type { BlurSwitchProps } from './BlurSwitch';
|
|
29
|
+
|
|
30
|
+
export { default as ReactNativeVibrancyView } from './ReactNativeVibrancyViewNativeComponent';
|
|
31
|
+
export { VibrancyView } from './VibrancyView';
|
|
32
|
+
export type { VibrancyViewProps } from './VibrancyView';
|