Add table for parsed word
parent
3c3a29896f
commit
3e88d7b888
|
@ -267,6 +267,9 @@ fun app() {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
"occurrence" -> {
|
||||||
|
parsedWordsTable(mostUsedWordList, onBackClick = { currentPage.value = "choixLangage" })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isJavaScriptFileSelected) {
|
if (isJavaScriptFileSelected) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
|
@ -285,7 +288,7 @@ fun app() {
|
||||||
onClick = {
|
onClick = {
|
||||||
// Handle the confirm button action
|
// Handle the confirm button action
|
||||||
isJavaScriptFileSelected = false
|
isJavaScriptFileSelected = false
|
||||||
currentPage.value = "accueil"
|
currentPage.value = "occurrence"
|
||||||
},
|
},
|
||||||
colors = ButtonDefaults.buttonColors(
|
colors = ButtonDefaults.buttonColors(
|
||||||
backgroundColor = customRedColor,
|
backgroundColor = customRedColor,
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.border
|
||||||
|
import androidx.compose.foundation.layout.*
|
||||||
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
|
import androidx.compose.foundation.lazy.items
|
||||||
|
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
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun parsedWordsTable(parsedWords: Map<String, Int>, onBackClick: () -> Unit) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
verticalArrangement = Arrangement.Top,
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
Text(text = "Mots Parsés", style = MaterialTheme.typography.h3)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
// Tableau des mots parsés
|
||||||
|
LazyColumn(modifier = Modifier.padding(16.dp)) {
|
||||||
|
item {
|
||||||
|
parsedWordsHeaderRow()
|
||||||
|
}
|
||||||
|
items(parsedWords.toList()) { (word, count) ->
|
||||||
|
parsedWordsDataRow(word, count)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
Button(
|
||||||
|
onClick = { onBackClick() },
|
||||||
|
colors = androidx.compose.material.ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = customRedColor,
|
||||||
|
contentColor = Color.White
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Text("Retour")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun parsedWordsHeaderRow() {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.background(customRedColor)
|
||||||
|
.border(1.dp, Color.Black),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
listOf("Mot", "Occurrences").forEach { header ->
|
||||||
|
Text(
|
||||||
|
text = header,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
modifier = Modifier.weight(1f).padding(8.dp),
|
||||||
|
color = Color.White
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun parsedWordsDataRow(word: String, count: Int) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.background(Color.White)
|
||||||
|
.border(1.dp, Color.Black),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
val modifier = Modifier.weight(1f).padding(8.dp)
|
||||||
|
CellContent(word, modifier)
|
||||||
|
CellContent(count.toString(), modifier)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue