Added delete glossary

main
Cemal Odabasioglu 2023-12-19 11:04:05 +01:00
parent 3e88d7b888
commit 7edd584d7e
1 changed files with 32 additions and 12 deletions

View File

@ -5,6 +5,8 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.material.* import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Delete
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@ -17,6 +19,7 @@ import java.awt.Frame
import java.io.File import java.io.File
import java.util.* import java.util.*
val customRedColor = Color(0xFFB70D1B) val customRedColor = Color(0xFFB70D1B)
@OptIn(ExperimentalMaterialApi::class) @OptIn(ExperimentalMaterialApi::class)
@ -68,13 +71,17 @@ fun app() {
verticalArrangement = Arrangement.spacedBy(10.dp) verticalArrangement = Arrangement.spacedBy(10.dp)
) { ) {
items(glossaries) { glossary -> items(glossaries) { glossary ->
Row(
modifier = Modifier.width(200.dp).fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween
) {
Button( Button(
onClick = { onClick = {
selectedGlossary = glossary selectedGlossary = glossary
currentPage.value = "glossaireOptions" currentPage.value = "glossaireOptions"
}, },
modifier = Modifier modifier = Modifier
.width(200.dp), .width(150.dp),
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor, backgroundColor = customRedColor,
contentColor = Color.White contentColor = Color.White
@ -82,6 +89,18 @@ fun app() {
) { ) {
Text(glossary.name) Text(glossary.name)
} }
IconButton(
onClick = {
// Handle delete glossary action
glossaries = glossaries.filterNot { it == glossary }
val file = File(glossary.jsonFilePath)
file.delete()
}
) {
Icon(imageVector = Icons.Default.Delete, contentDescription = "Delete Glossary")
}
}
} }
} }
@ -119,6 +138,7 @@ fun app() {
} }
} }
// Nouvelle page pour créer un nouveau glossaire // Nouvelle page pour créer un nouveau glossaire
"nouveauGlossaire" -> { "nouveauGlossaire" -> {
var nouveauGlossaireName by remember { mutableStateOf("") } var nouveauGlossaireName by remember { mutableStateOf("") }