manager: fix color (#154)
This commit is contained in:
@@ -586,18 +586,10 @@ private fun CategoryItem(
|
|||||||
category: AppCategory,
|
category: AppCategory,
|
||||||
isSelected: Boolean,
|
isSelected: Boolean,
|
||||||
appCount: Int,
|
appCount: Int,
|
||||||
onClick: () -> Unit
|
|
||||||
) {
|
) {
|
||||||
// 添加交互状态
|
// 添加交互状态
|
||||||
val interactionSource = remember { MutableInteractionSource() }
|
|
||||||
val isPressed by interactionSource.collectIsPressedAsState()
|
|
||||||
|
|
||||||
val animatedScale by animateFloatAsState(
|
val animatedScale by animateFloatAsState(
|
||||||
targetValue = when {
|
targetValue = 1.0f,
|
||||||
isPressed -> 0.96f
|
|
||||||
isSelected -> 1.02f
|
|
||||||
else -> 1.0f
|
|
||||||
},
|
|
||||||
animationSpec = spring(
|
animationSpec = spring(
|
||||||
dampingRatio = Spring.DampingRatioMediumBouncy,
|
dampingRatio = Spring.DampingRatioMediumBouncy,
|
||||||
stiffness = Spring.StiffnessHigh
|
stiffness = Spring.StiffnessHigh
|
||||||
@@ -608,21 +600,15 @@ private fun CategoryItem(
|
|||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.scale(animatedScale)
|
.scale(animatedScale),
|
||||||
.clickable(
|
|
||||||
interactionSource = interactionSource,
|
|
||||||
indication = null
|
|
||||||
) { onClick() },
|
|
||||||
colors = CardDefaults.cardColors(
|
colors = CardDefaults.cardColors(
|
||||||
containerColor = if (isSelected) {
|
containerColor = if (isSelected) {
|
||||||
MaterialTheme.colorScheme.primaryContainer
|
MaterialTheme.colorScheme.primary
|
||||||
} else {
|
} else {
|
||||||
MaterialTheme.colorScheme.surfaceVariant
|
MaterialTheme.colorScheme.surfaceBright
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
elevation = CardDefaults.cardElevation(
|
elevation = getCardElevation()
|
||||||
defaultElevation = if (isSelected) 6.dp else 2.dp
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -639,9 +625,9 @@ private fun CategoryItem(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val iconColor = if (isSelected) {
|
val iconColor = if (isSelected) {
|
||||||
MaterialTheme.colorScheme.onPrimaryContainer
|
MaterialTheme.colorScheme.onPrimary
|
||||||
} else {
|
} else {
|
||||||
MaterialTheme.colorScheme.onSurfaceVariant
|
MaterialTheme.colorScheme.onSurface
|
||||||
}
|
}
|
||||||
|
|
||||||
Icon(
|
Icon(
|
||||||
@@ -659,9 +645,9 @@ private fun CategoryItem(
|
|||||||
style = MaterialTheme.typography.labelSmall,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Normal,
|
fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Normal,
|
||||||
color = if (isSelected) {
|
color = if (isSelected) {
|
||||||
MaterialTheme.colorScheme.onPrimaryContainer
|
MaterialTheme.colorScheme.onPrimary
|
||||||
} else {
|
} else {
|
||||||
MaterialTheme.colorScheme.onSurfaceVariant
|
MaterialTheme.colorScheme.onSurface
|
||||||
},
|
},
|
||||||
textAlign = TextAlign.Center,
|
textAlign = TextAlign.Center,
|
||||||
maxLines = 2,
|
maxLines = 2,
|
||||||
@@ -673,9 +659,9 @@ private fun CategoryItem(
|
|||||||
text = appCount.toString(),
|
text = appCount.toString(),
|
||||||
style = MaterialTheme.typography.labelSmall,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
color = if (isSelected) {
|
color = if (isSelected) {
|
||||||
MaterialTheme.colorScheme.onPrimaryContainer.copy(alpha = 0.8f)
|
MaterialTheme.colorScheme.onPrimary.copy(alpha = 0.8f)
|
||||||
} else {
|
} else {
|
||||||
MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.8f)
|
MaterialTheme.colorScheme.onSurface.copy(alpha = 0.8f)
|
||||||
},
|
},
|
||||||
modifier = Modifier.padding(top = 1.dp),
|
modifier = Modifier.padding(top = 1.dp),
|
||||||
fontSize = 9.sp
|
fontSize = 9.sp
|
||||||
|
|||||||
Reference in New Issue
Block a user