Steffen Funke

    Steffen Funke

    10 months ago
    Is there a way to make
    Surface
    to not set any
    contentColor
    , e.g. make it behave like a
    Box
    in this regard? I have custom colored content (Texts, Sliders, etc….), but as soon as I wrap them into a
    ModalBottomSheetLayout
    - which is backed by a
    Surface
    - everything gets tinted with the
    contentColor
    . I surely miss something here. 🤔
    Surface initializer:
    @Composable
    fun Surface(
        modifier: Modifier = Modifier,
        shape: Shape = RectangleShape,
        color: Color = MaterialTheme.colors.surface,
        contentColor: Color = contentColorFor(color),
        border: BorderStroke? = null,
        elevation: Dp = 0.dp,
        content: @Composable () -> Unit
    ) {
        Surface(
            modifier = modifier,
            shape = shape,
            color = color,
            contentColor = contentColor,
            border = border,
            elevation = elevation,
            content = content,
            clickAndSemanticsModifier = Modifier
                .semantics(mergeDescendants = false) {}
                .pointerInput(Unit) { }
        )
    }
    Ideally, I would like to set
    contentColor
    to null to have the widgets shown their color. But I guess that is not how it is supposed to work.
    l

    Luke

    10 months ago
    Maybe using
    contentColor = Color.Transparent
    would help?
    Or
    Color.Unspecified
    Steffen Funke

    Steffen Funke

    10 months ago
    @Luke Interesting, thanks. Indeed that removes the tinting. The alpha however is still a bit off 😩 I am wondering if that has any implications, setting a transparent / unspecified color?
    Ok, resetting the Sheet
    color
    (which actually is its
    backgroundColor
    ) fixes the alpha of the foreground now. Interesting. Thanks for pointing me in the direction @Luke !