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

Button colors doesn't respect current theme #15

Closed
risalfajar opened this issue Jan 19, 2023 · 5 comments
Closed

Button colors doesn't respect current theme #15

risalfajar opened this issue Jan 19, 2023 · 5 comments

Comments

@risalfajar
Copy link

I tried to implement a simple confirmation dialog with CoreDialog, here's what I get:
image

Despite that the primary color is blue, the button that showed is purple, and there are no parameters I can pass to customize it.
I use Material2. Do you have any solution?

@maxkeppeler
Copy link
Owner

This library uses MD3. Mixing it with MD2 leads to issues with colors.
If more people request it, I might support MD2 as separate dependencies.

@risalfajar
Copy link
Author

Yes please. I've considered to use MD3 before, but sadly some components hasn't been supported yet.

@risalfajar
Copy link
Author

Workaround

You can add Material3 dependency and use it in your theme:

private val LightColorPalette = lightColors(
    primary = BrandBlue,
    primaryVariant = BrandBlue,
    secondary = BrandYellow,
    onPrimary = Color.White,
    onSecondary = Color.White,
    error = Red,
    onError = Color.White
)

@Composable
fun AppTheme(content: @Composable () -> Unit) {
    MaterialTheme(
        colors = LightColorPalette,
        typography = Typography,
        shapes = Shapes
    ) {
        androidx.compose.material3.MaterialTheme(
            colorScheme = androidx.compose.material3.MaterialTheme.colorScheme.copy(
                primary = LightColorPalette.primary,
                primaryContainer = LightColorPalette.primary,
                secondary = LightColorPalette.primary,
                secondaryContainer = LightColorPalette.primary,
                tertiary = LightColorPalette.secondary,
                tertiaryContainer = LightColorPalette.secondary,
                onPrimary = LightColorPalette.onPrimary,
                onSecondary = LightColorPalette.onPrimary,
                onTertiary = LightColorPalette.onSecondary,
                error = LightColorPalette.error,
                onError = LightColorPalette.onError,
                surface = LightColorPalette.surface,
                background = LightColorPalette.background
            ),
            androidx.compose.material3.MaterialTheme.shapes.copy(
                small = Shapes.small,
                medium = Shapes.medium,
                large = Shapes.large
            ),
            content = content
        )
    }
}

Theming Guide.
You can also use Material3 Theme Builder to generate M3 theme.

@gibranhit
Copy link

it's works, thanks

@thomasponzo-dev
Copy link

what color is used for what? primary = LightColorPalette.primary,
primaryContainer = LightColorPalette.primary,
secondary = LightColorPalette.primary,
secondaryContainer = LightColorPalette.primary,
tertiary = LightColorPalette.secondary,
tertiaryContainer = LightColorPalette.secondary,
onPrimary = LightColorPalette.onPrimary,
onSecondary = LightColorPalette.onPrimary,
onTertiary = LightColorPalette.onSecondary,
error = LightColorPalette.error,
onError = LightColorPalette.onError,
surface = LightColorPalette.surface,
background = LightColorPalette.background
I want to know for calendarview I need to change all the purple colors to a different one .

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

4 participants