Added legend + some tests
parent
1938a0282f
commit
8d46370f42
|
@ -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"
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue