fixed no error bug
This commit is contained in:
parent
678ce92b5e
commit
09ff5c2016
@ -9,6 +9,8 @@ import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.filled.Info
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ExposedDropdownMenuBox
|
||||
@ -16,6 +18,7 @@ import androidx.compose.material3.ExposedDropdownMenuDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@ -43,6 +46,33 @@ fun AddCategory(
|
||||
var name by remember { mutableStateOf("") }
|
||||
var selectedIconIndex by remember { mutableStateOf(-1) } // Store index of selected icon
|
||||
var expanded by remember { mutableStateOf(false) } // Controls dropdown visibility
|
||||
var parsingError by remember { mutableStateOf(false) }
|
||||
|
||||
if (parsingError) {
|
||||
AlertDialog(
|
||||
icon = {
|
||||
Icon(Icons.Default.Info, contentDescription = "Info Icon")
|
||||
},
|
||||
title = {
|
||||
Text(text = "Parsing error")
|
||||
},
|
||||
text = {
|
||||
Text(text = "One or more fields contain invalid input. Please review your entries and try again.")
|
||||
},
|
||||
onDismissRequest = {
|
||||
parsingError = false
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
parsingError = false
|
||||
}
|
||||
) {
|
||||
Text("Okay")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = modifier
|
||||
@ -132,6 +162,8 @@ fun AddCategory(
|
||||
|
||||
categoryViewModel.addCategory(newCategory)
|
||||
onButtonClick()
|
||||
}else{
|
||||
parsingError = true
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -169,7 +169,7 @@ fun EditCategory(
|
||||
ButtonDanger(
|
||||
modifier = Modifier
|
||||
.padding(bottom = 8.dp),
|
||||
"Delete Category",
|
||||
"Delete",
|
||||
onClick = {
|
||||
deleteStarted = true
|
||||
editCategoryViewModel.findEntryByCategoryId()
|
||||
@ -177,7 +177,7 @@ fun EditCategory(
|
||||
)
|
||||
ButtonSuccess(
|
||||
modifier = Modifier,
|
||||
"Save Category",
|
||||
"Done",
|
||||
onClick = {
|
||||
editCategoryViewModel.saveCategory()
|
||||
onButtonClick()
|
||||
|
Loading…
Reference in New Issue
Block a user