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

AlertDialog is missing scrim #2580

Closed
sproctor opened this issue Dec 28, 2022 · 10 comments · Fixed by JetBrains/compose-multiplatform-core#358
Closed

AlertDialog is missing scrim #2580

sproctor opened this issue Dec 28, 2022 · 10 comments · Fixed by JetBrains/compose-multiplatform-core#358
Assignees
Labels
desktop enhancement New feature or request

Comments

@sproctor
Copy link

The Box at https://github.com/JetBrains/androidx/blob/jb-main/compose/material/material/src/desktopMain/kotlin/androidx/compose/material/DesktopAlertDialog.desktop.kt#L221 should have a black background with 32% opacity, or a default with some option to specify in the theme or component.

@dima-avdeev-jb dima-avdeev-jb self-assigned this Dec 28, 2022
@dima-avdeev-jb dima-avdeev-jb added question Not a bug, but question or comment desktop labels Dec 28, 2022
@dima-avdeev-jb
Copy link
Contributor

You can configure an Alert background with MaterialTheme, surface:

MaterialTheme(
    colors = MaterialTheme.colors.copy(surface = Color.Green)
) {
    AlertDialog(
        onDismissRequest = {},
        confirmButton = {},
        text = {
            Text("Alert")
        }
    )
}

Or directly with argument backgroundColor

AlertDialog(
    backgroundColor = ...
    ...
)

@sproctor
Copy link
Author

I only opened this because it's the default on Android and it's a bit surprising to have a different behavior on desktop.

@dima-avdeev-jb
Copy link
Contributor

dima-avdeev-jb commented Dec 28, 2022

@sproctor
You may try to use dark or light theme settings.

MaterialTheme(
    colors = darkColors()
) {
    AlertDialog(
    ...
    )
}   
MaterialTheme(
    colors = lightColors()
) {
    AlertDialog(
    ...
    )
}   

Or default MaterialTheme will use your system dark/light settings.

The result will be the same as surface color in Android.

@sproctor
Copy link
Author

I think we're talking about different things. I think you're talking about the background of the dialog itself. I'm talking about the scrim behind the dialog. In this diagram: https://m3.material.io/components/dialogs/specs#67ce2705-d8c0-4ede-9f3e-06b636d6801d it's # 7. The scrim doesn't exist on desktop. I realize that this a link to a different version of material, but I had it handy, and regarding the scrim m2 and m3 seem identical.

@dima-avdeev-jb
Copy link
Contributor

Thanks! I will try to fix it.

@dima-avdeev-jb dima-avdeev-jb added enhancement New feature or request and removed question Not a bug, but question or comment labels Dec 28, 2022
@kirill-grouchnikov
Copy link

Is there an expectation that showing a dialog on desktop casts a scrim over the rest of the app window?

@sproctor
Copy link
Author

In general, I don't know. For a dialog following the material spec, yes.The m3 spec is very specific about this point: "Desktop dialogs are modal windows above a scrim". m2 doesn't specifically mention desktop: "To express that the rest of the app is inaccessible, and to focus attention on the dialog, surfaces behind the dialog are scrimmed. A scrim is a temporary treatment that can be applied to Material surfaces for the purpose of making content on the surface less prominent."

@dima-avdeev-jb
Copy link
Contributor

@sproctor
Where do you get opacity value 32% ?

dima-avdeev-jb added a commit to JetBrains/compose-multiplatform-core that referenced this issue Jan 1, 2023
JetBrains/compose-multiplatform#2580
Also, add temporary PopupDialog. In the future it should be changed to LayerDialog.(JetBrains/compose-multiplatform#933)
@sproctor
Copy link
Author

sproctor commented Jan 2, 2023

I thought I'd seen it in the in the m3 docs, but I can't find it now, so maybe not. It's given as the value for the crane theme in m2: https://m2.material.io/components/dialogs#theming

And it's the value used in the design tokens in m3: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/tokens/ScrimTokens.kt

dima-avdeev-jb added a commit to JetBrains/compose-multiplatform-core that referenced this issue Jan 5, 2023
JetBrains/compose-multiplatform#2580
Also, add temporary PopupDialog. In the future, it should be changed to LayerDialog.(JetBrains/compose-multiplatform#933)
eymar pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue Jan 13, 2023
JetBrains/compose-multiplatform#2580
Also, add temporary PopupDialog. In the future, it should be changed to LayerDialog.(JetBrains/compose-multiplatform#933)
MatkovIvan pushed a commit to MatkovIvan/compose-multiplatform that referenced this issue May 10, 2023
JetBrains#2580
Also, add temporary PopupDialog. In the future, it should be changed to LayerDialog.(JetBrains#933)
@okushnikov
Copy link
Collaborator

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

@JetBrains JetBrains locked and limited conversation to collaborators Dec 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
desktop enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants