Hi all, this question is related to material3 specifically.. (pressed enter by accident, still editi...
a
Hi all, this question is related to material3 specifically.. (pressed enter by accident, still editing) We've implemented a material3 ModalBottomSheet and are passing in the container colour via the theme, like so
Copy code
ModalBottomSheet(
        onDismissRequest = onDismissRequest,
        modifier = modifier,
        sheetState = sheetState,
        shape = RoundedCornerShape(topStart = DP_8, topEnd = DP_8),
        containerColor = MaterialTheme.colorScheme.surface,
        dragHandle = dragHandle,
        content = {
            content()
            Spacer(modifier = Modifier.navigationBarsPadding())
        }
    )
nothing weird, right? but the
surface
colour doesnt seem to be applying, even though elsewhere on that screen
surface
is applied correctly on another Composable furthermore, hardcoding containerColour to another colour actually makes it apply, and we are having a very similar issue in a dialog
Copy code
fun CustomDialog() {
    Dialog {
        Surface(
            color = MaterialTheme.colorScheme.surface // colour does not apply, unless it is changed to be hardcoded
        )
    }
c
And you are sure, the sheet and the dialog are children of the
MaterialTheme
composable!?
a
certainly!
theyre called from the same context as every other composable
i think we found the reason for this, which is elevation darkening the surface
👍 1
d
Easiest way to test would be changing your ColorScheme's
.surface
colour to
Color.Black
and trying again
a
@dorche this has been addressed above but mentioned in post that i had tried this
d
Not really - you're saying that hardcoding the colour on the Sheet works, I am saying change your Theme's colour and then try it again
a
good point, this would definitely have gotten us closer to understanding the issue