@sbaiahmed1/react-native-blur 0.2.0 → 0.3.0-beta.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 +271 -16
- package/ReactNativeBlur.podspec +2 -1
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeBlurViewManagerDelegate.java +38 -0
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeBlurViewManagerInterface.java +20 -0
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeGlassViewManagerDelegate.java +38 -0
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeGlassViewManagerInterface.java +20 -0
- package/android/app/build/generated/source/codegen/jni/CMakeLists.txt +36 -0
- package/android/app/build/generated/source/codegen/jni/ReactNativeBlurViewSpec-generated.cpp +22 -0
- package/android/app/build/generated/source/codegen/jni/ReactNativeBlurViewSpec.h +24 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ComponentDescriptors.cpp +23 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ComponentDescriptors.h +25 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/EventEmitters.cpp +17 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/EventEmitters.h +30 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/Props.cpp +36 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/Props.h +91 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ReactNativeBlurViewSpecJSI-generated.cpp +17 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ReactNativeBlurViewSpecJSI.h +19 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ShadowNodes.cpp +18 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ShadowNodes.h +43 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/States.cpp +16 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/States.h +41 -0
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt +164 -39
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurViewManager.kt +20 -0
- package/ios/ReactNativeBlurView.mm +190 -238
- package/ios/ReactNativeBlurView.swift +309 -0
- package/ios/ReactNativeBlurViewManager.h +5 -0
- package/ios/ReactNativeBlurViewManager.m +165 -0
- package/lib/module/BlurView.js +14 -2
- package/lib/module/BlurView.js.map +1 -1
- package/lib/module/ReactNativeBlurViewNativeComponent.ts +9 -3
- package/lib/typescript/src/BlurView.d.ts +30 -1
- package/lib/typescript/src/BlurView.d.ts.map +1 -1
- package/lib/typescript/src/ReactNativeBlurViewNativeComponent.d.ts +8 -3
- package/lib/typescript/src/ReactNativeBlurViewNativeComponent.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/BlurView.tsx +48 -3
- package/src/ReactNativeBlurViewNativeComponent.ts +9 -3
- package/ios/ReactNativeBlurViewManager.mm +0 -23
|
@@ -6,98 +6,169 @@
|
|
|
6
6
|
#import <react/renderer/components/ReactNativeBlurViewSpec/RCTComponentViewHelpers.h>
|
|
7
7
|
|
|
8
8
|
#import "RCTFabricComponentsPlugins.h"
|
|
9
|
+
#import "ReactNativeBlur-Swift.h" // Swift bridging header
|
|
9
10
|
|
|
10
11
|
using namespace facebook::react;
|
|
11
12
|
|
|
12
13
|
@interface ReactNativeBlurView () <RCTReactNativeBlurViewViewProtocol>
|
|
13
|
-
|
|
14
14
|
@end
|
|
15
15
|
|
|
16
16
|
@implementation ReactNativeBlurView {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
22
|
-
{
|
|
23
|
-
return concreteComponentDescriptorProvider<ReactNativeBlurViewComponentDescriptor>();
|
|
17
|
+
AdvancedBlurView *_advancedBlurView;
|
|
18
|
+
Props::Shared _props;
|
|
24
19
|
}
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
_props = defaultProps;
|
|
31
|
-
|
|
32
|
-
[self setupBlurView];
|
|
21
|
+
+ (UIColor *)colorFromString:(NSString *)colorString {
|
|
22
|
+
// Input validation
|
|
23
|
+
if (!colorString || [colorString isEqualToString:@""] || colorString.length == 0) {
|
|
24
|
+
return [UIColor clearColor]; // Default color
|
|
33
25
|
}
|
|
34
26
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
27
|
+
// Prevent excessively long strings that could cause performance issues
|
|
28
|
+
if (colorString.length > 50) {
|
|
29
|
+
NSLog(@"[ReactNativeBlurView] Warning: Color string too long, using default clear color");
|
|
30
|
+
return [UIColor clearColor];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Handle common color names
|
|
34
|
+
NSDictionary *colorMap = @{
|
|
35
|
+
@"red": [UIColor redColor],
|
|
36
|
+
@"blue": [UIColor blueColor],
|
|
37
|
+
@"green": [UIColor greenColor],
|
|
38
|
+
@"yellow": [UIColor yellowColor],
|
|
39
|
+
@"orange": [UIColor orangeColor],
|
|
40
|
+
@"purple": [UIColor purpleColor],
|
|
41
|
+
@"black": [UIColor blackColor],
|
|
42
|
+
@"white": [UIColor whiteColor],
|
|
43
|
+
@"gray": [UIColor grayColor],
|
|
44
|
+
@"clear": [UIColor clearColor],
|
|
45
|
+
@"transparent": [UIColor clearColor]
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
UIColor *namedColor = colorMap[colorString.lowercaseString];
|
|
49
|
+
if (namedColor) {
|
|
50
|
+
return namedColor;
|
|
51
|
+
}
|
|
45
52
|
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
// Handle hex colors (e.g., "#FF0000", "FF0000", "#FF00FF00", "FF00FF00")
|
|
54
|
+
NSString *hexString = colorString;
|
|
55
|
+
if ([hexString hasPrefix:@"#"]) {
|
|
56
|
+
if (hexString.length < 2) {
|
|
57
|
+
NSLog(@"[ReactNativeBlurView] Warning: Invalid hex color format '%@', using default clear color", colorString);
|
|
58
|
+
return [UIColor clearColor];
|
|
59
|
+
}
|
|
60
|
+
hexString = [hexString substringFromIndex:1];
|
|
61
|
+
}
|
|
52
62
|
|
|
53
|
-
//
|
|
54
|
-
[
|
|
55
|
-
[
|
|
63
|
+
// Validate hex string contains only valid hex characters
|
|
64
|
+
NSCharacterSet *hexCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789ABCDEFabcdef"];
|
|
65
|
+
NSCharacterSet *invalidCharacters = [hexCharacterSet invertedSet];
|
|
66
|
+
if ([hexString rangeOfCharacterFromSet:invalidCharacters].location != NSNotFound) {
|
|
67
|
+
NSLog(@"[ReactNativeBlurView] Warning: Invalid hex color format '%@', contains non-hex characters", colorString);
|
|
68
|
+
return [UIColor clearColor];
|
|
69
|
+
}
|
|
56
70
|
|
|
57
|
-
//
|
|
58
|
-
|
|
71
|
+
// Handle 6-character hex (RGB)
|
|
72
|
+
if (hexString.length == 6) {
|
|
73
|
+
unsigned int hexValue;
|
|
74
|
+
NSScanner *scanner = [NSScanner scannerWithString:hexString];
|
|
75
|
+
if ([scanner scanHexInt:&hexValue] && [scanner isAtEnd]) {
|
|
76
|
+
return [UIColor colorWithRed:((hexValue & 0xFF0000) >> 16) / 255.0
|
|
77
|
+
green:((hexValue & 0x00FF00) >> 8) / 255.0
|
|
78
|
+
blue:(hexValue & 0x0000FF) / 255.0
|
|
79
|
+
alpha:1.0];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Handle 8-character hex (RGBA)
|
|
83
|
+
else if (hexString.length == 8) {
|
|
84
|
+
unsigned long long hexValue;
|
|
85
|
+
NSScanner *scanner = [NSScanner scannerWithString:hexString];
|
|
86
|
+
if ([scanner scanHexLongLong:&hexValue] && [scanner isAtEnd]) {
|
|
87
|
+
return [UIColor colorWithRed:((hexValue & 0xFF000000) >> 24) / 255.0
|
|
88
|
+
green:((hexValue & 0x00FF0000) >> 16) / 255.0
|
|
89
|
+
blue:((hexValue & 0x0000FF00) >> 8) / 255.0
|
|
90
|
+
alpha:(hexValue & 0x000000FF) / 255.0];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Handle 3-character hex (RGB shorthand)
|
|
94
|
+
else if (hexString.length == 3) {
|
|
95
|
+
unsigned int hexValue;
|
|
96
|
+
NSScanner *scanner = [NSScanner scannerWithString:hexString];
|
|
97
|
+
if ([scanner scanHexInt:&hexValue] && [scanner isAtEnd]) {
|
|
98
|
+
// Expand 3-digit hex to 6-digit (e.g., "F0A" -> "FF00AA")
|
|
99
|
+
unsigned int r = (hexValue & 0xF00) >> 8;
|
|
100
|
+
unsigned int g = (hexValue & 0x0F0) >> 4;
|
|
101
|
+
unsigned int b = (hexValue & 0x00F);
|
|
102
|
+
|
|
103
|
+
return [UIColor colorWithRed:(r | (r << 4)) / 255.0
|
|
104
|
+
green:(g | (g << 4)) / 255.0
|
|
105
|
+
blue:(b | (b << 4)) / 255.0
|
|
106
|
+
alpha:1.0];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
NSLog(@"[ReactNativeBlurView] Warning: Unsupported hex color length (%lu) for '%@', expected 3, 6, or 8 characters",
|
|
111
|
+
(unsigned long)hexString.length, colorString);
|
|
112
|
+
}
|
|
59
113
|
|
|
60
|
-
|
|
61
|
-
[
|
|
62
|
-
selector:@selector(updateForReducedTransparency)
|
|
63
|
-
name:UIAccessibilityReduceTransparencyStatusDidChangeNotification
|
|
64
|
-
object:nil];
|
|
114
|
+
NSLog(@"[ReactNativeBlurView] Warning: Could not parse color '%@', using default clear color", colorString);
|
|
115
|
+
return [UIColor clearColor]; // Fallback to clear
|
|
65
116
|
}
|
|
66
117
|
|
|
67
|
-
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
68
121
|
{
|
|
69
|
-
|
|
70
|
-
_blurView.hidden = reduceTransparency;
|
|
71
|
-
_fallbackView.hidden = !reduceTransparency;
|
|
122
|
+
return concreteComponentDescriptorProvider<ReactNativeBlurViewComponentDescriptor>();
|
|
72
123
|
}
|
|
73
124
|
|
|
74
|
-
- (
|
|
125
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
75
126
|
{
|
|
76
|
-
if ([
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
127
|
+
if (self = [super initWithFrame:frame]) {
|
|
128
|
+
static const auto defaultProps = std::make_shared<const ReactNativeBlurViewProps>();
|
|
129
|
+
_props = defaultProps;
|
|
130
|
+
|
|
131
|
+
const auto &bvProps = *std::static_pointer_cast<const ReactNativeBlurViewProps>(defaultProps);
|
|
132
|
+
|
|
133
|
+
_advancedBlurView = [ReactNativeBlurViewHelper createBlurViewWithFrame:frame];
|
|
134
|
+
|
|
135
|
+
// Set initial glassTintColor from default props
|
|
136
|
+
NSString *defaultGlassTintColorString = [[NSString alloc] initWithUTF8String:bvProps.glassTintColor.c_str()];
|
|
137
|
+
UIColor *defaultGlassTintColor = [ReactNativeBlurView colorFromString:defaultGlassTintColorString];
|
|
138
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withGlassTintColor:defaultGlassTintColor];
|
|
139
|
+
|
|
140
|
+
// Set initial glassOpacity from default props
|
|
141
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withGlassOpacity:bvProps.glassOpacity];
|
|
142
|
+
|
|
143
|
+
// Set initial blurAmount from default props
|
|
144
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withBlurAmount:bvProps.blurAmount];
|
|
145
|
+
|
|
146
|
+
// Set initial blurType from default props
|
|
147
|
+
if (bvProps.blurType != facebook::react::ReactNativeBlurViewBlurType::Xlight) {
|
|
148
|
+
NSString *blurTypeString = [[NSString alloc] initWithUTF8String:toString(bvProps.blurType).c_str()];
|
|
149
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withBlurType:blurTypeString];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Set initial glassType from default props
|
|
153
|
+
if (bvProps.glassType != facebook::react::ReactNativeBlurViewGlassType::Clear) {
|
|
154
|
+
NSString *glassTypeString = [[NSString alloc] initWithUTF8String:toString(bvProps.glassType).c_str()];
|
|
155
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withGlassType:glassTypeString];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Set initial type from default props
|
|
159
|
+
NSString *blurTypeString = [[NSString alloc] initWithUTF8String:toString(bvProps.type).c_str()];
|
|
160
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withType:blurTypeString];
|
|
161
|
+
|
|
162
|
+
// Set initial reducedTransparencyFallbackColor from default props
|
|
163
|
+
if (!bvProps.reducedTransparencyFallbackColor.empty()) {
|
|
164
|
+
NSString *fallbackColorString = [[NSString alloc] initWithUTF8String:bvProps.reducedTransparencyFallbackColor.c_str()];
|
|
165
|
+
UIColor *fallbackColor = [ReactNativeBlurView colorFromString:fallbackColorString];
|
|
166
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withReducedTransparencyFallbackColor:fallbackColor];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
[self addSubview:_advancedBlurView];
|
|
98
170
|
}
|
|
99
|
-
|
|
100
|
-
return UIBlurEffectStyleLight; // Default
|
|
171
|
+
return self;
|
|
101
172
|
}
|
|
102
173
|
|
|
103
174
|
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
@@ -105,106 +176,71 @@ using namespace facebook::react;
|
|
|
105
176
|
const auto &oldViewProps = *std::static_pointer_cast<ReactNativeBlurViewProps const>(_props);
|
|
106
177
|
const auto &newViewProps = *std::static_pointer_cast<ReactNativeBlurViewProps const>(props);
|
|
107
178
|
|
|
108
|
-
// Update
|
|
109
|
-
if (oldViewProps.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
179
|
+
// Update glassTintColor if it has changed
|
|
180
|
+
if (oldViewProps.glassTintColor != newViewProps.glassTintColor) {
|
|
181
|
+
if (!newViewProps.glassTintColor.empty()) {
|
|
182
|
+
NSString *glassTintColorString = [[NSString alloc] initWithUTF8String:newViewProps.glassTintColor.c_str()];
|
|
183
|
+
UIColor *newGlassTintColor = [ReactNativeBlurView colorFromString:glassTintColorString];
|
|
184
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withGlassTintColor:newGlassTintColor];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Update glassOpacity if it has changed
|
|
189
|
+
if (oldViewProps.glassOpacity != newViewProps.glassOpacity) {
|
|
190
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withGlassOpacity:newViewProps.glassOpacity];
|
|
115
191
|
}
|
|
116
192
|
|
|
117
|
-
// Update
|
|
193
|
+
// Update blurAmount if it has changed
|
|
118
194
|
if (oldViewProps.blurAmount != newViewProps.blurAmount) {
|
|
119
|
-
[
|
|
195
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withBlurAmount:newViewProps.blurAmount];
|
|
120
196
|
}
|
|
121
197
|
|
|
122
|
-
// Update
|
|
123
|
-
if (oldViewProps.
|
|
124
|
-
if (
|
|
125
|
-
NSString *
|
|
126
|
-
|
|
198
|
+
// Update blurType if it has changed
|
|
199
|
+
if (oldViewProps.blurType != newViewProps.blurType) {
|
|
200
|
+
if (newViewProps.blurType != facebook::react::ReactNativeBlurViewBlurType::Xlight) {
|
|
201
|
+
NSString *blurTypeString = [[NSString alloc] initWithUTF8String:toString(newViewProps.blurType).c_str()];
|
|
202
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withBlurType:blurTypeString];
|
|
127
203
|
}
|
|
128
204
|
}
|
|
129
205
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
// For amounts 0-30: Use alpha blending with UIVisualEffectView
|
|
136
|
-
// For amounts 30+: Create custom blur effect with Core Image
|
|
137
|
-
|
|
138
|
-
if (amount <= 30.0) {
|
|
139
|
-
// Use standard UIVisualEffectView with alpha
|
|
140
|
-
CGFloat alpha = amount / 30.0; // Scale to 0-1 for low amounts
|
|
141
|
-
_blurView.alpha = alpha;
|
|
142
|
-
|
|
143
|
-
// Remove any custom blur layer
|
|
144
|
-
[self.layer.sublayers enumerateObjectsUsingBlock:^(CALayer *layer, NSUInteger idx, BOOL *stop) {
|
|
145
|
-
if ([layer.name isEqualToString:@"customBlur"]) {
|
|
146
|
-
[layer removeFromSuperlayer];
|
|
147
|
-
}
|
|
148
|
-
}];
|
|
149
|
-
} else {
|
|
150
|
-
// Use full opacity for the base blur
|
|
151
|
-
_blurView.alpha = 1.0;
|
|
152
|
-
|
|
153
|
-
// Add custom blur overlay for enhanced effect
|
|
154
|
-
[self addCustomBlurOverlayWithIntensity:(amount - 30.0) / 70.0]; // Scale 30-100 to 0-1
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
- (void)addCustomBlurOverlayWithIntensity:(CGFloat)intensity
|
|
159
|
-
{
|
|
160
|
-
// Remove existing custom blur layer
|
|
161
|
-
[self.layer.sublayers enumerateObjectsUsingBlock:^(CALayer *layer, NSUInteger idx, BOOL *stop) {
|
|
162
|
-
if ([layer.name isEqualToString:@"customBlur"]) {
|
|
163
|
-
[layer removeFromSuperlayer];
|
|
206
|
+
// Update glassType if it has changed
|
|
207
|
+
if (oldViewProps.glassType != newViewProps.glassType) {
|
|
208
|
+
if (newViewProps.glassType != facebook::react::ReactNativeBlurViewGlassType::Clear) {
|
|
209
|
+
NSString *glassTypeString = [[NSString alloc] initWithUTF8String:toString(newViewProps.glassType).c_str()];
|
|
210
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withGlassType:glassTypeString];
|
|
164
211
|
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Create a semi-transparent overlay that simulates additional blur
|
|
168
|
-
CALayer *blurOverlay = [CALayer layer];
|
|
169
|
-
blurOverlay.name = @"customBlur";
|
|
170
|
-
blurOverlay.frame = self.bounds;
|
|
171
|
-
|
|
172
|
-
// Create a gradient effect that simulates depth
|
|
173
|
-
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
|
|
174
|
-
gradientLayer.frame = self.bounds;
|
|
212
|
+
}
|
|
175
213
|
|
|
176
|
-
//
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
} else {
|
|
181
|
-
overlayColor = [UIColor colorWithWhite:1.0 alpha:intensity * 0.2];
|
|
214
|
+
// Update type if it has changed
|
|
215
|
+
if (oldViewProps.type != newViewProps.type) {
|
|
216
|
+
NSString *blurTypeString = [[NSString alloc] initWithUTF8String:toString(newViewProps.type).c_str()];
|
|
217
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withType:blurTypeString];
|
|
182
218
|
}
|
|
183
219
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
(
|
|
187
|
-
|
|
188
|
-
|
|
220
|
+
// Update reducedTransparencyFallbackColor if it has changed
|
|
221
|
+
if (oldViewProps.reducedTransparencyFallbackColor != newViewProps.reducedTransparencyFallbackColor) {
|
|
222
|
+
if (!newViewProps.reducedTransparencyFallbackColor.empty()) {
|
|
223
|
+
NSString *fallbackColorString = [[NSString alloc] initWithUTF8String:newViewProps.reducedTransparencyFallbackColor.c_str()];
|
|
224
|
+
UIColor *fallbackColor = [ReactNativeBlurView colorFromString:fallbackColorString];
|
|
225
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withReducedTransparencyFallbackColor:fallbackColor];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
189
228
|
|
|
190
|
-
|
|
229
|
+
// Store the new props
|
|
230
|
+
_props = props;
|
|
191
231
|
|
|
192
|
-
[
|
|
193
|
-
[self.layer addSublayer:blurOverlay];
|
|
232
|
+
[super updateProps:props oldProps:oldProps];
|
|
194
233
|
}
|
|
195
234
|
|
|
196
|
-
- (
|
|
235
|
+
- (void)layoutSubviews
|
|
197
236
|
{
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
return [[NSString alloc] initWithUTF8String:blurTypeStr.c_str()];
|
|
237
|
+
[super layoutSubviews];
|
|
238
|
+
_advancedBlurView.frame = self.bounds;
|
|
201
239
|
}
|
|
202
240
|
|
|
203
241
|
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
204
242
|
{
|
|
205
|
-
|
|
206
|
-
NSInteger adjustedIndex = index + 2;
|
|
207
|
-
[self insertSubview:childComponentView atIndex:adjustedIndex];
|
|
243
|
+
[_advancedBlurView addSubview:childComponentView];
|
|
208
244
|
}
|
|
209
245
|
|
|
210
246
|
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
@@ -212,100 +248,16 @@ using namespace facebook::react;
|
|
|
212
248
|
[childComponentView removeFromSuperview];
|
|
213
249
|
}
|
|
214
250
|
|
|
215
|
-
- (void)layoutSubviews
|
|
216
|
-
{
|
|
217
|
-
[super layoutSubviews];
|
|
218
|
-
|
|
219
|
-
// Ensure blur view and fallback view cover the entire bounds
|
|
220
|
-
if (_blurView) {
|
|
221
|
-
_blurView.frame = self.bounds;
|
|
222
|
-
}
|
|
223
|
-
if (_fallbackView) {
|
|
224
|
-
_fallbackView.frame = self.bounds;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// Keep blur views at the back without using sendSubviewToBack to avoid index conflicts
|
|
228
|
-
if (_blurView && _blurView.superview == self) {
|
|
229
|
-
// Move to index 0 if not already there
|
|
230
|
-
NSInteger currentIndex = [self.subviews indexOfObject:_blurView];
|
|
231
|
-
if (currentIndex != 0 && currentIndex != NSNotFound) {
|
|
232
|
-
[_blurView removeFromSuperview];
|
|
233
|
-
[self insertSubview:_blurView atIndex:0];
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
if (_fallbackView && _fallbackView.superview == self) {
|
|
237
|
-
// Move to index 1 if not already there (after blur view)
|
|
238
|
-
NSInteger currentIndex = [self.subviews indexOfObject:_fallbackView];
|
|
239
|
-
if (currentIndex != 1 && currentIndex != NSNotFound) {
|
|
240
|
-
[_fallbackView removeFromSuperview];
|
|
241
|
-
[self insertSubview:_fallbackView atIndex:1];
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
251
|
- (void)dealloc
|
|
247
252
|
{
|
|
248
|
-
[
|
|
249
|
-
|
|
250
|
-
// Clean up blur views
|
|
251
|
-
if (_blurView) {
|
|
252
|
-
[_blurView removeFromSuperview];
|
|
253
|
-
_blurView = nil;
|
|
254
|
-
}
|
|
255
|
-
if (_fallbackView) {
|
|
256
|
-
[_fallbackView removeFromSuperview];
|
|
257
|
-
_fallbackView = nil;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
Class<RCTComponentViewProtocol> ReactNativeBlurViewCls(void)
|
|
262
|
-
{
|
|
263
|
-
return ReactNativeBlurView.class;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// Legacy compatibility methods for Old Architecture
|
|
267
|
-
- (void)setBlurAmount:(NSNumber *)blurAmount
|
|
268
|
-
{
|
|
269
|
-
if (blurAmount) {
|
|
270
|
-
[self updateBlurEffectWithAmount:[blurAmount doubleValue]];
|
|
271
|
-
}
|
|
253
|
+
[_advancedBlurView removeFromSuperview];
|
|
254
|
+
_advancedBlurView = nil;
|
|
272
255
|
}
|
|
273
256
|
|
|
274
|
-
|
|
275
|
-
{
|
|
276
|
-
if (blurType) {
|
|
277
|
-
UIBlurEffectStyle blurStyle = [self blurEffectStyleFromString:blurType];
|
|
278
|
-
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:blurStyle];
|
|
279
|
-
_blurView.effect = blurEffect;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
- (void)setReducedTransparencyFallbackColor:(NSString *)color
|
|
284
|
-
{
|
|
285
|
-
if (color && color.length > 0) {
|
|
286
|
-
_fallbackView.backgroundColor = [self hexStringToColor:color];
|
|
287
|
-
}
|
|
288
|
-
}
|
|
257
|
+
@end
|
|
289
258
|
|
|
290
|
-
|
|
259
|
+
Class<RCTComponentViewProtocol> BlurryViewCls(void)
|
|
291
260
|
{
|
|
292
|
-
|
|
293
|
-
return [UIColor clearColor];
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
NSString *noHashString = [stringToConvert stringByReplacingOccurrencesOfString:@"#" withString:@""];
|
|
297
|
-
NSScanner *stringScanner = [NSScanner scannerWithString:noHashString];
|
|
298
|
-
|
|
299
|
-
unsigned hex;
|
|
300
|
-
if (![stringScanner scanHexInt:&hex]) {
|
|
301
|
-
return [UIColor clearColor];
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
int r = (hex >> 16) & 0xFF;
|
|
305
|
-
int g = (hex >> 8) & 0xFF;
|
|
306
|
-
int b = (hex) & 0xFF;
|
|
307
|
-
|
|
308
|
-
return [UIColor colorWithRed:r / 255.0f green:g / 255.0f blue:b / 255.0f alpha:1.0f];
|
|
261
|
+
return ReactNativeBlurView.class;
|
|
309
262
|
}
|
|
310
263
|
|
|
311
|
-
@end
|