maxkeppeler / sheets-compose-dialogs

✨ Enhancing Android UIs: A Jetpack Compose Library supporting a wide range of common use-cases with Material Design 3 Dialogs, Popups, and Bottom Sheets. ✨
https://maxkeppeler.github.io/sheets-compose-dialogs/
Apache License 2.0
807 stars 38 forks source link

Allow OptionSheet icons to be in colour #56

Closed russellbanks closed 1 year ago

russellbanks commented 1 year ago

Same as https://github.com/maxkeppeler/sheets/issues/83 but for Compose dialogs.

There should be an option to keep the icon as is without any tinting at all.

studio64_BVb8pByJ1s

I want the user to be able to choose an image but it looks like that rather than retaining all its colours.

maxkeppeler commented 1 year ago

Did you try to add a tint of color, "Color.Unspecified" which according to the Icon component would not apply a tint to the icon?

russellbanks commented 1 year ago

Did you try to add a tint of color, "Color.Unspecified" which according to the Icon component would not apply a tint to the icon?

Color.Unspecified doesn't change anything here - it's still tinted:

studio64_pnbgruqCRs

maxkeppeler commented 1 year ago

Hmm I just checked and this seems to work:


 icon = IconSource(
                R.drawable.ic_fruit_apple,
                tint = Color.Unspecified
            )

It's gray by default and the color is kept. When I use Color.RED, it's red. If I remove tint / keep it null, it uses the secondary color.

I guess you are not using a DrawableRes? Maybe it doesn't work for each type atm.

russellbanks commented 1 year ago

I was doing it as a painterResource before, but it's still like that even with drawableRes:

if (imageSheetVisible) {
    ModalBottomSheet(
        onDismissRequest = { imageSheetVisible = false },
        sheetState = imageSheetState
    ) {
        OptionView(
            useCaseState = rememberUseCaseState(),
            selection = OptionSelection.Single(
                options = listOf(
                    Option(
                        icon = IconSource(
                            drawableRes = R.drawable.image_anahata,
                            tint = Color.Unspecified
                        ),
                        titleText = "",
                    )
                ),
                onSelectOption = { index, option ->
                }
            ),
            config = OptionConfig(
                mode = DisplayMode.GRID_VERTICAL,
            )
        )
    }
}
maxkeppeler commented 1 year ago

My example was with the header.

   header = Header.Default(
            "Select time",
            icon = IconSource(
                R.drawable.ic_fruit_apple,
                tint = Color.Unspecified
            )
        ),
maxkeppeler commented 1 year ago

For the OptionView it makes sense if it doesn't work as it enforces currently the icon color.

val iconColor = if (option.selected) MaterialTheme.colorScheme.primary
    else MaterialTheme.colorScheme.onSurface