Skip to content

Comments

refactor(ui): Optimize card component style and color management#1381

Open
matsuzaka-yuki wants to merge 1 commit intobmax121:mainfrom
matsuzaka-yuki:main
Open

refactor(ui): Optimize card component style and color management#1381
matsuzaka-yuki wants to merge 1 commit intobmax121:mainfrom
matsuzaka-yuki:main

Conversation

@matsuzaka-yuki
Copy link
Contributor

  • Replace ElevatedCard with Card component to unify card styling
  • Dynamically set card background color and content color based on state to improve readability
  • Use surfaceColorAtElevation to enhance depth and color expression
  • Standardize card corner radius to 20dp to improve visual consistency

- Replace ElevatedCard with Card component to unify card styling
- Dynamically set card background color and content color based on state to improve readability
- Use surfaceColorAtElevation to enhance depth and color expression
- Standardize card corner radius to 20dp to improve visual consistency

else -> {
MaterialTheme.colorScheme.secondaryContainer
MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp) to MaterialTheme.colorScheme.onSurface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you want to do
I think you should read Android's UI design documents first Click There

You can see from this document, card colors use surfaceContainer,
we already have surface surfaceContainerLowest surfaceContainerLow surfaceContainer surfaceContainerHigh surfaceContainerHighest 6 elevation colors in theme, why manually calc that?

I think manually calc elevation colors is unnecessary, and will cause more rendering time, because you are do math calc internally rather than directly using data calculated at application startup!

}

ElevatedCard(
Card(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want to notice to you, you no need to switch to Card, because ElevatedCard basically is an alias of Card itself

@Composable
fun ElevatedCard(
    modifier: Modifier = Modifier,
    shape: Shape = CardDefaults.elevatedShape,
    colors: CardColors = CardDefaults.elevatedCardColors(),
    elevation: CardElevation = CardDefaults.elevatedCardElevation(),
    content: @Composable ColumnScope.() -> Unit,
) =
    Card(
        modifier = modifier,
        shape = shape,
        border = null,
        elevation = elevation,
        colors = colors,
        content = content,
    )

This is a code snippet of material3-android library, as you can see, ElevatedCard is an card without border, that is all
You no need change that if you just want change contentColor, and btw, you lost elevation set

And if you want unify, you should package your own Card control, NOT CHANGE EVERYWHERE TO WASTE, THAT IS A NIGHTMARE

@Admirepowered Admirepowered added the need_modify Need to merge after modifying the code label Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

need_modify Need to merge after modifying the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants