Merge remote-tracking branch 'origin/main'
# Conflicts: # src/main/kotlin/main/Main.ktmain
commit
69dd7abaa7
|
@ -20,7 +20,7 @@ import java.io.IOException
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterialApi::class)
|
@OptIn(ExperimentalMaterialApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun formPage(onCancelClick: () -> Unit) {
|
fun formPage(glossary: Glossary, onCancelClick: () -> Unit) {
|
||||||
// State to track whether to show the snackbar
|
// State to track whether to show the snackbar
|
||||||
val requiredFieldsSnackbarVisibleState = remember { mutableStateOf(false) }
|
val requiredFieldsSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||||
val alreadyExistSnackbarVisibleState = remember { mutableStateOf(false) }
|
val alreadyExistSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||||
|
@ -172,7 +172,7 @@ fun formPage(onCancelClick: () -> Unit) {
|
||||||
return@Button
|
return@Button
|
||||||
}
|
}
|
||||||
|
|
||||||
val wordsList = loadDatasFromFile().toMutableList()
|
val wordsList = loadDatasFromFile(glossary.jsonFilePath).toMutableList()
|
||||||
|
|
||||||
// Transform name to lowercase to avoid duplicates
|
// Transform name to lowercase to avoid duplicates
|
||||||
name.value = name.value.lowercase()
|
name.value = name.value.lowercase()
|
||||||
|
@ -194,7 +194,7 @@ fun formPage(onCancelClick: () -> Unit) {
|
||||||
antonym = antonym.value
|
antonym = antonym.value
|
||||||
)
|
)
|
||||||
|
|
||||||
addWordToGlossary(newWord)
|
addWordToGlossary(glossary.jsonFilePath, newWord)
|
||||||
openDialog.value = true
|
openDialog.value = true
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -267,8 +267,8 @@ fun resetFields(
|
||||||
antonym.value = ""
|
antonym.value = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addWordToGlossary(newWord: Word) {
|
fun addWordToGlossary(filePath: String, newWord: Word) {
|
||||||
val wordsList = loadDatasFromFile().toMutableList()
|
val wordsList = loadDatasFromFile(filePath).toMutableList()
|
||||||
|
|
||||||
// Verify if the word already exists in the glossary
|
// Verify if the word already exists in the glossary
|
||||||
if (wordsList.any { it.name.equals(newWord.name, ignoreCase = true) }) {
|
if (wordsList.any { it.name.equals(newWord.name, ignoreCase = true) }) {
|
||||||
|
@ -278,28 +278,28 @@ fun addWordToGlossary(newWord: Word) {
|
||||||
|
|
||||||
// Add the new word to the glossary
|
// Add the new word to the glossary
|
||||||
wordsList.add(newWord)
|
wordsList.add(newWord)
|
||||||
saveDatasInFile(wordsList)
|
saveDatasInFile(filePath, wordsList)
|
||||||
|
|
||||||
println("Mot ajouté avec succès : ${newWord.name}")
|
println("Mot ajouté avec succès : ${newWord.name}")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveDatasInFile(listeWords: List<Word>) {
|
fun saveDatasInFile(filePath: String, listeWords: List<Word>) {
|
||||||
val json = Json { prettyPrint = true }
|
val json = Json { prettyPrint = true }
|
||||||
try {
|
try {
|
||||||
val content = json.encodeToString(listeWords)
|
val content = json.encodeToString(listeWords)
|
||||||
File("glossaire.json").writeText(content)
|
File(filePath).writeText(content)
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadDatasFromFile(): List<Word> {
|
fun loadDatasFromFile(filePath: String): List<Word> {
|
||||||
// If file is empty, return empty list
|
// If file is empty, return empty list
|
||||||
if (!File("glossaire.json").exists() || File("glossaire.json").length() == 0L) {
|
if (!File(filePath).exists() || File(filePath).length() == 0L) {
|
||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
return try {
|
return try {
|
||||||
val content = File("glossaire.json").readText()
|
val content = File(filePath).readText()
|
||||||
Json.decodeFromString<List<Word>>(content)
|
Json.decodeFromString<List<Word>>(content)
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
|
|
@ -5,7 +5,7 @@ import androidx.compose.material.Button
|
||||||
import androidx.compose.material.ButtonDefaults
|
import androidx.compose.material.ButtonDefaults
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
@ -20,6 +20,9 @@ import java.io.FileInputStream
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
|
data class Glossary(val name: String, val jsonFilePath: String)
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun glossaryPage(
|
fun glossaryPage(
|
||||||
languageManager: LanguageManager,
|
languageManager: LanguageManager,
|
||||||
|
@ -27,9 +30,11 @@ fun glossaryPage(
|
||||||
onImportClick: () -> Unit,
|
onImportClick: () -> Unit,
|
||||||
onExportClick: () -> Unit,
|
onExportClick: () -> Unit,
|
||||||
onSeeGlossaryClick: () -> Unit,
|
onSeeGlossaryClick: () -> Unit,
|
||||||
onBackClick: () -> Unit
|
onBackClick: () -> Unit,
|
||||||
|
selectedGlossary: Glossary
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
verticalArrangement = Arrangement.Top, // Align content at the top
|
verticalArrangement = Arrangement.Top, // Align content at the top
|
||||||
|
@ -139,8 +144,8 @@ fun selectFile(extensions: Set<String>, onFileSelected: (String) -> Unit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun exportToCSV(csvFilePath: String) {
|
fun exportToCSV(glossary: Glossary, csvFilePath: String) {
|
||||||
val glossary = loadDatasFromFile()
|
val glossary = loadDatasFromFile(glossary.jsonFilePath)
|
||||||
val csvContent = buildString {
|
val csvContent = buildString {
|
||||||
appendLine("Mot;Description;Contexte principal;Contexte 2;Lié à;Synonyme;Antonyme;")
|
appendLine("Mot;Description;Contexte principal;Contexte 2;Lié à;Synonyme;Antonyme;")
|
||||||
glossary.forEach { entry ->
|
glossary.forEach { entry ->
|
||||||
|
@ -159,16 +164,16 @@ fun exportToCSV(csvFilePath: String) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun importFile(filePath: String) {
|
fun importFile(glossary: Glossary, filePath: String) {
|
||||||
val fileExtension = File(filePath).extension.lowercase()
|
val fileExtension = File(filePath).extension.lowercase()
|
||||||
|
|
||||||
when (fileExtension) {
|
when (fileExtension) {
|
||||||
"csv" -> {
|
"csv" -> {
|
||||||
importCSVFile(filePath)
|
importCSVFile(glossary, filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
"xlsx" -> {
|
"xlsx" -> {
|
||||||
importXLSXFile(filePath)
|
importXLSXFile(glossary, filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
|
@ -177,7 +182,7 @@ fun importFile(filePath: String) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun importCSVFile(filePath: String) {
|
fun importCSVFile(glossary : Glossary, filePath: String) {
|
||||||
val file = File(filePath).readText(Charsets.UTF_8)
|
val file = File(filePath).readText(Charsets.UTF_8)
|
||||||
|
|
||||||
val lines = file.split("\n")
|
val lines = file.split("\n")
|
||||||
|
@ -212,12 +217,12 @@ fun importCSVFile(filePath: String) {
|
||||||
if (!verifyRequiredFields(mot)) {
|
if (!verifyRequiredFields(mot)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
addWordToGlossary(nouveauWord)
|
addWordToGlossary(glossary.jsonFilePath, nouveauWord)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun importXLSXFile(cheminFichier: String) {
|
private fun importXLSXFile(glossary: Glossary, cheminFichier: String) {
|
||||||
val workbook: Workbook
|
val workbook: Workbook
|
||||||
try {
|
try {
|
||||||
FileInputStream(cheminFichier).use { fileInputStream ->
|
FileInputStream(cheminFichier).use { fileInputStream ->
|
||||||
|
@ -266,7 +271,7 @@ private fun importXLSXFile(cheminFichier: String) {
|
||||||
)
|
)
|
||||||
|
|
||||||
if (newWord.name.isNotBlank() && verifyRequiredFields(line)) {
|
if (newWord.name.isNotBlank() && verifyRequiredFields(line)) {
|
||||||
addWordToGlossary(newWord)
|
addWordToGlossary(glossary.jsonFilePath, newWord)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ fun homePage(
|
||||||
if (isCompareClicked) {
|
if (isCompareClicked) {
|
||||||
println(mostUsedWordList.keys.toList())
|
println(mostUsedWordList.keys.toList())
|
||||||
compareResults(
|
compareResults(
|
||||||
glossaryWords = loadDatasFromFile(),
|
glossaryWords = loadDatasFromFile("glossaire.json"),
|
||||||
codeWords = mostUsedWordList.keys.toList(),
|
codeWords = mostUsedWordList.keys.toList(),
|
||||||
onBackClick = { isCompareClicked = false }
|
onBackClick = { isCompareClicked = false }
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,15 +1,21 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import androidx.compose.desktop.ui.tooling.preview.Preview
|
import androidx.compose.desktop.ui.tooling.preview.Preview
|
||||||
|
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.*
|
||||||
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.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.window.*
|
import androidx.compose.ui.window.*
|
||||||
import java.awt.FileDialog
|
import java.awt.FileDialog
|
||||||
import java.awt.Frame
|
import java.awt.Frame
|
||||||
|
import java.io.File
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
val customRedColor = Color(0xFFB70D1B)
|
val customRedColor = Color(0xFFB70D1B)
|
||||||
|
|
||||||
|
@ -17,30 +23,187 @@ val customRedColor = Color(0xFFB70D1B)
|
||||||
@Composable
|
@Composable
|
||||||
@Preview
|
@Preview
|
||||||
fun app() {
|
fun app() {
|
||||||
val languageManager = LanguageManager()
|
|
||||||
MaterialTheme {
|
MaterialTheme {
|
||||||
val currentPage = remember { mutableStateOf("accueil") }
|
val currentPage = remember { mutableStateOf("accueil") }
|
||||||
|
|
||||||
var glossaryDetail: List<Word> by remember { mutableStateOf(emptyList()) }
|
var glossaryDetail: List<Word> by remember { mutableStateOf(emptyList()) }
|
||||||
var isJavaScriptFileSelected by remember { mutableStateOf(false) }
|
var isJavaScriptFileSelected by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
var glossaries by remember { mutableStateOf(emptyList<Glossary>()) }
|
||||||
|
|
||||||
|
var selectedGlossary by remember { mutableStateOf<Glossary?>(null) }
|
||||||
|
|
||||||
|
val isEmptySnackbarVisibleState = remember { mutableStateOf(false) }
|
||||||
|
val containsSpaceSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||||
|
val glossaryAlreadyExistsSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Récupérer tous les glossaires à la racine du projet et les ajouter à la liste glossaries
|
||||||
|
glossaries = loadGlossaries()
|
||||||
|
|
||||||
|
|
||||||
when (currentPage.value) {
|
when (currentPage.value) {
|
||||||
"accueil" -> {
|
"accueil" -> {
|
||||||
homePage(
|
homePage(
|
||||||
languageManager,
|
onGlossaryClick = { currentPage.value = "glossaires" },
|
||||||
onGlossaryClick = { currentPage.value = "glossaire" },
|
|
||||||
onCodeToVerifyClick = { currentPage.value = "choixLangage" }
|
onCodeToVerifyClick = { currentPage.value = "choixLangage" }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
"glossaire" -> {
|
"glossaires" -> {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
verticalArrangement = Arrangement.Center,
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
Text("Sélectionnez un glossaire", style = MaterialTheme.typography.h5)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
LazyColumn(
|
||||||
|
modifier = Modifier.padding(10.dp),
|
||||||
|
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
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Text(glossary.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
Button(
|
||||||
|
onClick = {
|
||||||
|
currentPage.value = "nouveauGlossaire"
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.width(300.dp),
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = customRedColor,
|
||||||
|
contentColor = Color.White
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Text("Créer un nouveau glossaire")
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(6.dp))
|
||||||
|
|
||||||
|
Button(
|
||||||
|
onClick = {
|
||||||
|
currentPage.value = "accueil"
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.width(250.dp),
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = customRedColor,
|
||||||
|
contentColor = Color.White
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Text("Retour")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nouvelle page pour créer un nouveau glossaire
|
||||||
|
"nouveauGlossaire" -> {
|
||||||
|
var nouveauGlossaireName by remember { mutableStateOf("") }
|
||||||
|
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
verticalArrangement = Arrangement.Center,
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
TextField(
|
||||||
|
value = nouveauGlossaireName,
|
||||||
|
onValueChange = { nouveauGlossaireName = it },
|
||||||
|
label = { Text("Nom du nouveau glossaire") },
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(16.dp)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
colors = TextFieldDefaults.textFieldColors(
|
||||||
|
backgroundColor = Color.White,
|
||||||
|
focusedIndicatorColor = customRedColor,
|
||||||
|
unfocusedIndicatorColor = Color.Gray
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
Button(
|
||||||
|
onClick = {
|
||||||
|
// Ajouter le code pour créer un nouveau glossaire avec le nom saisi
|
||||||
|
//first check if the name is not empty, if there is space or if the name already exists
|
||||||
|
if (nouveauGlossaireName.isEmpty()) {
|
||||||
|
println("Veuillez saisir un nom pour le nouveau glossaire")
|
||||||
|
isEmptySnackbarVisibleState.value = true
|
||||||
|
return@Button
|
||||||
|
}
|
||||||
|
if (nouveauGlossaireName.contains(" ")) {
|
||||||
|
println("Le nom du glossaire ne doit pas contenir d'espace")
|
||||||
|
containsSpaceSnackbarVisibleState.value = true
|
||||||
|
return@Button
|
||||||
|
}
|
||||||
|
glossaries.forEach { glossary ->
|
||||||
|
nouveauGlossaireName = nouveauGlossaireName.lowercase(Locale.getDefault())
|
||||||
|
if (glossary.name == nouveauGlossaireName) {
|
||||||
|
println("Le nom du glossaire existe déjà")
|
||||||
|
glossaryAlreadyExistsSnackbarVisibleState.value = true
|
||||||
|
return@Button
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val newGlossary = Glossary(nouveauGlossaireName, "$nouveauGlossaireName.json")
|
||||||
|
glossaries = glossaries + newGlossary
|
||||||
|
//create new json file
|
||||||
|
val newFile = File(newGlossary.jsonFilePath)
|
||||||
|
newFile.createNewFile()
|
||||||
|
//update glossaries list
|
||||||
|
glossaries = loadGlossaries()
|
||||||
|
currentPage.value = "glossaires" // Revenir à la liste des glossaires
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.width(200.dp),
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = customRedColor,
|
||||||
|
contentColor = Color.White
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Text("Créer")
|
||||||
|
}
|
||||||
|
|
||||||
|
Button(
|
||||||
|
onClick = {
|
||||||
|
currentPage.value = "glossaires"
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.width(200.dp),
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = customRedColor,
|
||||||
|
contentColor = Color.White
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Text("Annuler")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"glossaireOptions" -> {
|
||||||
glossaryPage(
|
glossaryPage(
|
||||||
languageManager,
|
|
||||||
onAddWordClick = { currentPage.value = "formulaire" },
|
onAddWordClick = { currentPage.value = "formulaire" },
|
||||||
onImportClick = {
|
onImportClick = {
|
||||||
selectFile(setOf("csv", "xlsx")) { filePath ->
|
selectFile(setOf("csv", "xlsx")) { filePath ->
|
||||||
println("Importing file: $filePath")
|
println("Importing file: $filePath")
|
||||||
importFile(filePath)
|
selectedGlossary?.let { importFile(it, filePath) }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onExportClick = {
|
onExportClick = {
|
||||||
|
@ -52,27 +215,28 @@ fun app() {
|
||||||
if (selectedFile != null) {
|
if (selectedFile != null) {
|
||||||
val csvFilePath = "$selectedDirectory$selectedFile"
|
val csvFilePath = "$selectedDirectory$selectedFile"
|
||||||
println("Exporting to: $csvFilePath")
|
println("Exporting to: $csvFilePath")
|
||||||
exportToCSV(csvFilePath)
|
selectedGlossary?.let { exportToCSV(it, csvFilePath) }
|
||||||
} else {
|
} else {
|
||||||
println("Export command cancelled by user.")
|
println("Export command cancelled by user.")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSeeGlossaryClick = {
|
onSeeGlossaryClick = {
|
||||||
glossaryDetail = loadDatasFromFile()
|
glossaryDetail = selectedGlossary?.let { loadDatasFromFile(it.jsonFilePath) }!!
|
||||||
currentPage.value = "glossaireDetail"
|
currentPage.value = "glossaireDetail"
|
||||||
},
|
},
|
||||||
onBackClick = { currentPage.value = "accueil" }
|
onBackClick = { currentPage.value = "glossaires" },
|
||||||
|
selectedGlossary = selectedGlossary!!
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
"glossaireDetail" -> {
|
"glossaireDetail" -> {
|
||||||
glossaryDetailedPage(
|
glossaryDetailedPage(
|
||||||
glossary = glossaryDetail,
|
glossary = glossaryDetail,
|
||||||
onBackClick = { currentPage.value = "glossaire" }
|
onBackClick = { currentPage.value = "glossaireOptions" }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
"formulaire" -> {
|
"formulaire" -> {
|
||||||
formPage(onCancelClick = { currentPage.value = "glossaire" })
|
selectedGlossary?.let { formPage(it, onCancelClick = { currentPage.value = "glossaireOptions" }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
"choixLangage" -> {
|
"choixLangage" -> {
|
||||||
|
@ -80,7 +244,6 @@ fun app() {
|
||||||
val javaExtensions = setOf("java")
|
val javaExtensions = setOf("java")
|
||||||
val jsExtensions = setOf("js", "html")
|
val jsExtensions = setOf("js", "html")
|
||||||
choixLangagePage(
|
choixLangagePage(
|
||||||
languageManager,
|
|
||||||
onBackClick = { currentPage.value = "accueil" },
|
onBackClick = { currentPage.value = "accueil" },
|
||||||
onPythonClick = {
|
onPythonClick = {
|
||||||
selectFile(pythonExtensions) { filePath ->
|
selectFile(pythonExtensions) { filePath ->
|
||||||
|
@ -130,9 +293,78 @@ fun app() {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (isEmptySnackbarVisibleState.value) {
|
||||||
|
Snackbar(
|
||||||
|
modifier = Modifier.padding(16.dp),
|
||||||
|
action = {
|
||||||
|
Button(
|
||||||
|
onClick = { isEmptySnackbarVisibleState.value = false },
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = customRedColor,
|
||||||
|
contentColor = Color.White
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Text("OK")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
Text("Veuillez entrer un nom de glossaire.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (containsSpaceSnackbarVisibleState.value) {
|
||||||
|
Snackbar(
|
||||||
|
modifier = Modifier.padding(16.dp),
|
||||||
|
action = {
|
||||||
|
Button(
|
||||||
|
onClick = { containsSpaceSnackbarVisibleState.value = false },
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = customRedColor,
|
||||||
|
contentColor = Color.White
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Text("OK")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
Text("Veuillez ne pas mettre d'espace dans le nom du glossaire.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (glossaryAlreadyExistsSnackbarVisibleState.value) {
|
||||||
|
Snackbar(
|
||||||
|
modifier = Modifier.padding(16.dp),
|
||||||
|
action = {
|
||||||
|
Button(
|
||||||
|
onClick = { glossaryAlreadyExistsSnackbarVisibleState.value = false },
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = customRedColor,
|
||||||
|
contentColor = Color.White
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Text("OK")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
Text("Ce glossaire existe déjà.")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun loadGlossaries(): List<Glossary> {
|
||||||
|
val glossaries = mutableListOf<Glossary>()
|
||||||
|
//Récupérer tous les fichiers json à la racine du projet
|
||||||
|
val glossaryFiles = File(".").listFiles { file ->
|
||||||
|
file.extension == "json"
|
||||||
|
}
|
||||||
|
glossaryFiles?.forEach { file ->
|
||||||
|
val glossary = Glossary(file.nameWithoutExtension, file.name)
|
||||||
|
glossaries.add(glossary)
|
||||||
|
}
|
||||||
|
println(glossaries)
|
||||||
|
return glossaries
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun main() = application {
|
fun main() = application {
|
||||||
val state = rememberWindowState(
|
val state = rememberWindowState(
|
||||||
placement = WindowPlacement.Floating,
|
placement = WindowPlacement.Floating,
|
||||||
|
|
Loading…
Reference in New Issue