Added delete glossary
parent
3e88d7b888
commit
7edd584d7e
|
@ -5,6 +5,8 @@ import androidx.compose.foundation.layout.*
|
|||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
|
@ -17,6 +19,7 @@ import java.awt.Frame
|
|||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
|
||||
val customRedColor = Color(0xFFB70D1B)
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
|
@ -68,19 +71,35 @@ fun app() {
|
|||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||
) {
|
||||
items(glossaries) { glossary ->
|
||||
Button(
|
||||
onClick = {
|
||||
selectedGlossary = glossary
|
||||
currentPage.value = "glossaireOptions"
|
||||
},
|
||||
modifier = Modifier
|
||||
.width(200.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
backgroundColor = customRedColor,
|
||||
contentColor = Color.White
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier.width(200.dp).fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
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
|
||||
"nouveauGlossaire" -> {
|
||||
var nouveauGlossaireName by remember { mutableStateOf("") }
|
||||
|
|
Loading…
Reference in New Issue