Sonar lint on Home.kt

main
CAPEL Maxime 2023-12-21 12:37:15 +01:00
parent a05e2c5e7c
commit b42780ac92
1 changed files with 41 additions and 32 deletions

View File

@ -28,10 +28,8 @@ fun homePage(
val appState = AppState
val noFileSnackbarVisibleState = remember { mutableStateOf(false) }
var isCompareClicked by remember { mutableStateOf(false) }
var selectedGlossary by remember { mutableStateOf<Glossary?>(null) }
if (!isCompareClicked && selectedGlossary == null) {
// Utilisez un Box pour placer le drapeau en haut à droite
Box(
@ -88,7 +86,6 @@ fun homePage(
onClick = {
if (mostUsedWordList.isEmpty()) {
noFileSnackbarVisibleState.value = true
println("Veuillez d'abord importer un fichier")
return@Button
} else {
isCompareClicked = true
@ -137,7 +134,6 @@ fun homePage(
"Comparer" -> {
if (mostUsedWordList.isEmpty()) {
noFileSnackbarVisibleState.value = true
println("Veuillez d'abord importer un fichier")
return@dropdownButtonComponent
} else {
isCompareClicked = true
@ -149,40 +145,53 @@ fun homePage(
var selectedProject by remember { mutableStateOf<Project?>(null) }
if (isCompareClicked && selectedProject == null && selectedGlossary == null) {
projectList(
projects = loadProjects(),
onProjectSelected = { project ->
selectedProject = project
appState.selectedProject = selectedProject
println("selectedProject = $selectedProject")
},
onBackClick = { isCompareClicked = false; selectedGlossary = null; selectedProject = null }
)
} else if (isCompareClicked && selectedGlossary == null) {
glossaryList(
glossaries = loadGlossaries(appState.selectedProject!!),
onGlossarySelected = { glossary ->
selectedGlossary = glossary
println("selectedGlossary = $selectedGlossary")
},
onBackClick = { isCompareClicked = false; selectedGlossary = null; selectedProject = null }
)
} else if (isCompareClicked) {
selectedGlossary?.let {
compareResults(
glossaryWords = loadDatasFromFile(it.jsonFilePath),
codeWords = mostUsedWordList.keys.toList(),
onBackClick = { isCompareClicked = false; selectedGlossary = null; selectedProject = null }
when {
isCompareClicked && selectedProject == null && selectedGlossary == null -> {
projectList(
projects = loadProjects(),
onProjectSelected = { project ->
selectedProject = project
appState.selectedProject = selectedProject
},
onBackClick = {
isCompareClicked = false
selectedGlossary = null
selectedProject = null
}
)
}
isCompareClicked && selectedGlossary == null -> {
glossaryList(
glossaries = loadGlossaries(appState.selectedProject!!),
onGlossarySelected = { glossary ->
selectedGlossary = glossary
},
onBackClick = {
isCompareClicked = false
selectedGlossary = null
selectedProject = null
}
)
}
isCompareClicked -> {
selectedGlossary?.let {
compareResults(
glossaryWords = loadDatasFromFile(it.jsonFilePath),
codeWords = mostUsedWordList.keys.toList(),
onBackClick = {
isCompareClicked = false
selectedGlossary = null
selectedProject = null
}
)
}
}
}
}
@Composable
@Composable
fun glossaryList(glossaries: List<Glossary>, onGlossarySelected: (Glossary) -> Unit, onBackClick: () -> Unit) {
Column(
modifier = Modifier.fillMaxSize(),