Alternate color for tables
parent
04ed49e551
commit
740f4de441
|
@ -152,21 +152,26 @@ var importedSuccessfully = mutableStateOf(false)
|
|||
var errorImportation = mutableStateOf(false)
|
||||
var exportedSuccessfully = mutableStateOf(false)
|
||||
|
||||
// Faire un tableau qui affiche les mots et leur définition
|
||||
@Composable
|
||||
fun glossaryTable(glossary: List<Word>) {
|
||||
val listState = rememberLazyListState()
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.height(500.dp)
|
||||
.padding(10.dp)
|
||||
) {
|
||||
LazyColumn(state = listState, modifier = Modifier.padding(16.dp)) {
|
||||
item {
|
||||
headerRow()
|
||||
}
|
||||
items(glossary) { word ->
|
||||
glossaryDataRow(word)
|
||||
LazyColumn(state = listState, modifier = Modifier.padding(16.dp)) {
|
||||
item {
|
||||
headerRow()
|
||||
}
|
||||
items(glossary) { word ->
|
||||
val backgroundColor = if (glossary.indexOf(word) % 2 == 0) {
|
||||
Color.White
|
||||
} else {
|
||||
Color.LightGray
|
||||
}
|
||||
glossaryDataRow(word = word, backgroundColor = backgroundColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -212,12 +217,12 @@ fun cellContent(text: String, modifier: Modifier = Modifier) {
|
|||
}
|
||||
|
||||
@Composable
|
||||
fun glossaryDataRow(word: Word) {
|
||||
fun glossaryDataRow(word: Word, backgroundColor: Color) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.background(Color.White)
|
||||
.border(1.dp, Color.Black), // Ajouter une bordure à chaque ligne
|
||||
.background(backgroundColor)
|
||||
.border(1.dp, Color.Black),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
val modifier = Modifier.weight(1f).padding(8.dp)
|
||||
|
|
|
@ -41,8 +41,13 @@ fun parsedWordsTable(
|
|||
item {
|
||||
parsedWordsHeaderRow()
|
||||
}
|
||||
items(parsedWords.toList()) { (word, count) ->
|
||||
parsedWordsDataRow(word, count)
|
||||
items(parsedWords.toList()) { word ->
|
||||
val backgroundColor = if (parsedWords.toList().indexOf(word) % 2 == 0) {
|
||||
Color.White
|
||||
} else {
|
||||
Color.LightGray
|
||||
}
|
||||
parsedWordsDataRow(word = word.first, count = word.second, backgroundColor = backgroundColor)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,11 +103,11 @@ fun parsedWordsHeaderRow() {
|
|||
}
|
||||
|
||||
@Composable
|
||||
fun parsedWordsDataRow(word: String, count: Int) {
|
||||
fun parsedWordsDataRow(word: String, count: Int, backgroundColor: Color) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.background(Color.White)
|
||||
.background(backgroundColor)
|
||||
.border(1.dp, Color.Black),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
|
|
Loading…
Reference in New Issue