From 4794c8f3b1bc8a8696a1d3a4edd953482516ae37 Mon Sep 17 00:00:00 2001 From: CAPEL Maxime <83071634+fortyup@users.noreply.github.com> Date: Thu, 21 Dec 2023 09:15:35 +0100 Subject: [PATCH] Fix warnings --- src/main/kotlin/main/Form.kt | 2 +- src/main/kotlin/main/Home.kt | 12 ++++++------ src/main/kotlin/main/Main.kt | 2 +- src/main/kotlin/main/parser.kt | 8 ++++---- src/main/kotlin/main/projects.kt | 20 -------------------- 5 files changed, 12 insertions(+), 32 deletions(-) diff --git a/src/main/kotlin/main/Form.kt b/src/main/kotlin/main/Form.kt index a674763..bc2bd5c 100644 --- a/src/main/kotlin/main/Form.kt +++ b/src/main/kotlin/main/Form.kt @@ -25,7 +25,7 @@ var appState = AppState @Composable fun formPage(glossary: Glossary, onCancelClick: () -> Unit) { // State to track whether to show the snackbar - var appState = AppState + AppState val requiredFieldsSnackbarVisibleState = remember { mutableStateOf(false) } val alreadyExistSnackbarVisibleState = remember { mutableStateOf(false) } diff --git a/src/main/kotlin/main/Home.kt b/src/main/kotlin/main/Home.kt index 14d34d7..f9648e1 100644 --- a/src/main/kotlin/main/Home.kt +++ b/src/main/kotlin/main/Home.kt @@ -130,7 +130,7 @@ fun homePage( if (isCompareClicked && selectedProject == null && selectedGlossary == null) { - ProjectList( + projectList( projects = loadProjects(), onProjectSelected = { project -> selectedProject = project @@ -142,7 +142,7 @@ fun homePage( } else if (isCompareClicked && selectedGlossary == null) { - GlossaryList( + glossaryList( glossaries = loadGlossaries(appState.selectedProject!!), onGlossarySelected = { glossary -> selectedGlossary = glossary @@ -163,7 +163,7 @@ fun homePage( } @Composable -fun GlossaryList(glossaries: List, onGlossarySelected: (Glossary) -> Unit, onBackClick: () -> Unit) { +fun glossaryList(glossaries: List, onGlossarySelected: (Glossary) -> Unit, onBackClick: () -> Unit) { Column( modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center, @@ -216,7 +216,7 @@ fun GlossaryList(glossaries: List, onGlossarySelected: (Glossary) -> U Button( onClick = onBackClick, - colors = androidx.compose.material.ButtonDefaults.buttonColors( + colors = ButtonDefaults.buttonColors( backgroundColor = customRedColor, contentColor = Color.White ) @@ -227,7 +227,7 @@ fun GlossaryList(glossaries: List, onGlossarySelected: (Glossary) -> U } @Composable -fun ProjectList(projects: List, onProjectSelected: (Project) -> Unit, onBackClick: () -> Unit) { +fun projectList(projects: List, onProjectSelected: (Project) -> Unit, onBackClick: () -> Unit) { Column( modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center, @@ -280,7 +280,7 @@ fun ProjectList(projects: List, onProjectSelected: (Project) -> Unit, o Button( onClick = onBackClick, - colors = androidx.compose.material.ButtonDefaults.buttonColors( + colors = ButtonDefaults.buttonColors( backgroundColor = customRedColor, contentColor = Color.White ) diff --git a/src/main/kotlin/main/Main.kt b/src/main/kotlin/main/Main.kt index 82cd94f..232cb20 100644 --- a/src/main/kotlin/main/Main.kt +++ b/src/main/kotlin/main/Main.kt @@ -27,7 +27,7 @@ import java.util.* val customRedColor = Color(0xFFB70D1B) val currentPage = mutableStateOf("accueil") -val glossaryPath : String = "src/main/resources/projects/" +const val glossaryPath : String = "src/main/resources/projects/" // Classe pour stocker l'état global object AppState { diff --git a/src/main/kotlin/main/parser.kt b/src/main/kotlin/main/parser.kt index 837196f..f2ddf35 100644 --- a/src/main/kotlin/main/parser.kt +++ b/src/main/kotlin/main/parser.kt @@ -17,7 +17,7 @@ fun takeOnlyJs(fileName: String): String { } fun jsWords(code : Map) : Map{ - val js = File("src/main/kotlin/main/sampleJS.txt").readText().toString().split(",") + val js = File("src/main/kotlin/main/sampleJS.txt").readText().split(",") return code.filter { it.key !in js } } @@ -49,10 +49,10 @@ fun splitLanguages(file : String){ fun parser(fileName : String) : MutableMap { val delimiter1 = " " - val regex = "[^a-zA-Z^é^à]".toRegex() + val regex = "[^a-zA-Z^éà]".toRegex() val array = mutableListOf() - val line = delStrings(takeOnlyJs(fileName)).toString().replace(regex, " ").toString() + val line = delStrings(takeOnlyJs(fileName)).replace(regex, " ") line.split(delimiter1).forEach { if (it != "") { @@ -62,7 +62,7 @@ fun parser(fileName : String) : MutableMap { val map = jsWords(array.groupingBy { it }.eachCount()) var sortedMap = map.toList().take(10).sortedBy { (_, value) -> value }.toMap() - sortedMap.forEach() { (t, u) -> println("$t : $u") } // affiche le nombre d'occurence de chaque mot + sortedMap.forEach { (t, u) -> println("$t : $u") } // affiche le nombre d'occurence de chaque mot sortedMap = sortedMap.toMutableMap() return sortedMap diff --git a/src/main/kotlin/main/projects.kt b/src/main/kotlin/main/projects.kt index 2fa023f..9e05bdb 100644 --- a/src/main/kotlin/main/projects.kt +++ b/src/main/kotlin/main/projects.kt @@ -26,7 +26,6 @@ fun projectsPage( currentPage: MutableState ) { val appState = AppState - var selectedProject: Project? by remember { mutableStateOf(null) } var projects: List by remember { mutableStateOf(loadProjects()) } Column( @@ -113,25 +112,6 @@ fun projectsPage( } } -@Composable -fun mySuperCoolButton( - project: Project, -){ - var projects: List = loadProjects() - - IconButton( - onClick = { - // Handle delete glossary action - projects = projects.filterNot { it == project } - val directory = File("src/main/resources/projects/${project.name}/") - directory.deleteRecursively() - - } - ) { - Icon(imageVector = Icons.Default.Delete, contentDescription = "Delete Project") - } -} - @Composable fun newProject( currentPage: MutableState