manager: fix the color of TextField in TemplateEditor

This commit is contained in:
YuKongA
2025-11-27 20:34:43 +08:00
committed by shirkneko
parent a98a718d61
commit 809b74a5f3
2 changed files with 30 additions and 36 deletions

View File

@@ -334,7 +334,6 @@ private fun SELinuxPanel(
.fillMaxWidth() .fillMaxWidth()
.padding(vertical = 8.dp), .padding(vertical = 8.dp),
label = stringResource(id = R.string.profile_selinux_domain), label = stringResource(id = R.string.profile_selinux_domain),
backgroundColor = colorScheme.surfaceContainer,
borderColor = if (isDomainValid) { borderColor = if (isDomainValid) {
colorScheme.primary colorScheme.primary
} else { } else {
@@ -353,7 +352,6 @@ private fun SELinuxPanel(
.fillMaxWidth() .fillMaxWidth()
.padding(vertical = 8.dp), .padding(vertical = 8.dp),
label = stringResource(id = R.string.profile_selinux_rules), label = stringResource(id = R.string.profile_selinux_rules),
backgroundColor = colorScheme.surfaceContainer,
borderColor = if (isRulesValid) { borderColor = if (isRulesValid) {
colorScheme.primary colorScheme.primary
} else { } else {

View File

@@ -111,6 +111,7 @@ fun TemplateEditorScreen(
stringResource(R.string.app_profile_template_edit) stringResource(R.string.app_profile_template_edit)
}, },
readOnly = readOnly, readOnly = readOnly,
isCreation = isCreation,
onBack = dropUnlessResumed { navigator.navigateBack(result = !readOnly) }, onBack = dropUnlessResumed { navigator.navigateBack(result = !readOnly) },
onDelete = { onDelete = {
if (deleteAppProfileTemplate(template.id)) { if (deleteAppProfileTemplate(template.id)) {
@@ -165,9 +166,7 @@ fun TemplateEditorScreen(
.fillMaxWidth() .fillMaxWidth()
.padding(12.dp), .padding(12.dp),
) { ) {
var errorHint by remember { var errorHint by rememberSaveable { mutableStateOf(false) }
mutableStateOf(false)
}
TextEdit( TextEdit(
label = stringResource(id = R.string.app_profile_template_name), label = stringResource(id = R.string.app_profile_template_name),
@@ -189,15 +188,7 @@ fun TemplateEditorScreen(
text = template.id, text = template.id,
isError = errorHint isError = errorHint
) { value -> ) { value ->
errorHint = if (value.isEmpty()) { errorHint = value.isNotEmpty() && (isTemplateExist(value) || !isValidTemplateId(value))
false
} else if (isTemplateExist(value)) {
true
} else if (!isValidTemplateId(value)) {
true
} else {
false
}
template = template.copy(id = value) template = template.copy(id = value)
} }
TextEdit( TextEdit(
@@ -311,6 +302,7 @@ fun saveTemplate(template: TemplateViewModel.TemplateInfo, isCreation: Boolean =
private fun TopBar( private fun TopBar(
title: String, title: String,
readOnly: Boolean, readOnly: Boolean,
isCreation: Boolean,
onBack: () -> Unit, onBack: () -> Unit,
onDelete: () -> Unit = {}, onDelete: () -> Unit = {},
onSave: () -> Unit = {}, onSave: () -> Unit = {},
@@ -339,28 +331,32 @@ private fun TopBar(
} }
}, },
actions = { actions = {
if (readOnly) { when {
return@TopAppBar !readOnly && !isCreation -> {
} IconButton(
IconButton( modifier = Modifier.padding(end = 16.dp),
modifier = Modifier.padding(end = 16.dp), onClick = onDelete
onClick = onDelete ) {
) { Icon(
Icon( imageVector = MiuixIcons.Useful.Delete,
imageVector = MiuixIcons.Useful.Delete, contentDescription = stringResource(id = R.string.app_profile_template_delete),
contentDescription = stringResource(id = R.string.app_profile_template_delete), tint = colorScheme.onBackground
tint = colorScheme.onBackground )
) }
} }
IconButton(
modifier = Modifier.padding(end = 16.dp), isCreation -> {
onClick = onSave IconButton(
) { modifier = Modifier.padding(end = 16.dp),
Icon( onClick = onSave
imageVector = MiuixIcons.Useful.Confirm, ) {
contentDescription = stringResource(id = R.string.app_profile_template_save), Icon(
tint = colorScheme.onBackground imageVector = MiuixIcons.Useful.Confirm,
) contentDescription = stringResource(id = R.string.app_profile_template_save),
tint = colorScheme.onBackground
)
}
}
} }
}, },
scrollBehavior = scrollBehavior scrollBehavior = scrollBehavior