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`
|
- Public `@Composable` functions require KDoc per `COMMENTS.md`
|
||||||
- `Modifier` parameter always last in composable signatures
|
- `Modifier` parameter always last in composable signatures
|
||||||
- Callback parameters use `on` prefix (`onDateClick`, `onMonthChanged`)
|
- 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,
|
onClick: () -> Unit,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
Box(
|
Card(
|
||||||
modifier = modifier
|
onClick = onClick,
|
||||||
.fillMaxWidth()
|
shape = RoundedCornerShape(8.dp),
|
||||||
.clickable(onClick = onClick)
|
colors = CardDefaults.cardColors(
|
||||||
.then(
|
containerColor = if (selected) MaterialTheme.colorScheme.primaryContainer
|
||||||
if (selected) Modifier.background(
|
else MaterialTheme.colorScheme.surfaceContainerHigh
|
||||||
MaterialTheme.colorScheme.primaryContainer,
|
),
|
||||||
RoundedCornerShape(8.dp)
|
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp),
|
||||||
) else Modifier
|
modifier = modifier.fillMaxWidth()
|
||||||
)
|
|
||||||
.padding(horizontal = 16.dp, vertical = 12.dp)
|
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = text,
|
text = text,
|
||||||
color = if (selected) MaterialTheme.colorScheme.onPrimaryContainer
|
color = if (selected) MaterialTheme.colorScheme.onPrimaryContainer
|
||||||
else MaterialTheme.colorScheme.onSurface,
|
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
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
Card(
|
Card(
|
||||||
|
onClick = onClick,
|
||||||
shape = RoundedCornerShape(16.dp),
|
shape = RoundedCornerShape(16.dp),
|
||||||
colors = CardDefaults.cardColors(
|
colors = CardDefaults.cardColors(
|
||||||
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh
|
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh
|
||||||
),
|
),
|
||||||
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp),
|
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp),
|
||||||
modifier = modifier
|
modifier = modifier.fillMaxWidth()
|
||||||
.fillMaxWidth()
|
|
||||||
.clickable(onClick = onClick)
|
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = title,
|
text = title,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user