refactor: MenuItem 和 ToolItem 统一使用 Card(onClick)
This commit is contained in:
parent
6446d6636e
commit
a8717dec7d
@ -77,3 +77,4 @@ CalendarMonthView ← top-level screen (MonthHeader + WeekdayHeader + p
|
||||
- Public `@Composable` functions require KDoc per `COMMENTS.md`
|
||||
- `Modifier` parameter always last in composable signatures
|
||||
- Callback parameters use `on` prefix (`onDateClick`, `onMonthChanged`)
|
||||
- **Clickable list items:** Use `Card(onClick = ...)` with `CardDefaults.cardElevation(defaultElevation = 0.dp)` instead of `Modifier.clickable()` on `Box`/`Row`. This ensures consistent Material 3 press-state feedback (ripple + background color change) across all interactive list/menu items. See `LicensesScreen`, `ToolsScreen`, and `CalendarMonthView.MenuItem` for reference.
|
||||
|
||||
@ -633,23 +633,22 @@ private fun MenuItem(
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Box(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(onClick = onClick)
|
||||
.then(
|
||||
if (selected) Modifier.background(
|
||||
MaterialTheme.colorScheme.primaryContainer,
|
||||
RoundedCornerShape(8.dp)
|
||||
) else Modifier
|
||||
)
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp)
|
||||
Card(
|
||||
onClick = onClick,
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = if (selected) MaterialTheme.colorScheme.primaryContainer
|
||||
else MaterialTheme.colorScheme.surfaceContainerHigh
|
||||
),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp),
|
||||
modifier = modifier.fillMaxWidth()
|
||||
) {
|
||||
Text(
|
||||
text = text,
|
||||
color = if (selected) MaterialTheme.colorScheme.onPrimaryContainer
|
||||
else MaterialTheme.colorScheme.onSurface,
|
||||
style = MaterialTheme.typography.bodyLarge
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,14 +93,13 @@ private fun ToolItem(
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Card(
|
||||
onClick = onClick,
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh
|
||||
),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp),
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(onClick = onClick)
|
||||
modifier = modifier.fillMaxWidth()
|
||||
) {
|
||||
Text(
|
||||
text = title,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user