Improve profile picker background

This commit is contained in:
世界
2025-12-16 15:50:24 +08:00
parent 9db8dfa1cf
commit be175ccd73
2 changed files with 16 additions and 22 deletions

View File

@@ -43,6 +43,7 @@ import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
@@ -283,7 +284,11 @@ private fun ProfilePickerRow(
shape = RoundedCornerShape(8.dp), shape = RoundedCornerShape(8.dp),
color = when { color = when {
isDragging -> MaterialTheme.colorScheme.tertiaryContainer isDragging -> MaterialTheme.colorScheme.tertiaryContainer
isSelected -> MaterialTheme.colorScheme.primaryContainer isSelected -> if (isSystemInDarkTheme()) {
MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f)
} else {
MaterialTheme.colorScheme.surfaceDim
}
else -> MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.3f) else -> MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.3f)
}, },
tonalElevation = animatedElevation.dp, tonalElevation = animatedElevation.dp,
@@ -302,11 +307,7 @@ private fun ProfilePickerRow(
imageVector = profileIcon, imageVector = profileIcon,
contentDescription = null, contentDescription = null,
modifier = Modifier.size(24.dp), modifier = Modifier.size(24.dp),
tint = if (isSelected) { tint = MaterialTheme.colorScheme.onSurfaceVariant,
MaterialTheme.colorScheme.primary
} else {
MaterialTheme.colorScheme.onSurfaceVariant
},
) )
Spacer(modifier = Modifier.width(12.dp)) Spacer(modifier = Modifier.width(12.dp))
@@ -319,11 +320,7 @@ private fun ProfilePickerRow(
text = profile.name, text = profile.name,
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
fontWeight = if (isSelected) FontWeight.SemiBold else FontWeight.Medium, fontWeight = if (isSelected) FontWeight.SemiBold else FontWeight.Medium,
color = if (isSelected) { color = MaterialTheme.colorScheme.onSurfaceVariant,
MaterialTheme.colorScheme.onPrimaryContainer
} else {
MaterialTheme.colorScheme.onSurfaceVariant
},
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
) )
@@ -337,11 +334,7 @@ private fun ProfilePickerRow(
) )
}, },
style = MaterialTheme.typography.labelSmall, style = MaterialTheme.typography.labelSmall,
color = if (isSelected) { color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.6f),
MaterialTheme.colorScheme.onPrimaryContainer.copy(alpha = 0.7f)
} else {
MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.6f)
},
) )
} }
@@ -371,11 +364,7 @@ private fun ProfilePickerRow(
imageVector = Icons.Default.MoreVert, imageVector = Icons.Default.MoreVert,
contentDescription = stringResource(R.string.more_options), contentDescription = stringResource(R.string.more_options),
modifier = Modifier.size(20.dp), modifier = Modifier.size(20.dp),
tint = if (isSelected) { tint = MaterialTheme.colorScheme.onSurfaceVariant,
MaterialTheme.colorScheme.onPrimaryContainer
} else {
MaterialTheme.colorScheme.onSurfaceVariant
},
) )
} }

View File

@@ -16,6 +16,7 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@@ -37,7 +38,11 @@ fun ProfileSelectorButton(
onClick = onClick, onClick = onClick,
modifier = modifier.fillMaxWidth().height(48.dp), modifier = modifier.fillMaxWidth().height(48.dp),
shape = RoundedCornerShape(12.dp), shape = RoundedCornerShape(12.dp),
color = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f), color = if (isSystemInDarkTheme()) {
MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f)
} else {
MaterialTheme.colorScheme.surfaceDim
},
) { ) {
Row( Row(
modifier = Modifier modifier = Modifier