diff --git a/build.gradle.kts b/build.gradle.kts index 629f126..4038aba 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,6 +15,8 @@ repositories { google() } + + dependencies { // Note, if you develop a library, you should use compose.desktop.common. // compose.desktop.currentOs should be used in launcher-sourceSet @@ -41,18 +43,25 @@ dependencies { 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") - } compose.desktop { application { - mainClass = "MainKt" + mainClass = "main.MainKt" nativeDistributions { targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) - packageName = "demo" + packageName = "QualiNomme" 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" + } } } } diff --git a/src/main/kotlin/main/Home.kt b/src/main/kotlin/main/Home.kt index 4a92aca..91babdb 100644 --- a/src/main/kotlin/main/Home.kt +++ b/src/main/kotlin/main/Home.kt @@ -42,137 +42,103 @@ fun homePage( } } else { - HelpButton { - showHelpPage = true - } + if (!isCompareClicked && selectedGlossary == null) { + // 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) { - // 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)) - - 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() + Column { + Row( + horizontalArrangement = Arrangement.spacedBy(16.dp) ) { - 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) { - Snackbar( - modifier = Modifier.padding(16.dp), - action = { - buttonComponent("OK", { noFileSnackbarVisibleState.value = false }) - } - ) { - Text("Veuillez d'abord importer un fichier") - } - } - } - - // Example usage with text options - dropdownButtonComponent( - 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 + // Example usage with text options + dropdownButtonComponent( + 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(null) } + var selectedProject by remember { mutableStateOf(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(), + when { + isCompareClicked && selectedProject == null && selectedGlossary == null -> { + projectList( + projects = loadProjects(), + onProjectSelected = { project -> + selectedProject = project + appState.selectedProject = selectedProject + }, onBackClick = { isCompareClicked = false 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 + } + } }