del cat fixed

This commit is contained in:
Xaver 2025-01-17 11:18:58 +01:00
parent d4116b5a7f
commit 097835de83
3 changed files with 18 additions and 18 deletions

View File

@ -63,7 +63,6 @@ import java.util.Locale
fun HeaderCard(modifier: Modifier = Modifier, balance: String, onCategoryButton: () -> Unit) {
Surface(
shape = RoundedCornerShape(12.dp),
color = Color(0xfff9f9f9),
border = BorderStroke(1.dp, Color(0xffc6c6c6)),
modifier = modifier
.shadow(
@ -108,7 +107,6 @@ fun LayoutMediaTextHeader(modifier: Modifier = Modifier, balance: String) {
) {
Text(
text = "your balance",
color = Color(0xff1b1b1b),
lineHeight = 1.5.em,
style = TextStyle(
fontSize = 16.sp,
@ -118,7 +116,6 @@ fun LayoutMediaTextHeader(modifier: Modifier = Modifier, balance: String) {
)
Text(
text = balance,
color = Color(0xff1b1b1b),
lineHeight = 1.43.em,
style = TextStyle(
fontSize = 40.sp,
@ -142,7 +139,6 @@ fun HorizontalCard(modifier: Modifier = Modifier, name: String, date: String, am
Surface(
onClick = onClick,
shape = RoundedCornerShape(12.dp),
color = Color(0xfff9f9f9),
border = BorderStroke(1.dp, Color(0xffc6c6c6)),
modifier = modifier
.clip(shape = RoundedCornerShape(12.dp))
@ -167,7 +163,6 @@ fun CategoryCard(
Surface(
onClick = onClick,
shape = RoundedCornerShape(12.dp),
color = Color(0xfff9f9f9),
border = BorderStroke(1.dp, Color(0xffc6c6c6)),
modifier = modifier
.clip(shape = RoundedCornerShape(12.dp))
@ -206,7 +201,6 @@ fun LayoutMediaText(modifier: Modifier = Modifier, name: String, date: String, a
) {
Text(
text = name,
color = Color(0xff1b1b1b),
lineHeight = 1.5.em,
style = TextStyle(
fontSize = 16.sp,
@ -216,7 +210,6 @@ fun LayoutMediaText(modifier: Modifier = Modifier, name: String, date: String, a
)
Text(
text = date,
color = Color(0xff1b1b1b),
lineHeight = 1.43.em,
style = TextStyle(
fontSize = 14.sp,
@ -257,7 +250,6 @@ fun LayoutMediaText(modifier: Modifier = Modifier, name: String, iconId: Int) {
)
Text(
text = name,
color = Color(0xff1b1b1b),
lineHeight = 1.5.em,
style = TextStyle(
fontSize = 16.sp,
@ -330,7 +322,7 @@ private fun CustomButton(modifier: Modifier = Modifier, text: String, onClick: (
) {
Text(
text = text,
color = Color.White,
//color = Color.White,
textAlign = TextAlign.Center,
lineHeight = 1.43.em,
style = MaterialTheme.typography.labelMedium,

View File

@ -44,7 +44,8 @@ fun EditCategory(
editCategoryViewModel: EditCategoryViewModel = viewModel(factory = AppViewModelProvider.Factory)
) {
val category = editCategoryViewModel.categoryUi.category
var showError by remember { mutableStateOf(editCategoryViewModel.entryUIState) }
var showError by remember { mutableStateOf(editCategoryViewModel.deletePossible) }
var redirect by remember { mutableStateOf(editCategoryViewModel.redirect) }
var deleteStarted by remember { mutableStateOf(false) }
var expanded by remember { mutableStateOf(false) }
var selectedIconIndex by remember { mutableIntStateOf(category.icon) }
@ -56,11 +57,15 @@ fun EditCategory(
LaunchedEffect(deleteStarted) {
if (deleteStarted) {
editCategoryViewModel.findEntryByCategoryId()
showError = editCategoryViewModel.entryUIState
showError = editCategoryViewModel.deletePossible
}
if (redirect) {
onButtonClick()
}
}
if (deleteStarted && showError) {
if (showError) {
AlertDialog(
icon = {
Icon(Icons.Default.Info, contentDescription = "Info Icon")
@ -86,9 +91,6 @@ fun EditCategory(
}
}
)
}else if(deleteStarted && !showError){
editCategoryViewModel.deleteEntry()
onButtonClick()
}

View File

@ -29,7 +29,8 @@ class EditCategoryViewModel(private val savedStateHandle: SavedStateHandle, priv
var categoryUi by mutableStateOf(CategoryUIState())
private set
var entryUIState by mutableStateOf(false)
var deletePossible by mutableStateOf(false)
var redirect by mutableStateOf(false)
@ -39,6 +40,8 @@ class EditCategoryViewModel(private val savedStateHandle: SavedStateHandle, priv
entryRepository.findCategoryById(categoryId)
}
categoryUi = CategoryUIState(category)
redirect = false;
}
}
@ -46,7 +49,7 @@ class EditCategoryViewModel(private val savedStateHandle: SavedStateHandle, priv
categoryUi = categoryUi.copy(category = category)
}
fun deleteEntry() {
fun deleteCategory() {
viewModelScope.launch {
entryRepository.deleteCategory(categoryUi.category)
}
@ -73,7 +76,10 @@ class EditCategoryViewModel(private val savedStateHandle: SavedStateHandle, priv
}
if(fetchedEntries>0){
entryUIState = true
deletePossible = true
}else{
deleteCategory()
redirect= true;
}
}
//print("ASASDADS$categoryId")