fix: 漏加的限制
This commit is contained in:
parent
0f5532de8a
commit
4db78310f9
3 changed files with 15 additions and 10 deletions
|
|
@ -205,6 +205,15 @@ fun TodoEditorPage(
|
|||
value = uiState.categoryContent,
|
||||
onValueChange = { uiState.categoryContent = it },
|
||||
isError = uiState.isErrorCategory,
|
||||
supportingText = when {
|
||||
uiState.categoryContent.trim().isEmpty() ->
|
||||
stringResource(R.string.error_no_content_entered)
|
||||
|
||||
uiState.categoryContent.length > 5 ->
|
||||
stringResource(R.string.error_exceeds_5_chars)
|
||||
|
||||
else -> stringResource(R.string.tip_max_length_5)
|
||||
},
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
/*.sharedBounds(
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ fun TodoCategoryTextField(
|
|||
value: String,
|
||||
onValueChange: (String) -> Unit,
|
||||
isError: Boolean,
|
||||
supportingText: String = stringResource(R.string.tip_max_length_5),
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
TextField(
|
||||
|
|
@ -49,15 +50,8 @@ fun TodoCategoryTextField(
|
|||
onValueChange = onValueChange,
|
||||
label = { Text(stringResource(R.string.label_enter_category_name)) },
|
||||
isError = isError,
|
||||
supportingText = {
|
||||
AnimatedVisibility(
|
||||
visible = isError,
|
||||
enter = fadeIn() + expandVertically(),
|
||||
exit = fadeOut() + shrinkVertically()
|
||||
) {
|
||||
Text(stringResource(R.string.error_no_content_entered))
|
||||
}
|
||||
},
|
||||
supportingText = { Text(supportingText) },
|
||||
maxLines = 1,
|
||||
modifier = modifier
|
||||
)
|
||||
}
|
||||
|
|
@ -29,7 +29,9 @@ class EditorState(val initialTodo: TodoEntity? = null) {
|
|||
*/
|
||||
fun setErrorIfNotValid(): Boolean {
|
||||
isErrorContent = toDoContent.trim().isEmpty()
|
||||
isErrorCategory = if (selectedCategoryIndex == -1) categoryContent.trim().isEmpty() else false
|
||||
isErrorCategory = if (selectedCategoryIndex == -1) {
|
||||
categoryContent.trim().isEmpty() || categoryContent.trim().length > 5
|
||||
} else false
|
||||
return isErrorContent || isErrorCategory
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue