BugFix helpButton

main
Cemal Odabasioglu 2024-01-12 14:14:19 +01:00
parent 856cd6094d
commit 7ea17ba12d
2 changed files with 128 additions and 120 deletions

View File

@ -15,6 +15,8 @@ repositories {
google() google()
} }
dependencies { dependencies {
// Note, if you develop a library, you should use compose.desktop.common. // Note, if you develop a library, you should use compose.desktop.common.
// compose.desktop.currentOs should be used in launcher-sourceSet // compose.desktop.currentOs should be used in launcher-sourceSet
@ -41,18 +43,25 @@ dependencies {
implementation("org.apache.poi:poi-ooxml:5.0.0") implementation("org.apache.poi:poi-ooxml:5.0.0")
testImplementation("org.junit.jupiter:junit-jupiter:5.8.1") testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.8.1") testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")
} }
compose.desktop { compose.desktop {
application { application {
mainClass = "MainKt" mainClass = "main.MainKt"
nativeDistributions { nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "demo" packageName = "QualiNomme"
packageVersion = "1.0.0" packageVersion = "1.0.0"
windows {
// a version for all Windows distributables
packageVersion = "1.0.0"
// a version only for the msi package
msiPackageVersion = "1.0.0"
// a version only for the exe package
exePackageVersion = "1.0.0"
}
} }
} }
} }

View File

@ -42,137 +42,103 @@ fun homePage(
} }
} else { } else {
HelpButton { if (!isCompareClicked && selectedGlossary == null) {
showHelpPage = true // Utilisez un Box pour placer le drapeau en haut à droite
} Box(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
contentAlignment = Alignment.TopEnd
) {
// Utilisez les images des drapeaux
Image(
painter = painterResource(if (languageManager.currentLanguage == Language.FRENCH) "FR.png" else "EN.png"),
contentDescription = "Language Flag",
modifier = Modifier.size(48.dp)
.clickable { languageManager.changeLanguage() }
)
}
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text("Quali'Nomme", style = MaterialTheme.typography.h3)
} Spacer(modifier = Modifier.height(16.dp))
if (!isCompareClicked && selectedGlossary == null) { Column {
// Utilisez un Box pour placer le drapeau en haut à droite Row(
Box( horizontalArrangement = Arrangement.spacedBy(16.dp)
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
contentAlignment = Alignment.TopEnd
) {
// Utilisez les images des drapeaux
Image(
painter = painterResource(if (languageManager.currentLanguage == Language.FRENCH) "FR.png" else "EN.png"),
contentDescription = "Language Flag",
modifier = Modifier.size(48.dp)
.clickable { languageManager.changeLanguage() }
)
}
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text("Quali'Nomme", style = MaterialTheme.typography.h3)
Spacer(modifier = Modifier.height(16.dp))
Column {
Row(
horizontalArrangement = Arrangement.spacedBy(16.dp)
) {
buttonComponent(languageManager.getGlossaryText(), onProjectClick)
buttonComponent(languageManager.getCodeToVerifyText(), onCodeToVerifyClick)
Button(
onClick = {
if (mostUsedWordList.isEmpty()) {
noFileSnackbarVisibleState.value = true
return@Button
} else {
isCompareClicked = true
}
},
modifier = Modifier.width(200.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
),
enabled = mostUsedWordList.isNotEmpty()
) { ) {
Text(languageManager.getCompareText()) buttonComponent(languageManager.getGlossaryText(), onProjectClick)
buttonComponent(languageManager.getCodeToVerifyText(), onCodeToVerifyClick)
Button(
onClick = {
if (mostUsedWordList.isEmpty()) {
noFileSnackbarVisibleState.value = true
return@Button
} else {
isCompareClicked = true
}
},
modifier = Modifier.width(200.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
),
enabled = mostUsedWordList.isNotEmpty()
) {
Text(languageManager.getCompareText())
}
}
}
if (noFileSnackbarVisibleState.value) {
Snackbar(
modifier = Modifier.padding(16.dp),
action = {
buttonComponent("OK", { noFileSnackbarVisibleState.value = false })
}
) {
Text("Veuillez d'abord importer un fichier")
} }
} }
} }
if (noFileSnackbarVisibleState.value) { // Example usage with text options
Snackbar( dropdownButtonComponent(
modifier = Modifier.padding(16.dp), items = listOf("Glossaire", "Code à vérifier", "Comparer")
action = { ) { selectedOption ->
buttonComponent("OK", { noFileSnackbarVisibleState.value = false }) // Handle the selected option
} when (selectedOption) {
) { "Glossaire" -> onProjectClick()
Text("Veuillez d'abord importer un fichier") "Code à vérifier" -> onCodeToVerifyClick()
} "Comparer" -> {
} if (mostUsedWordList.isEmpty()) {
} noFileSnackbarVisibleState.value = true
return@dropdownButtonComponent
// Example usage with text options } else {
dropdownButtonComponent( isCompareClicked = true
items = listOf("Glossaire", "Code à vérifier", "Comparer") }
) { selectedOption ->
// Handle the selected option
when (selectedOption) {
"Glossaire" -> onProjectClick()
"Code à vérifier" -> onCodeToVerifyClick()
"Comparer" -> {
if (mostUsedWordList.isEmpty()) {
noFileSnackbarVisibleState.value = true
return@dropdownButtonComponent
} else {
isCompareClicked = true
} }
} }
} }
} }
} var selectedProject by remember { mutableStateOf<Project?>(null) }
var selectedProject by remember { mutableStateOf<Project?>(null) }
when { when {
isCompareClicked && selectedProject == null && selectedGlossary == null -> { 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
}, },
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 = { onBackClick = {
isCompareClicked = false isCompareClicked = false
selectedGlossary = null selectedGlossary = null
@ -180,7 +146,40 @@ fun homePage(
} }
) )
} }
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
}
)
}
}
} }
HelpButton {
showHelpPage = true
}
} }
} }