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,19 +71,35 @@ fun app() {
verticalArrangement = Arrangement.spacedBy(10.dp) verticalArrangement = Arrangement.spacedBy(10.dp)
) { ) {
items(glossaries) { glossary -> items(glossaries) { glossary ->
Button( Row(
onClick = { modifier = Modifier.width(200.dp).fillMaxWidth(),
selectedGlossary = glossary horizontalArrangement = Arrangement.SpaceBetween
currentPage.value = "glossaireOptions"
},
modifier = Modifier
.width(200.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) { ) {
Text(glossary.name) Button(
onClick = {
selectedGlossary = glossary
currentPage.value = "glossaireOptions"
},
modifier = Modifier
.width(150.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) {
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("") }