diff --git a/build.gradle.kts b/build.gradle.kts index 6dddd18..629f126 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -39,9 +39,12 @@ dependencies { testImplementation("junit:junit:4.13.1") implementation("org.apache.poi:poi: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") } + compose.desktop { application { mainClass = "MainKt" diff --git a/src/main/kotlin/main/Compare.kt b/src/main/kotlin/main/Compare.kt index c54be86..0c750bd 100644 --- a/src/main/kotlin/main/Compare.kt +++ b/src/main/kotlin/main/Compare.kt @@ -6,7 +6,6 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material.Button -import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -29,15 +28,24 @@ fun compareResults( verticalArrangement = Arrangement.Top, horizontalAlignment = Alignment.CenterHorizontally ) { - Text( - text = "Le code contient ${commonWords.size}% des mots du glossaire", - style = MaterialTheme.typography.h3 - ) Spacer(modifier = Modifier.height(16.dp)) commonWordsTable(glossaryWords, codeWords) + Spacer(modifier = Modifier.height(16.dp)) + + // Légende + Column( + modifier = Modifier.fillMaxWidth(), + verticalArrangement = Arrangement.spacedBy(8.dp), + ) { + LegendItem(color = Color.Green, label = "Mot dans le glossaire et dans le code") + LegendItem(color = Color.White, label = "Mot seulement dans le glossaire") + LegendItem(color = Color.Yellow, label = "Mot seulement dans le code") + } + + Spacer(modifier = Modifier.height(16.dp)) Button( @@ -52,6 +60,7 @@ fun compareResults( } } +// Ajouter une légende au tableau @OptIn(ExperimentalFoundationApi::class) @Composable fun commonWordsTable( @@ -62,7 +71,6 @@ fun commonWordsTable( Box( modifier = Modifier - // Les 3/4 de l'écran .height(500.dp) .padding(10.dp) ) { @@ -91,6 +99,24 @@ fun commonWordsTable( } } +@Composable +fun LegendItem(color: Color, label: String) { + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(4.dp) + ) { + Box( + modifier = Modifier + .width(24.dp) + .height(14.dp) + .background(color) + .border(1.dp, Color.Black) + ) + Text(text = label) + } +} + + @Composable fun commonWordsHeaderRow() { Row( diff --git a/src/main/kotlin/main/Form.kt b/src/main/kotlin/main/Form.kt index e5c9249..b6eb60b 100644 --- a/src/main/kotlin/main/Form.kt +++ b/src/main/kotlin/main/Form.kt @@ -15,7 +15,6 @@ import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.focus.FocusRequester -import androidx.compose.ui.focus.focusOrder import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.graphics.Color import androidx.compose.ui.input.key.* @@ -225,7 +224,7 @@ fun formPage(glossary: Glossary, onCancelClick: () -> Unit) { TextField( value = secondaryContext.value, onValueChange = { secondaryContext.value = it }, - label = { Text("Contexte 2") }, + label = { Text("Contexte secondaire") }, singleLine = true, colors = TextFieldDefaults.textFieldColors( focusedIndicatorColor = customRedColor, diff --git a/src/test/kotlin/MainKtTest.kt b/src/test/kotlin/MainKtTest.kt new file mode 100644 index 0000000..9213339 --- /dev/null +++ b/src/test/kotlin/MainKtTest.kt @@ -0,0 +1,30 @@ +package main + +import org.junit.Test + +import org.junit.jupiter.api.Assertions.* + +class MainKtTest { + + @Test + fun valid_file_names() { + val validFileNames = listOf("example", "file123", "my-file_01") + + for (fileName in validFileNames) { + val isValid = isValidFileName(fileName) + assertEquals(true, isValid, "Expected $fileName to be a valid file name") + } + } + + @Test + fun invalid_file_names() { + val invalidFileNames = listOf("file name", "file*123", "my/file") + + for (fileName in invalidFileNames) { + val isValid = isValidFileName(fileName) + assertEquals(false, isValid, "Expected $fileName to be an invalid file name") + } + } + + +} \ No newline at end of file