mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-10 00:27:45 +00:00
use isError and trainingIcon to indicate invalid name for color
This commit is contained in:
parent
5ba40f7875
commit
6b86ea236b
2 changed files with 12 additions and 22 deletions
|
@ -16,7 +16,6 @@ import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.width
|
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.LocalContentColor
|
import androidx.compose.material3.LocalContentColor
|
||||||
|
@ -128,27 +127,18 @@ fun ColorsScreen(
|
||||||
title = {
|
title = {
|
||||||
var nameValid by rememberSaveable { mutableStateOf(true) }
|
var nameValid by rememberSaveable { mutableStateOf(true) }
|
||||||
var nameField by rememberSaveable(stateSaver = TextFieldValue.Saver) { mutableStateOf(newThemeName) }
|
var nameField by rememberSaveable(stateSaver = TextFieldValue.Saver) { mutableStateOf(newThemeName) }
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
TextField(
|
||||||
TextField(
|
value = nameField,
|
||||||
value = nameField,
|
onValueChange = {
|
||||||
onValueChange = {
|
nameValid = KeyboardTheme.renameUserColors(newThemeName.text, it.text, prefs)
|
||||||
nameValid = KeyboardTheme.renameUserColors(newThemeName.text, it.text, prefs)
|
if (nameValid)
|
||||||
if (nameValid)
|
newThemeName = it
|
||||||
newThemeName = it
|
nameField = it
|
||||||
nameField = it
|
},
|
||||||
},
|
isError = !nameValid,
|
||||||
modifier = Modifier.weight(1f)
|
// supportingText = { if (!nameValid) Text("name already in use") } // this is cutting off bottom half of the actual text...
|
||||||
)
|
trailingIcon = { if (!nameValid) Icon(painterResource(R.drawable.ic_close), null) }
|
||||||
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.secondary) {
|
)
|
||||||
// todo: this should indicate whether name is saved, but looks like a button
|
|
||||||
// either make it flash and then disappear, or use a better indicator
|
|
||||||
Icon(
|
|
||||||
painterResource(if (nameValid) R.drawable.ic_setup_check else R.drawable.ic_close),
|
|
||||||
null,
|
|
||||||
Modifier.width(24.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
menu = listOf(
|
menu = listOf(
|
||||||
stringResource(R.string.main_colors) to { KeyboardTheme.writeUserMoreColors(prefs, newThemeName.text, 0) },
|
stringResource(R.string.main_colors) to { KeyboardTheme.writeUserMoreColors(prefs, newThemeName.text, 0) },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue