@sbaiahmed1/react-native-blur 4.4.1 → 4.5.0
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 +34 -9
- 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/VibrancyEffectView.swift +124 -0
- 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/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/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
|
|
|
@@ -588,6 +594,17 @@ All props are optional and have sensible defaults.
|
|
|
588
594
|
| `style` | `ViewStyle` | `undefined` | Style object for the blur view |
|
|
589
595
|
| `children` | `ReactNode` | `undefined` | Child components to render inside the blur view |
|
|
590
596
|
|
|
597
|
+
### VibrancyView Props
|
|
598
|
+
|
|
599
|
+
All props are optional and have sensible defaults.
|
|
600
|
+
|
|
601
|
+
| Prop | Type | Default | Description |
|
|
602
|
+
| ------------ | ------------ | ----------- | ----------------------------------------------- |
|
|
603
|
+
| `blurType` | `BlurType` | `'xlight'` | The type of blur/vibrancy effect to apply |
|
|
604
|
+
| `blurAmount` | `number` | `10.0` | The intensity of the blur effect (0-100) |
|
|
605
|
+
| `style` | `ViewStyle` | `undefined` | Style object for the vibrancy view |
|
|
606
|
+
| `children` | `ReactNode` | `undefined` | Child components to render inside the vibrancy view |
|
|
607
|
+
|
|
591
608
|
### ProgressiveBlurView Props
|
|
592
609
|
|
|
593
610
|
All props are optional and have sensible defaults.
|
|
@@ -700,6 +717,11 @@ Both components have been completely rewritten using **SwiftUI** for modern perf
|
|
|
700
717
|
- **Older iOS**: Graceful fallback to standard blur effects
|
|
701
718
|
- **SwiftUI Integration**: Leverages SwiftUI's declarative UI for better performance and maintainability
|
|
702
719
|
|
|
720
|
+
#### VibrancyView
|
|
721
|
+
|
|
722
|
+
- **iOS**: Uses native `UIVibrancyEffect` to create vibrant content that shines through the blur
|
|
723
|
+
- **Integration**: Works seamlessly with `UIVisualEffectView` hierarchies
|
|
724
|
+
|
|
703
725
|
#### LiquidGlassView
|
|
704
726
|
|
|
705
727
|
- **iOS 26+**: Uses native `UIGlassEffect` API for true liquid glass effects with customizable tint colors and opacity
|
|
@@ -712,11 +734,7 @@ Both components have been completely rewritten using **SwiftUI** for modern perf
|
|
|
712
734
|
|
|
713
735
|
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
736
|
|
|
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
|
|
737
|
+
#### L+ssibility
|
|
720
738
|
|
|
721
739
|
All components automatically respect the "Reduce Transparency" accessibility setting:
|
|
722
740
|
|
|
@@ -747,14 +765,16 @@ import {
|
|
|
747
765
|
LiquidGlassView,
|
|
748
766
|
LiquidGlassContainer,
|
|
749
767
|
ProgressiveBlurView,
|
|
750
|
-
|
|
768
|
+
BlurView,
|
|
769
|
+
VibrancySwitch,
|
|
751
770
|
BlurType,
|
|
752
771
|
GlassType,
|
|
753
772
|
BlurViewProps,
|
|
754
773
|
LiquidGlassViewProps,
|
|
755
774
|
LiquidGlassContainerProps,
|
|
756
775
|
ProgressiveBlurViewProps,
|
|
757
|
-
|
|
776
|
+
BlurViewProps,
|
|
777
|
+
VibrancySwitchProps,
|
|
758
778
|
} from '@sbaiahmed1/react-native-blur';
|
|
759
779
|
|
|
760
780
|
// BlurType is exported for type checking
|
|
@@ -768,6 +788,11 @@ interface MyBlurComponentProps {
|
|
|
768
788
|
blurProps: BlurViewProps;
|
|
769
789
|
}
|
|
770
790
|
|
|
791
|
+
// VibrancyViewProps for vibrancy component props
|
|
792
|
+
interface MyVibrancyComponentProps {
|
|
793
|
+
vibrancyProps: VibrancyViewProps;
|
|
794
|
+
}
|
|
795
|
+
|
|
771
796
|
// LiquidGlassViewProps for glass component props
|
|
772
797
|
interface MyGlassComponentProps {
|
|
773
798
|
glassProps: LiquidGlassViewProps;
|
|
@@ -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() {
|
|
@@ -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
|
+
}
|
|
@@ -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":[]}
|
|
@@ -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.0",
|
|
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
|
},
|
|
@@ -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';
|