@sbaiahmed1/react-native-blur 0.2.1 → 3.0.0-beta.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 +125 -20
- package/ReactNativeBlur.podspec +2 -1
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt +150 -46
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurViewManager.kt +25 -0
- package/ios/ReactNativeBlurView.mm +197 -237
- package/ios/ReactNativeBlurView.swift +321 -0
- package/ios/ReactNativeBlurViewManager.h +5 -0
- package/ios/ReactNativeBlurViewManager.m +171 -0
- package/lib/module/BlurView.js +17 -2
- package/lib/module/BlurView.js.map +1 -1
- package/lib/module/ReactNativeBlurViewNativeComponent.ts +10 -3
- package/lib/typescript/src/BlurView.d.ts +36 -1
- package/lib/typescript/src/BlurView.d.ts.map +1 -1
- package/lib/typescript/src/ReactNativeBlurViewNativeComponent.d.ts +9 -3
- package/lib/typescript/src/ReactNativeBlurViewNativeComponent.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/BlurView.tsx +58 -3
- package/src/ReactNativeBlurViewNativeComponent.ts +10 -3
- package/ios/ReactNativeBlurViewManager.mm +0 -23
|
@@ -6,98 +6,172 @@
|
|
|
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 isInteractive from default props
|
|
153
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withIsInteractive:bvProps.isInteractive];
|
|
154
|
+
|
|
155
|
+
// Set initial glassType from default props
|
|
156
|
+
if (bvProps.glassType != facebook::react::ReactNativeBlurViewGlassType::Clear) {
|
|
157
|
+
NSString *glassTypeString = [[NSString alloc] initWithUTF8String:toString(bvProps.glassType).c_str()];
|
|
158
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withGlassType:glassTypeString];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Set initial type from default props
|
|
162
|
+
NSString *blurTypeString = [[NSString alloc] initWithUTF8String:toString(bvProps.type).c_str()];
|
|
163
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withType:blurTypeString];
|
|
164
|
+
|
|
165
|
+
// Set initial reducedTransparencyFallbackColor from default props
|
|
166
|
+
if (!bvProps.reducedTransparencyFallbackColor.empty()) {
|
|
167
|
+
NSString *fallbackColorString = [[NSString alloc] initWithUTF8String:bvProps.reducedTransparencyFallbackColor.c_str()];
|
|
168
|
+
UIColor *fallbackColor = [ReactNativeBlurView colorFromString:fallbackColorString];
|
|
169
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withReducedTransparencyFallbackColor:fallbackColor];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
[self addSubview:_advancedBlurView];
|
|
98
173
|
}
|
|
99
|
-
|
|
100
|
-
return UIBlurEffectStyleLight; // Default
|
|
174
|
+
return self;
|
|
101
175
|
}
|
|
102
176
|
|
|
103
177
|
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
@@ -105,106 +179,76 @@ using namespace facebook::react;
|
|
|
105
179
|
const auto &oldViewProps = *std::static_pointer_cast<ReactNativeBlurViewProps const>(_props);
|
|
106
180
|
const auto &newViewProps = *std::static_pointer_cast<ReactNativeBlurViewProps const>(props);
|
|
107
181
|
|
|
108
|
-
// Update
|
|
109
|
-
if (oldViewProps.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
182
|
+
// Update glassTintColor if it has changed
|
|
183
|
+
if (oldViewProps.glassTintColor != newViewProps.glassTintColor) {
|
|
184
|
+
if (!newViewProps.glassTintColor.empty()) {
|
|
185
|
+
NSString *glassTintColorString = [[NSString alloc] initWithUTF8String:newViewProps.glassTintColor.c_str()];
|
|
186
|
+
UIColor *newGlassTintColor = [ReactNativeBlurView colorFromString:glassTintColorString];
|
|
187
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withGlassTintColor:newGlassTintColor];
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Update glassOpacity if it has changed
|
|
192
|
+
if (oldViewProps.glassOpacity != newViewProps.glassOpacity) {
|
|
193
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withGlassOpacity:newViewProps.glassOpacity];
|
|
115
194
|
}
|
|
116
195
|
|
|
117
|
-
// Update
|
|
196
|
+
// Update blurAmount if it has changed
|
|
118
197
|
if (oldViewProps.blurAmount != newViewProps.blurAmount) {
|
|
119
|
-
[
|
|
198
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withBlurAmount:newViewProps.blurAmount];
|
|
120
199
|
}
|
|
121
200
|
|
|
122
|
-
// Update
|
|
123
|
-
if (oldViewProps.
|
|
124
|
-
if (
|
|
125
|
-
NSString *
|
|
126
|
-
|
|
201
|
+
// Update blurType if it has changed
|
|
202
|
+
if (oldViewProps.blurType != newViewProps.blurType) {
|
|
203
|
+
if (newViewProps.blurType != facebook::react::ReactNativeBlurViewBlurType::Xlight) {
|
|
204
|
+
NSString *blurTypeString = [[NSString alloc] initWithUTF8String:toString(newViewProps.blurType).c_str()];
|
|
205
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withBlurType:blurTypeString];
|
|
127
206
|
}
|
|
128
207
|
}
|
|
129
208
|
|
|
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];
|
|
209
|
+
// Update glassType if it has changed
|
|
210
|
+
if (oldViewProps.glassType != newViewProps.glassType) {
|
|
211
|
+
if (newViewProps.glassType != facebook::react::ReactNativeBlurViewGlassType::Clear) {
|
|
212
|
+
NSString *glassTypeString = [[NSString alloc] initWithUTF8String:toString(newViewProps.glassType).c_str()];
|
|
213
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withGlassType:glassTypeString];
|
|
164
214
|
}
|
|
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;
|
|
215
|
+
}
|
|
171
216
|
|
|
172
|
-
//
|
|
173
|
-
|
|
174
|
-
|
|
217
|
+
// Update type if it has changed
|
|
218
|
+
if (oldViewProps.type != newViewProps.type) {
|
|
219
|
+
NSString *blurTypeString = [[NSString alloc] initWithUTF8String:toString(newViewProps.type).c_str()];
|
|
220
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withType:blurTypeString];
|
|
221
|
+
}
|
|
175
222
|
|
|
176
|
-
//
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
overlayColor = [UIColor colorWithWhite:0.0 alpha:intensity * 0.3];
|
|
180
|
-
} else {
|
|
181
|
-
overlayColor = [UIColor colorWithWhite:1.0 alpha:intensity * 0.2];
|
|
223
|
+
// Update isInteractive if it has changed
|
|
224
|
+
if (oldViewProps.isInteractive != newViewProps.isInteractive) {
|
|
225
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withIsInteractive:newViewProps.isInteractive];
|
|
182
226
|
}
|
|
183
227
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
(
|
|
187
|
-
|
|
188
|
-
|
|
228
|
+
// Update reducedTransparencyFallbackColor if it has changed
|
|
229
|
+
if (oldViewProps.reducedTransparencyFallbackColor != newViewProps.reducedTransparencyFallbackColor) {
|
|
230
|
+
if (!newViewProps.reducedTransparencyFallbackColor.empty()) {
|
|
231
|
+
NSString *fallbackColorString = [[NSString alloc] initWithUTF8String:newViewProps.reducedTransparencyFallbackColor.c_str()];
|
|
232
|
+
UIColor *fallbackColor = [ReactNativeBlurView colorFromString:fallbackColorString];
|
|
233
|
+
[ReactNativeBlurViewHelper updateBlurView:_advancedBlurView withReducedTransparencyFallbackColor:fallbackColor];
|
|
234
|
+
}
|
|
235
|
+
}
|
|
189
236
|
|
|
190
|
-
|
|
237
|
+
// Store the new props
|
|
238
|
+
_props = props;
|
|
191
239
|
|
|
192
|
-
[
|
|
193
|
-
[self.layer addSublayer:blurOverlay];
|
|
240
|
+
[super updateProps:props oldProps:oldProps];
|
|
194
241
|
}
|
|
195
242
|
|
|
196
|
-
- (
|
|
243
|
+
- (void)layoutSubviews
|
|
197
244
|
{
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
return [[NSString alloc] initWithUTF8String:blurTypeStr.c_str()];
|
|
245
|
+
[super layoutSubviews];
|
|
246
|
+
_advancedBlurView.frame = self.bounds;
|
|
201
247
|
}
|
|
202
248
|
|
|
203
249
|
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
204
250
|
{
|
|
205
|
-
|
|
206
|
-
NSInteger adjustedIndex = index + 2;
|
|
207
|
-
[self insertSubview:childComponentView atIndex:adjustedIndex];
|
|
251
|
+
[_advancedBlurView addSubview:childComponentView];
|
|
208
252
|
}
|
|
209
253
|
|
|
210
254
|
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
@@ -212,100 +256,16 @@ using namespace facebook::react;
|
|
|
212
256
|
[childComponentView removeFromSuperview];
|
|
213
257
|
}
|
|
214
258
|
|
|
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
259
|
- (void)dealloc
|
|
247
260
|
{
|
|
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
|
-
}
|
|
261
|
+
[_advancedBlurView removeFromSuperview];
|
|
262
|
+
_advancedBlurView = nil;
|
|
272
263
|
}
|
|
273
264
|
|
|
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
|
-
}
|
|
265
|
+
@end
|
|
289
266
|
|
|
290
|
-
|
|
267
|
+
Class<RCTComponentViewProtocol> BlurryViewCls(void)
|
|
291
268
|
{
|
|
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];
|
|
269
|
+
return ReactNativeBlurView.class;
|
|
309
270
|
}
|
|
310
271
|
|
|
311
|
-
@end
|