Add glossary name in view
parent
b54f734bd7
commit
9338603c73
|
@ -22,6 +22,7 @@ import main.component.buttonComponent
|
|||
@Composable
|
||||
fun glossaryDetailedPage(
|
||||
glossary: List<Word>,
|
||||
glossaryName: String,
|
||||
onBackClick: () -> Unit,
|
||||
onAddWordClick: () -> Unit,
|
||||
onExportClick: () -> Unit,
|
||||
|
@ -32,7 +33,7 @@ fun glossaryDetailedPage(
|
|||
verticalArrangement = Arrangement.Top, // Align content at the top
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text(text = "Détail du glossaire", style = MaterialTheme.typography.h3)
|
||||
Text(text = "Glossaire : $glossaryName", style = MaterialTheme.typography.h3)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
|
@ -41,28 +42,18 @@ fun glossaryDetailedPage(
|
|||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
Row {
|
||||
buttonComponent(text = "Retour", onClick = { onBackClick() }, icon = Icons.Filled.ArrowBack, width = 150, modifier = Modifier.padding(10.dp))
|
||||
buttonComponent(text = "Ajouter un mot", onClick = { onAddWordClick() }, width = 150, modifier = Modifier.padding(10.dp))
|
||||
buttonComponent(text = "Exporter un fichier", onClick = { onExportClick() }, width = 150, modifier = Modifier.padding(10.dp))
|
||||
if (exportedSuccessfully.value) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { exportedSuccessfully.value = false },
|
||||
title = { Text("Exportation réussie") },
|
||||
text = { Text("Le fichier a été exporté avec succès") },
|
||||
confirmButton = {
|
||||
Button(
|
||||
onClick = { exportedSuccessfully.value = false },
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
backgroundColor = customRedColor,
|
||||
contentColor = Color.White
|
||||
buttonComponent(
|
||||
text = "Retour",
|
||||
onClick = { onBackClick() },
|
||||
icon = Icons.Filled.ArrowBack,
|
||||
modifier = Modifier.padding(10.dp)
|
||||
)
|
||||
) {
|
||||
Text("OK")
|
||||
}
|
||||
}
|
||||
buttonComponent(text = "Ajouter un mot", onClick = { onAddWordClick() }, modifier = Modifier.padding(10.dp))
|
||||
buttonComponent(
|
||||
text = "Importer un fichier",
|
||||
onClick = { onImportClick() },
|
||||
modifier = Modifier.padding(10.dp)
|
||||
)
|
||||
}
|
||||
buttonComponent(text = "Importer un fichier", onClick = { onImportClick() }, width = 150, modifier = Modifier.padding(10.dp))
|
||||
if (importedSuccessfully.value) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { importedSuccessfully.value = false },
|
||||
|
@ -107,6 +98,29 @@ fun glossaryDetailedPage(
|
|||
}
|
||||
)
|
||||
}
|
||||
buttonComponent(
|
||||
text = "Exporter un fichier",
|
||||
onClick = { onExportClick() },
|
||||
modifier = Modifier.padding(10.dp)
|
||||
)
|
||||
if (exportedSuccessfully.value) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { exportedSuccessfully.value = false },
|
||||
title = { Text("Exportation réussie") },
|
||||
text = { Text("Le fichier a été exporté avec succès") },
|
||||
confirmButton = {
|
||||
Button(
|
||||
onClick = { exportedSuccessfully.value = false },
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
backgroundColor = customRedColor,
|
||||
contentColor = Color.White
|
||||
)
|
||||
) {
|
||||
Text("OK")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -189,8 +189,7 @@ fun glossaryList(glossaries: List<Glossary>, onGlossarySelected: (Glossary) -> U
|
|||
modifier = Modifier
|
||||
.padding(10.dp)
|
||||
.width(200.dp)
|
||||
.height(300.dp)
|
||||
.border(1.dp, Color.Black),
|
||||
.height(300.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||
) {
|
||||
if (glossaries.isEmpty()) {
|
||||
|
@ -243,8 +242,7 @@ fun projectList(projects: List<Project>, onProjectSelected: (Project) -> Unit, o
|
|||
modifier = Modifier
|
||||
.padding(10.dp)
|
||||
.width(250.dp)
|
||||
.height(300.dp)
|
||||
.border(1.dp, Color.Black),
|
||||
.height(300.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||
) {
|
||||
if (projects.isEmpty()) {
|
||||
|
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import androidx.compose.desktop.ui.tooling.preview.Preview
|
||||
import androidx.compose.foundation.VerticalScrollbar
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
|
@ -23,7 +22,6 @@ import androidx.compose.ui.window.*
|
|||
import java.awt.FileDialog
|
||||
import java.awt.Frame
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
|
||||
val customRedColor = Color(0xFFB70D1B)
|
||||
|
@ -43,7 +41,7 @@ fun app() {
|
|||
val languageManager = remember { LanguageManager() }
|
||||
MaterialTheme {
|
||||
|
||||
var glossaryDetail: List<Word> by remember { mutableStateOf(emptyList()) }
|
||||
val glossaryDetail: List<Word> by remember { mutableStateOf(emptyList()) }
|
||||
var isJavaScriptFileSelected by remember { mutableStateOf(false) }
|
||||
|
||||
var glossaries by remember { mutableStateOf(emptyList<Glossary>()) }
|
||||
|
@ -197,28 +195,35 @@ fun app() {
|
|||
.onKeyEvent { event ->
|
||||
if (event.key == Key.Enter && event.type == KeyEventType.KeyDown) {
|
||||
// Handle the Enter key event by calling the common function
|
||||
if (nouveauGlossaireName.isEmpty()) {
|
||||
when {
|
||||
nouveauGlossaireName.isEmpty() -> {
|
||||
println("Veuillez saisir un nom pour le nouveau glossaire")
|
||||
isEmptySnackbarVisibleState.value = true
|
||||
} else if (nouveauGlossaireName.contains(" ")) {
|
||||
}
|
||||
nouveauGlossaireName.contains(" ") -> {
|
||||
println("Le nom du glossaire ne doit pas contenir d'espace")
|
||||
containsSpaceSnackbarVisibleState.value = true
|
||||
} else if (glossaries.any { it.name == nouveauGlossaireName }) {
|
||||
}
|
||||
glossaries.any { it.name == nouveauGlossaireName } -> {
|
||||
println("Le nom du glossaire existe déjà")
|
||||
glossaryAlreadyExistsSnackbarVisibleState.value = true
|
||||
} else if (!isValidFileName(nouveauGlossaireName)) {
|
||||
}
|
||||
!isValidFileName(nouveauGlossaireName) -> {
|
||||
println("Le nom du glossaire contient des caractères non autorisés")
|
||||
invalidCharacterSnackbarVisibleState.value = true
|
||||
} else {
|
||||
}
|
||||
else -> {
|
||||
val newGlossary = Glossary(nouveauGlossaireName, "$nouveauGlossaireName.json")
|
||||
glossaries = glossaries + newGlossary
|
||||
// create new json file
|
||||
val newFile = File(glossaryPath + (appState.selectedProject?.name) + "/" + newGlossary.jsonFilePath)
|
||||
val newFile =
|
||||
File(glossaryPath + (appState.selectedProject?.name) + "/" + newGlossary.jsonFilePath)
|
||||
newFile.createNewFile()
|
||||
// update glossaries list
|
||||
glossaries = loadGlossaries(appState.selectedProject!!)
|
||||
currentPage.value = "glossaires" // Revenir à la liste des glossaires
|
||||
}
|
||||
}
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
@ -234,19 +239,24 @@ fun app() {
|
|||
Button(
|
||||
onClick = {
|
||||
// Handle the Enter key event by calling the common function
|
||||
if (nouveauGlossaireName.isEmpty()) {
|
||||
when {
|
||||
nouveauGlossaireName.isEmpty() -> {
|
||||
println("Veuillez saisir un nom pour le nouveau glossaire")
|
||||
isEmptySnackbarVisibleState.value = true
|
||||
} else if (nouveauGlossaireName.contains(" ")) {
|
||||
}
|
||||
nouveauGlossaireName.contains(" ") -> {
|
||||
println("Le nom du glossaire ne doit pas contenir d'espace")
|
||||
containsSpaceSnackbarVisibleState.value = true
|
||||
} else if (glossaries.any { it.name == nouveauGlossaireName }) {
|
||||
}
|
||||
glossaries.any { it.name == nouveauGlossaireName } -> {
|
||||
println("Le nom du glossaire existe déjà")
|
||||
glossaryAlreadyExistsSnackbarVisibleState.value = true
|
||||
} else if (!isValidFileName(nouveauGlossaireName)) {
|
||||
}
|
||||
!isValidFileName(nouveauGlossaireName) -> {
|
||||
println("Le nom du glossaire contient des caractères non autorisés")
|
||||
invalidCharacterSnackbarVisibleState.value = true
|
||||
} else {
|
||||
}
|
||||
else -> {
|
||||
val newGlossary = Glossary(nouveauGlossaireName, "$nouveauGlossaireName.json")
|
||||
glossaries = glossaries + newGlossary
|
||||
// create new json file
|
||||
|
@ -257,6 +267,7 @@ fun app() {
|
|||
glossaries = loadGlossaries(appState.selectedProject!!)
|
||||
currentPage.value = "glossaires" // Revenir à la liste des glossaires
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.width(200.dp),
|
||||
|
@ -299,6 +310,7 @@ fun app() {
|
|||
"glossaireDetail" -> {
|
||||
glossaryDetailedPage(
|
||||
glossary = glossaryDetail,
|
||||
glossaryName = selectedGlossary?.name ?: "",
|
||||
onBackClick = { currentPage.value = "glossaires" },
|
||||
onAddWordClick = { currentPage.value = "formulaire" },
|
||||
onExportClick = {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package main
|
||||
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
|
@ -245,7 +244,7 @@ fun newProject(
|
|||
}
|
||||
}
|
||||
) {
|
||||
Text("Veuillez entrer un nom de glossaire.")
|
||||
Text("Veuillez entrer un nom de projet.")
|
||||
}
|
||||
}
|
||||
if (containsSpaceSnackbarVisibleState.value) {
|
||||
|
@ -263,7 +262,7 @@ fun newProject(
|
|||
}
|
||||
}
|
||||
) {
|
||||
Text("Veuillez ne pas mettre d'espace dans le nom du glossaire.")
|
||||
Text("Veuillez ne pas mettre d'espace dans le nom du projet.")
|
||||
}
|
||||
}
|
||||
if (glossaryAlreadyExistsSnackbarVisibleState.value) {
|
||||
|
@ -281,7 +280,7 @@ fun newProject(
|
|||
}
|
||||
}
|
||||
) {
|
||||
Text("Ce glossaire existe déjà.")
|
||||
Text("Ce projet existe déjà.")
|
||||
}
|
||||
}
|
||||
if (invalidCharacterSnackbarVisibleState.value) {
|
||||
|
@ -299,7 +298,7 @@ fun newProject(
|
|||
}
|
||||
}
|
||||
) {
|
||||
Text("Le nom du glossaire contient des caractères non autorisés (caractères spéciaux).")
|
||||
Text("Le nom du projet contient des caractères non autorisés (caractères spéciaux).")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue