manager: accessibility optimization (#131)

manager: style optimization
This commit is contained in:
米凛MiRin
2025-06-02 14:47:59 +08:00
committed by GitHub
parent 13b5290598
commit c210b00d54
5 changed files with 67 additions and 41 deletions

View File

@@ -354,7 +354,7 @@ private fun StatusCard(
} }
} }
.padding(24.dp), .padding(24.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.Top
) { ) {
when { when {
systemStatus.ksuVersion != null -> { systemStatus.ksuVersion != null -> {
@@ -366,8 +366,8 @@ private fun StatusCard(
val workingModeSurfaceText = when { val workingModeSurfaceText = when {
systemStatus.lkmMode == true -> "LKM" systemStatus.lkmMode == true -> "LKM"
systemStatus.lkmMode == null && systemStatus.kernelVersion.isGKI1() -> "GKI-1.0" systemStatus.lkmMode == null && systemStatus.kernelVersion.isGKI1() -> "GKI 1.0"
systemStatus.lkmMode == false || systemStatus.kernelVersion.isGKI() -> "GKI-2.0" systemStatus.lkmMode == false || systemStatus.kernelVersion.isGKI() -> "GKI 2.0"
else -> "N-GKI" else -> "N-GKI"
} }
@@ -375,7 +375,11 @@ private fun StatusCard(
Icons.Outlined.TaskAlt, Icons.Outlined.TaskAlt,
contentDescription = stringResource(R.string.home_working), contentDescription = stringResource(R.string.home_working),
tint = MaterialTheme.colorScheme.primary, tint = MaterialTheme.colorScheme.primary,
modifier = Modifier.size(24.dp) modifier = Modifier
.size(28.dp)
.padding(
horizontal = 4.dp
),
) )
Column(Modifier.padding(start = 20.dp)) { Column(Modifier.padding(start = 20.dp)) {
@@ -386,6 +390,7 @@ private fun StatusCard(
Text( Text(
text = workingModeText, text = workingModeText,
style = MaterialTheme.typography.titleMedium, style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.primary,
) )
Spacer(Modifier.width(8.dp)) Spacer(Modifier.width(8.dp))
@@ -399,7 +404,8 @@ private fun StatusCard(
Text( Text(
text = workingModeSurfaceText, text = workingModeSurfaceText,
style = MaterialTheme.typography.labelMedium, style = MaterialTheme.typography.labelMedium,
modifier = Modifier.padding(horizontal = 6.dp, vertical = 2.dp) modifier = Modifier.padding(horizontal = 6.dp, vertical = 2.dp),
color = MaterialTheme.colorScheme.onPrimary
) )
} }
@@ -418,7 +424,8 @@ private fun StatusCard(
modifier = Modifier.padding( modifier = Modifier.padding(
horizontal = 6.dp, horizontal = 6.dp,
vertical = 2.dp vertical = 2.dp
) ),
color = MaterialTheme.colorScheme.onPrimary
) )
} }
} }
@@ -438,6 +445,7 @@ private fun StatusCard(
Text( Text(
text = stringResource(R.string.home_working_version, systemStatus.ksuVersion), text = stringResource(R.string.home_working_version, systemStatus.ksuVersion),
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.secondary,
) )
} }
@@ -446,12 +454,14 @@ private fun StatusCard(
Text( Text(
text = stringResource(R.string.home_superuser_count, getSuperuserCount()), text = stringResource(R.string.home_superuser_count, getSuperuserCount()),
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.secondary,
) )
Spacer(Modifier.height(4.dp)) Spacer(Modifier.height(4.dp))
Text( Text(
text = stringResource(R.string.home_module_count, getModuleCount()), text = stringResource(R.string.home_module_count, getModuleCount()),
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.secondary,
) )
val kpmVersion = getKpmVersion() val kpmVersion = getKpmVersion()
@@ -460,6 +470,7 @@ private fun StatusCard(
Text( Text(
text = stringResource(R.string.home_kpm_module, getKpmModuleCount()), text = stringResource(R.string.home_kpm_module, getKpmModuleCount()),
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.secondary,
) )
} }
} }
@@ -471,19 +482,25 @@ private fun StatusCard(
Icons.Outlined.Warning, Icons.Outlined.Warning,
contentDescription = stringResource(R.string.home_not_installed), contentDescription = stringResource(R.string.home_not_installed),
tint = MaterialTheme.colorScheme.error, tint = MaterialTheme.colorScheme.error,
modifier = Modifier.size(24.dp) modifier = Modifier
.size(28.dp)
.padding(
horizontal = 4.dp
),
) )
Column(Modifier.padding(start = 20.dp)) { Column(Modifier.padding(start = 20.dp)) {
Text( Text(
text = stringResource(R.string.home_not_installed), text = stringResource(R.string.home_not_installed),
style = MaterialTheme.typography.titleMedium, style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.error
) )
Spacer(Modifier.height(4.dp)) Spacer(Modifier.height(4.dp))
Text( Text(
text = stringResource(R.string.home_click_to_install), text = stringResource(R.string.home_click_to_install),
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onErrorContainer
) )
} }
} }
@@ -493,19 +510,25 @@ private fun StatusCard(
Icons.Outlined.Block, Icons.Outlined.Block,
contentDescription = stringResource(R.string.home_unsupported), contentDescription = stringResource(R.string.home_unsupported),
tint = MaterialTheme.colorScheme.error, tint = MaterialTheme.colorScheme.error,
modifier = Modifier.size(24.dp) modifier = Modifier
.size(28.dp)
.padding(
horizontal = 4.dp
),
) )
Column(Modifier.padding(start = 20.dp)) { Column(Modifier.padding(start = 20.dp)) {
Text( Text(
text = stringResource(R.string.home_unsupported), text = stringResource(R.string.home_unsupported),
style = MaterialTheme.typography.titleMedium, style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.error
) )
Spacer(Modifier.height(4.dp)) Spacer(Modifier.height(4.dp))
Text( Text(
text = stringResource(R.string.home_unsupported_reason), text = stringResource(R.string.home_unsupported_reason),
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onErrorContainer
) )
} }
} }
@@ -667,7 +690,7 @@ private fun InfoCard(
icon: ImageVector = Icons.Default.Info icon: ImageVector = Icons.Default.Info
) { ) {
Row( Row(
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.Top,
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(vertical = 8.dp) .padding(vertical = 8.dp)
@@ -675,7 +698,9 @@ private fun InfoCard(
Icon( Icon(
imageVector = icon, imageVector = icon,
contentDescription = label, contentDescription = label,
modifier = Modifier.size(24.dp), modifier = Modifier
.size(28.dp)
.padding(vertical = 4.dp),
tint = MaterialTheme.colorScheme.primary, tint = MaterialTheme.colorScheme.primary,
) )
Spacer(modifier = Modifier.width(16.dp)) Spacer(modifier = Modifier.width(16.dp))

View File

@@ -88,6 +88,7 @@ import com.sukisu.ultra.ui.theme.getCardElevation
import androidx.compose.material3.RadioButton import androidx.compose.material3.RadioButton
import androidx.compose.material3.TextButton import androidx.compose.material3.TextButton
import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.unit.sp
/** /**
* @author ShirkNeko * @author ShirkNeko
@@ -1245,10 +1246,10 @@ fun SettingItem(
Row( Row(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.height(if (subtitle != null) SETTINGS_ITEM_HEIGHT + 12.dp else SETTINGS_ITEM_HEIGHT) // .height(if (subtitle != null) SETTINGS_ITEM_HEIGHT + 12.dp else SETTINGS_ITEM_HEIGHT)
.clickable(onClick = onClick) .clickable(onClick = onClick)
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp, vertical = 5.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.Top
) { ) {
Icon( Icon(
imageVector = icon, imageVector = icon,
@@ -1296,10 +1297,10 @@ fun SwitchSettingItem(
Row( Row(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.height(if (summary != null) SETTINGS_ITEM_HEIGHT + 12.dp else SETTINGS_ITEM_HEIGHT) // .height(if (summary != null) SETTINGS_ITEM_HEIGHT + 12.dp else SETTINGS_ITEM_HEIGHT)
.clickable { onChange(!checked) } .clickable { onChange(!checked) }
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp, vertical = 10.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.Top
) { ) {
Icon( Icon(
imageVector = icon, imageVector = icon,
@@ -1317,8 +1318,9 @@ fun SwitchSettingItem(
Text( Text(
text = title, text = title,
style = MaterialTheme.typography.titleMedium, style = MaterialTheme.typography.titleMedium,
maxLines = 1, lineHeight = 20.sp,
overflow = TextOverflow.Ellipsis // maxLines = 1,
// overflow = TextOverflow.Ellipsis
) )
if (summary != null) { if (summary != null) {
Spacer(modifier = Modifier.height(2.dp)) Spacer(modifier = Modifier.height(2.dp))
@@ -1326,8 +1328,9 @@ fun SwitchSettingItem(
text = summary, text = summary,
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant, color = MaterialTheme.colorScheme.onSurfaceVariant,
maxLines = 2, lineHeight = 16.sp,
overflow = TextOverflow.Ellipsis // maxLines = 2,
// overflow = TextOverflow.Ellipsis
) )
} }
} }

View File

@@ -85,6 +85,7 @@ fun SettingScreen(navigator: DestinationsNavigator) {
} }
Scaffold( Scaffold(
// containerColor = MaterialTheme.colorScheme.surfaceBright,
topBar = { topBar = {
TopBar(scrollBehavior = scrollBehavior) TopBar(scrollBehavior = scrollBehavior)
}, },
@@ -351,7 +352,7 @@ private fun SettingsGroupCard(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = SPACING_LARGE, vertical = SPACING_MEDIUM), .padding(horizontal = SPACING_LARGE, vertical = SPACING_MEDIUM),
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainerHigh), colors = getCardColors(MaterialTheme.colorScheme.surfaceContainerLow),
elevation = getCardElevation() elevation = getCardElevation()
) { ) {
Column( Column(
@@ -360,7 +361,8 @@ private fun SettingsGroupCard(
Text( Text(
text = title, text = title,
style = MaterialTheme.typography.titleMedium, style = MaterialTheme.typography.titleMedium,
modifier = Modifier.padding(horizontal = SPACING_LARGE, vertical = SPACING_MEDIUM) modifier = Modifier.padding(horizontal = SPACING_LARGE, vertical = SPACING_MEDIUM),
color = MaterialTheme.colorScheme.primary
) )
content() content()
} }
@@ -502,7 +504,7 @@ fun SettingItem(
.fillMaxWidth() .fillMaxWidth()
.clickable(onClick = onClick) .clickable(onClick = onClick)
.padding(horizontal = SPACING_LARGE, vertical = 12.dp), .padding(horizontal = SPACING_LARGE, vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.Top
) { ) {
Icon( Icon(
imageVector = icon, imageVector = icon,
@@ -548,7 +550,7 @@ fun SwitchItem(
.fillMaxWidth() .fillMaxWidth()
.clickable { onCheckedChange(!checked) } .clickable { onCheckedChange(!checked) }
.padding(horizontal = SPACING_LARGE, vertical = 12.dp), .padding(horizontal = SPACING_LARGE, vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.Top
) { ) {
Icon( Icon(
imageVector = icon, imageVector = icon,
@@ -797,4 +799,4 @@ private fun TopBar(
windowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal), windowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
scrollBehavior = scrollBehavior scrollBehavior = scrollBehavior
) )
} }

View File

@@ -18,7 +18,7 @@ object CardConfig {
// 卡片亮度 // 卡片亮度
var cardDim by mutableFloatStateOf(0f) var cardDim by mutableFloatStateOf(0f)
// 卡片阴影 // 卡片阴影
var cardElevation by mutableStateOf(4.dp) var cardElevation by mutableStateOf(0.dp)
var isShadowEnabled by mutableStateOf(true) var isShadowEnabled by mutableStateOf(true)
var isCustomAlphaSet by mutableStateOf(false) var isCustomAlphaSet by mutableStateOf(false)
var isCustomDimSet by mutableStateOf(false) var isCustomDimSet by mutableStateOf(false)
@@ -65,13 +65,7 @@ object CardConfig {
*/ */
fun updateShadowEnabled(enabled: Boolean) { fun updateShadowEnabled(enabled: Boolean) {
isShadowEnabled = enabled isShadowEnabled = enabled
cardElevation = if (isCustomBackgroundEnabled) { cardElevation = 0.dp
0.dp
} else if (enabled) {
4.dp
} else {
0.dp
}
} }
/** /**
@@ -103,11 +97,11 @@ fun getCardColors(originalColor: Color) = CardDefaults.cardColors(
@Composable @Composable
fun getCardElevation() = CardDefaults.cardElevation( fun getCardElevation() = CardDefaults.cardElevation(
defaultElevation = CardConfig.cardElevation, defaultElevation = CardConfig.cardElevation,
pressedElevation = if (CardConfig.isCustomBackgroundEnabled) 0.dp else 8.dp, pressedElevation = CardConfig.cardElevation,
focusedElevation = if (CardConfig.isCustomBackgroundEnabled) 0.dp else 6.dp, focusedElevation = CardConfig.cardElevation,
hoveredElevation = if (CardConfig.isCustomBackgroundEnabled) 0.dp else 4.dp, hoveredElevation = CardConfig.cardElevation,
draggedElevation = if (CardConfig.isCustomBackgroundEnabled) 0.dp else 8.dp, draggedElevation = CardConfig.cardElevation,
disabledElevation = 0.dp disabledElevation = CardConfig.cardElevation
) )
/** /**

View File

@@ -294,8 +294,8 @@ private fun createDynamicDarkColorScheme(context: Context): ColorScheme {
return scheme.copy( return scheme.copy(
background = if (CardConfig.isCustomBackgroundEnabled) Color.Transparent else scheme.background, background = if (CardConfig.isCustomBackgroundEnabled) Color.Transparent else scheme.background,
surface = if (CardConfig.isCustomBackgroundEnabled) Color.Transparent else scheme.surface, surface = if (CardConfig.isCustomBackgroundEnabled) Color.Transparent else scheme.surface,
onBackground = Color.White, onBackground = scheme.onBackground,
onSurface = Color.White onSurface = scheme.onSurface
) )
} }
@@ -308,7 +308,9 @@ private fun createDynamicLightColorScheme(context: Context): ColorScheme {
val scheme = dynamicLightColorScheme(context) val scheme = dynamicLightColorScheme(context)
return scheme.copy( return scheme.copy(
background = if (CardConfig.isCustomBackgroundEnabled) Color.Transparent else scheme.background, background = if (CardConfig.isCustomBackgroundEnabled) Color.Transparent else scheme.background,
surface = if (CardConfig.isCustomBackgroundEnabled) Color.Transparent else scheme.surface surface = if (CardConfig.isCustomBackgroundEnabled) Color.Transparent else scheme.surface,
onBackground = scheme.onBackground,
onSurface = scheme.onSurface
) )
} }