Added new diagram

main
Cemal Odabasioglu 2024-02-22 10:31:49 +01:00
parent a5069545bc
commit fd0ee5c776
1 changed files with 69 additions and 25 deletions

View File

@ -27,6 +27,7 @@ import androidx.compose.ui.graphics.Paint
import androidx.compose.ui.graphics.Path import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.* import androidx.compose.ui.text.*
import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
@ -45,6 +46,8 @@ fun compareResults(
val noFileSnackbarVisibleState = remember { mutableStateOf(false) } val noFileSnackbarVisibleState = remember { mutableStateOf(false) }
val scrollState = rememberLazyListState() val scrollState = rememberLazyListState()
val showTableAndLegend = remember { mutableStateOf(true) } // State to control the visibility of the table and legend val showTableAndLegend = remember { mutableStateOf(true) } // State to control the visibility of the table and legend
val showVennDiagram = remember { mutableStateOf(false) } // State to control the visibility of the Venn diagram
Column( Column(
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
@ -59,7 +62,34 @@ fun compareResults(
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
// Show the table and legend only if showTableAndLegend is true // Show the table and legend only if showTableAndLegend is true
if (showTableAndLegend.value) {
val intersectionWords = mutableListOf<String>()
Spacer(modifier = Modifier.height(16.dp))
println("glossaryWords : $glossaryWordsSet")
for (word in codeWords) {
if (word in glossaryWords.map { it.name }) {
intersectionWords.add(word)
println("inter : $word")
}
}
// Show the Venn diagram only if showTableAndLegend is false
if (!showTableAndLegend.value && showVennDiagram.value) {
IntersectionCircles(
intersectionWords,
glossaryWords,
codeWords
)
} else if (!showTableAndLegend.value && !showVennDiagram.value) {
Image(
painter = painterResource("code.png"),
contentDescription = "Venn diagram",
modifier = Modifier.size(500.dp)
)
} else if (showTableAndLegend.value && !showVennDiagram.value) {
commonWordsTable(glossaryWords, codeWords) commonWordsTable(glossaryWords, codeWords)
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
@ -76,36 +106,50 @@ fun compareResults(
} }
} }
val intersectionWords = mutableListOf<String>()
Spacer(modifier = Modifier.height(16.dp)) Column {
println("glossaryWords : $glossaryWordsSet") Row(
horizontalArrangement = Arrangement.spacedBy(16.dp)
) {
Button(
onClick = {
showTableAndLegend.value = false
showVennDiagram.value = true
}, // Toggle the value of showTableAndLegend when the button is clicked
colors = androidx.compose.material.ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) {
Text("Montrer le diagramme de Venn") // Change the button text based on the value of showTableAndLegend
}
for (word in codeWords) { Button(
if (word in glossaryWords.map { it.name }) { onClick = { showTableAndLegend.value = true
intersectionWords.add(word) showVennDiagram.value = false},
println("inter : $word") colors = androidx.compose.material.ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) {
Text("Montrer le tableau")
}
Button(
onClick = { showTableAndLegend.value = false
showVennDiagram.value = false},
colors = androidx.compose.material.ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) {
Text("Montrer le diagramme")
}
} }
} }
// Show the Venn diagram only if showTableAndLegend is false
if (!showTableAndLegend.value) {
IntersectionCircles(
intersectionWords,
glossaryWords,
codeWords
)
}
Button(
onClick = { showTableAndLegend.value = !showTableAndLegend.value }, // Toggle the value of showTableAndLegend when the button is clicked
colors = androidx.compose.material.ButtonDefaults.buttonColors(
backgroundColor = customRedColor,
contentColor = Color.White
)
) {
Text(if (showTableAndLegend.value) "Montrer le diagramme de Venn" else "Montrer le tableau") // Change the button text based on the value of showTableAndLegend
}
Button( Button(
onClick = onBackClick, onClick = onBackClick,