From 09ff5c20168078fb87823637ef6c6442f5509882 Mon Sep 17 00:00:00 2001 From: Xaver Date: Mon, 20 Jan 2025 12:56:15 +0100 Subject: [PATCH] fixed no error bug --- .../ledger/ui/category/add/AddCategoryUI.kt | 32 +++++++++++++++++++ .../ledger/ui/category/edit/EditCategory.kt | 4 +-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Ledger/app/src/main/java/at/xaxa/ledger/ui/category/add/AddCategoryUI.kt b/Ledger/app/src/main/java/at/xaxa/ledger/ui/category/add/AddCategoryUI.kt index b7a2ce2..0c8ef02 100644 --- a/Ledger/app/src/main/java/at/xaxa/ledger/ui/category/add/AddCategoryUI.kt +++ b/Ledger/app/src/main/java/at/xaxa/ledger/ui/category/add/AddCategoryUI.kt @@ -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 } } ) diff --git a/Ledger/app/src/main/java/at/xaxa/ledger/ui/category/edit/EditCategory.kt b/Ledger/app/src/main/java/at/xaxa/ledger/ui/category/edit/EditCategory.kt index d790e0d..6f4d073 100644 --- a/Ledger/app/src/main/java/at/xaxa/ledger/ui/category/edit/EditCategory.kt +++ b/Ledger/app/src/main/java/at/xaxa/ledger/ui/category/edit/EditCategory.kt @@ -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()