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