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