Allow transparent blur-type for ios

Patch from https://github.com/Kureev/react-native-blur/pull/513
This commit is contained in:
Parvesh Monu 2023-01-16 03:01:34 +05:30
parent ec607e5265
commit 1bb58aa0d1
No known key found for this signature in database
GPG Key ID: F399696520817DE9
6 changed files with 12 additions and 1 deletions

View File

@ -52,6 +52,7 @@ cd ios && pod install
| `extraDark` | extra dark blur type (tvOS only)
| `regular` | regular blur type (iOS 10+ and tvOS only)
| `prominent` | prominent blur type (iOS 10+ and tvOS only)
| `transparent` | transparent blur type (iOS 10+ and tvOS only)
#### blurType (iOS 13 only)

View File

@ -23,7 +23,7 @@ import {
const blurTypeValues =
Platform.OS === 'ios'
? ['xlight', 'light', 'dark', 'regular', 'prominent']
? ['xlight', 'light', 'dark', 'regular', 'prominent', 'transparent']
: ['xlight', 'light', 'dark'];
const Blurs = () => {

View File

@ -131,6 +131,7 @@ using namespace facebook::react;
- (UIBlurEffectStyle)blurEffectStyle
{
if ([self.blurType isEqual: @"transparent"]) return UIBlurEffectStyleDark;
if ([self.blurType isEqual: @"xlight"]) return UIBlurEffectStyleExtraLight;
if ([self.blurType isEqual: @"light"]) return UIBlurEffectStyleLight;
if ([self.blurType isEqual: @"dark"]) return UIBlurEffectStyleDark;
@ -183,6 +184,12 @@ using namespace facebook::react;
UIBlurEffectStyle style = [self blurEffectStyle];
self.blurEffect = [BlurEffectWithAmount effectWithStyle:style andBlurAmount:self.blurAmount];
self.blurEffectView.effect = self.blurEffect;
if ([self.blurType isEqual: @"transparent"]) {
for (UIView *subview in self.blurEffectView.subviews) {
subview.backgroundColor = [UIColor clearColor];
}
}
}
- (void)updateFallbackView

View File

@ -6,6 +6,7 @@ type BlurType =
| 'dark'
| 'light'
| 'xlight'
| 'transparent'
| 'prominent'
| 'regular'
| 'extraDark'

View File

@ -10,6 +10,7 @@ interface NativeProps extends ViewProps {
| 'dark'
| 'light'
| 'xlight'
| 'transparent'
| 'prominent'
| 'regular'
| 'extraDark'

View File

@ -10,6 +10,7 @@ interface NativeProps extends ViewProps {
| 'dark'
| 'light'
| 'xlight'
| 'transparent'
| 'prominent'
| 'regular'
| 'extraDark'