diff --git a/src/main/kotlin/main/Glossary.kt b/src/main/kotlin/main/Glossary.kt index 2da2859..198e1a5 100644 --- a/src/main/kotlin/main/Glossary.kt +++ b/src/main/kotlin/main/Glossary.kt @@ -39,7 +39,7 @@ val frame = Frame() fun glossariesPage( currentPage: MutableState ) { - var selectedGlossary by remember { mutableStateOf(null) } + var glossaries by remember { mutableStateOf(emptyList()) } Column( @@ -75,7 +75,7 @@ fun glossariesPage( ) { Button( onClick = { - selectedGlossary = glossary + appState.selectedGlossary = glossary currentPage.value = "glossaireDetail" }, modifier = Modifier diff --git a/src/main/kotlin/main/Main.kt b/src/main/kotlin/main/Main.kt index a41ee2d..a10aa4e 100644 --- a/src/main/kotlin/main/Main.kt +++ b/src/main/kotlin/main/Main.kt @@ -24,6 +24,7 @@ const val glossaryPath : String = "src/main/resources/projects/" // Classe pour stocker l'état global object AppState { var selectedProject: Project? = null + var selectedGlossary: Glossary? = null } @OptIn(ExperimentalMaterialApi::class, ExperimentalComposeUiApi::class) @@ -36,7 +37,7 @@ fun app() { val glossaryDetail: List by remember { mutableStateOf(emptyList()) } var isJavaScriptFileSelected by remember { mutableStateOf(false) } - val selectedGlossary by remember { mutableStateOf(null) } + val isEmptySnackbarVisibleState = remember { mutableStateOf(false) } val containsSpaceSnackbarVisibleState = remember { mutableStateOf(false) } @@ -82,19 +83,19 @@ fun app() { "glossaireDetail" -> { glossaryDetailedPage( glossary = glossaryDetail, - glossaryName = selectedGlossary?.name ?: "", + glossaryName = appState.selectedGlossary?.name ?: "", onBackClick = { currentPage.value = "glossaires" }, onAddWordClick = { currentPage.value = "formulaire" }, onExportClick = { val fileDialog = FileDialog(Frame(), "Save as CSV", FileDialog.SAVE) - fileDialog.file = selectedGlossary?.name // Initial file name + fileDialog.file = appState.selectedGlossary?.name // Initial file name fileDialog.isVisible = true val selectedFile = fileDialog.file val selectedDirectory = fileDialog.directory if (selectedFile != null) { val csvFilePath = "$selectedDirectory$selectedFile" println("Exporting to: $csvFilePath") - selectedGlossary?.let { exportToCSV(it, csvFilePath) } + appState.selectedGlossary?.let { exportToCSV(it, csvFilePath) } } else { println("Export command cancelled by user.") } @@ -102,14 +103,14 @@ fun app() { onImportClick = { selectFile(setOf("csv", "xlsx")) { filePath -> println("Importing file: $filePath") - selectedGlossary?.let { importFile(it, filePath) } + appState.selectedGlossary?.let { importFile(it, filePath) } } } ) } "formulaire" -> { - selectedGlossary?.let { formPage(it, onCancelClick = { currentPage.value = "glossaireDetail" }) } + appState.selectedGlossary?.let { formPage(it, onCancelClick = { currentPage.value = "glossaireDetail" }) } } "choixLangage" -> {