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

Allow OptionSheet icons to be in colour #56

Closed
russellbanks opened this issue May 15, 2023 · 6 comments
Closed

Allow OptionSheet icons to be in colour #56

russellbanks opened this issue May 15, 2023 · 6 comments
Assignees

Comments

@russellbanks
Copy link

russellbanks commented May 15, 2023

Same as maxkeppeler/sheets#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
Copy link
Owner

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?

@maxkeppeler maxkeppeler self-assigned this May 21, 2023
@russellbanks
Copy link
Author

russellbanks commented May 21, 2023

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
Copy link
Owner

maxkeppeler commented May 21, 2023

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
Copy link
Author

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
Copy link
Owner

My example was with the header.

   header = Header.Default(
            "Select time",
            icon = IconSource(
                R.drawable.ic_fruit_apple,
                tint = Color.Unspecified
            )
        ),

@maxkeppeler
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants