Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(iOS): transparent blur type #513

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kirgudkov
Copy link

@kirgudkov kirgudkov commented Nov 30, 2022

Hi there 👋 hope you're doing well

I've been looking for a way to implement Twitter-like navbar:

and it seems like it's not possible with current blur types.

So here's what I came up with: transparent blur type applies UIBlurEffectStyleDark (it doesn't matter dark or light) style and overrites backgroundColor property for each subview to transparent color. Works the same regardless of the selected system color scheme

blurType={'dark'} blurType={'transparent'}
before after

Probably it solves #474 and #465

Tested both BlurView and VibrancyView on iOS simulator including example project.
Update README.md and example

@suzil
Copy link

suzil commented Dec 19, 2022

Maybe also closes #407

@OskarEichler
Copy link

This is great and exactly what we are looking for as well, as the dark type is darkening too much! Would be great if this can get merged! 🤘🏼

@sapkra
Copy link

sapkra commented Jan 18, 2023

@Titozzz Sorry for pinging you, but do you have some spare time to review this PR? It's something we and other really need.

@Parveshdhull
Copy link

Hi @KirillGudkov, really awesome work 🎉 🥳
This is working great with most background colors, and the overlay is fully transparent when nothing is below it. But for a few colors, it kind of creates a visible overlay as shown in the image.
shot

Fully Transparent - Black, Red
Creates Overlay - Green, #09101C (Used in above image, creates bluish overlay)

The last color is important for my use, please can you take a look if you can reproduce this too. Thank you in advance.

@joisadler
Copy link

This solution is exactly what I'm looking for! I have also tested it locally on the project that I'm working on and it works perfectly there. @Kureev please, we need this PR to be accepted ASAP!

@kirgudkov
Copy link
Author

@Parveshdhull Hey! Thanks a lot for the kind words! I totally can reproduce it.
I tried to fix it but it doesn't seem to do anything about it. It doesn't look like a "hidden" overlay or smth. As far as I can see - the BlurEffectView makes all colors a bit more saturated, except for achromatic colors: whites, blacks and grays (because it's impoissible lol)

For example below purple and orange appears more vibrant. And as you can see - there is some glow effect with gradient from more saturated to less. "Right purple" somewhere in the middle 😅 So that's how it works, I guess there's nothing I can do.

1 2

@filippobarcellos
Copy link

@Parveshdhull I've got the same problem as yours. Did you manage to fix it?

@sapkra
Copy link

sapkra commented Mar 1, 2023

There might be a new approach for adding blur using react-native-skia which is actively maintained by Shopify. But I have not tried it yet. It's worth a try and it might not have these bugs.

https://shopify.github.io/react-native-skia/docs/backdrops-filters

@Parveshdhull
Copy link

@Parveshdhull I've got the same problem as yours. Did you manage to fix it?

No, still no luck. I skipped this for now and created an issue to track it. status-im/status-mobile#14903

@Parveshdhull
Copy link

There might be a new approach for adding blur using react-native-skia which is actively maintained by Shopify. But I have not tried it yet. It's worth a try and it might not have these bugs.

https://shopify.github.io/react-native-skia/docs/backdrops-filters

This looks promising, Thank you

@sapkra
Copy link

sapkra commented Mar 1, 2023

Shopify/react-native-skia#324 (comment)

It doesn't seem to be possible right now but it might be worth to get in contact with the maintainers. It's probaly something the community can contribute.

@chen-rn
Copy link

chen-rn commented Mar 29, 2023

@Parveshdhull @KirillGudkov
So it seems like the main issue with this patch is that BlurEffectView makes all colors more saturated (by something like 180%, unclear why)

Is there something that allows us to "de-saturate" a particular view?

Copy link

@Hady207 Hady207 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working fine please merge

@pottercomuneo
Copy link

So when will this be merged? 😬 or do I have to switch to another library?

@stephenkopylov
Copy link

Merge when?

@ugar0ff
Copy link

ugar0ff commented Feb 9, 2024

Working fine please merge

I noticed that it works well on some colors, but on some, it still doesn't work.

@TheRealNate
Copy link

Even if it's not working with some colors, could be merged with "transparent" as a beta option?

@@ -131,6 +131,7 @@ - (void)setReducedTransparencyFallbackColor:(nullable UIColor *)reducedTranspare

- (UIBlurEffectStyle)blurEffectStyle
{
if ([self.blurType isEqual: @"transparent"]) return UIBlurEffectStyleDark;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your good contribution on important issues.
I also want this feature with white background, so I used your changed code and just fixed this line as
if ([self.blurType isEqual: @"transparent"]) return UIBlurEffectStyleLight;.
However it shows dark background and not working.. Do you have any idea about this problem?

Copy link
Author

@kirgudkov kirgudkov Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. I've just tested both cases (dark and light backgrounds) and everything seems to be working great. No changes in the native code 🤔

1 2
1 2

Code is just like this. It doesn't depend on theme or whatever:

<BlurView
  blurAmount={7} 
  blurType={"transparent"} 
/>

Please make sure you're using it right. If the problem still exists, could you elaborate a bit? What kind of effect are you trying to achieve? The image will do

siddarthkay pushed a commit to siddarthkay/react-native-blur that referenced this pull request Apr 16, 2024
chore: update README.md (Kureev#494)

Update build.gradle

Allow transparent blur-type for ios

Patch from Kureev#513

chore: add compiled lib folder, don't rely on package.json hooks

Update BlurViewManagerImpl.java with patch

Bump version to 4.3.2

chore: Android BlurView upgraded to 2.0.3 (status-im#3)

Author: Ajay Sivan <ajayesivan@gmail.com>

Bump version to 4.3.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet