skydoves / Cloudy

☁️ Jetpack Compose blur effect library, which falls back onto a CPU-based implementation to support older API levels.
Apache License 2.0
789 stars 28 forks source link

Using Cloudy in Dialog compose #18

Closed PepaZapletal closed 1 month ago

PepaZapletal commented 7 months ago

Is it possible to use Cloudy in Dialog to have a blurred background? I have this code:

@Composable
public fun CustomInformationDialog(
    onDismissRequest: () -> Unit, onConfirm: () -> Unit
) {
    Dialog(
        onDismissRequest = onDismissRequest, properties = DialogProperties(
            usePlatformDefaultWidth = false
        )
    ) {
        Box(
            modifier = Modifier.fillMaxSize(),
            contentAlignment = Alignment.BottomCenter

        ) {
            Card(
                modifier = Modifier.fillMaxWidth()
            ) {

            }
        }
    }
}

I am trying to add a blur effect with Cloudy() but I get this exception:

ClassCastException: androidx.compose.ui.platform.ComposeView cannot be cast to androidx.compose.ui.window.DialogWindowProvider

What should I change? Where should I put Cloudy() to blur the dialog background (only background)?

Thank you for your help.

DenysBohurskyi commented 7 months ago

I don't have this error, but I got no composables to be displayed inside dialog's content

skydoves commented 1 month ago

Hey guys, the new version 0.2.0 has been released, and now you can resolve this issue by using the Modifier.cloudy modifier instead of the Cloudy composable function.