Dimezis / BlurView

Dynamic iOS-like blur of underlying Views for Android
Apache License 2.0
3.48k stars 331 forks source link

BlurView doesn't provide dynamic blur for BottomSheetDialogFragment #216

Closed hmmmk closed 1 month ago

hmmmk commented 1 month ago

I'm trying to make dynamic blur for a BottomSheetDialog fragment. But the thing is, that BlurView correctly takes snapshot of underlying content and blurs it, but only statically. When I'm trying to move my bottom sheet fragment up and down, blur remains the same, and I want to make it to change when bottom sheet is moving.

Here is how I enable it in the kotlin code:

val rootView = requireActivity().window.decorView as ViewGroup
            bgView.setupWith(rootView)
                .setBlurRadius(10f)
                .setBlurAutoUpdate(true)

In the XML layout of BottomSheetDialogFragment, BlurView is just top element of all hierarchy.

Dimezis commented 1 month ago

I have a suspicion about the root cause. It would help if you could share a sample project

hmmmk commented 1 month ago

@Dimezis can I invite you to a closed repo with the project itself? I think it's better to you to check this one in real-case scenario. I will point to the files where I set up BlurView

Dimezis commented 1 month ago

Sure, that would work for me too

hmmmk commented 1 month ago

@Dimezis sent an invite. The BlurView is used in PurchaseFragmentBottomSheet.kt at line 101

hmmmk commented 1 month ago

@Dimezis any updates on this issue?

Dimezis commented 1 month ago

@hmmmk I am not able to go through the signup process in your app, please just extract the problematic place into a separate example project, or provide a simple way to reproduce the issue in this project.

hmmmk commented 1 month ago

@Dimezis okay, I made a branch called blurtest. If you build this branch it will open screen where you should just press on a button with a big heart, it will open BottomSheetFragment, and you'll see the issue

Dimezis commented 1 month ago

I don't see the bottom sheet Screenshot_20240725_102443

hmmmk commented 1 month ago

@Dimezis telegram-cloud-photo-size-2-5264830719312648738-y Go to the first page and press on the button that I highlited on a screenshot

Dimezis commented 1 month ago

Version 2.0.5 should fix this issue. But you also have a different problem - you select a rootView that doesn't include the bottom bar, so it's not getting blurred.

hmmmk commented 1 month ago

Version 2.0.5 should fix this issue. But you also have a different problem - you select a rootView that doesn't include the bottom bar, so it's not getting blurred.

But I select rootView of the whole activity, how it doesn't include bottom bar?

Dimezis commented 1 month ago

But I select rootView of the whole activity, how it doesn't include bottom bar?

You don't. Well, not on this branch anyway. This code from your first post is nowhere to be seen in your project.

val rootView = requireActivity().window.decorView as ViewGroup
bgView.setupWith(rootView)

Your setup looks like this instead:

val rootView = requireParentFragment().requireParentFragment().requireParentFragment().view as ViewGroup
bgView.setupWith(rootView)
hmmmk commented 1 month ago

But I select rootView of the whole activity, how it doesn't include bottom bar?

You don't. Well, not on this branch anyway. This code from your first post is nowhere to be seen in your project.

val rootView = requireActivity().window.decorView as ViewGroup
bgView.setupWith(rootView)

Your setup looks like this instead:

val rootView = requireParentFragment().requireParentFragment().requireParentFragment().view as ViewGroup
bgView.setupWith(rootView)

Yep, you right. I forgot about this. But anyway, I tried to put 2.0.5 and it's still not working as expected

krupalivaghasiya24 commented 1 month ago

@Dimezis I tried version-2.0.5 but getting this error

Could not find com.github.Dimezis:BlurView:version-2.0.5. 2.0.4 is working fine for me

implementation ("com.github.Dimezis:BlurView:version-2.0.5")

janbolat commented 1 month ago

Build failed: https://jitpack.io/com/github/Dimezis/BlurView/version-2.0.5/build.log

Dimezis commented 1 month ago

@krupalivaghasiya24 @janbolat Should be good now

hmmmk commented 1 month ago

@Dimezis any ideas on how to improve performance when using BlurView as BottomSheetDialogFragment background?

Dimezis commented 1 month ago

RenderEffectBlur should be more performant

hmmmk commented 1 month ago

@Dimezis okay, despite that, the issue is solved