diff --git a/BeeTablesCompose/src/main/java/com/breens/beetablescompose/BeeTablesCompose.kt b/BeeTablesCompose/src/main/java/com/breens/beetablescompose/BeeTablesCompose.kt index 2394bd1..2aece75 100644 --- a/BeeTablesCompose/src/main/java/com/breens/beetablescompose/BeeTablesCompose.kt +++ b/BeeTablesCompose/src/main/java/com/breens/beetablescompose/BeeTablesCompose.kt @@ -15,22 +15,23 @@ */ package com.breens.beetablescompose +import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedCard import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip +import androidx.compose.ui.Alignment import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.breens.beetablescompose.components.TableHeaderComponent +import com.breens.beetablescompose.components.TableHeaderComponentWithoutColumnDividers import com.breens.beetablescompose.components.TableRowComponent +import com.breens.beetablescompose.components.TableRowComponentWithoutDividers import com.breens.beetablescompose.utils.extractMembers /** @@ -49,6 +50,11 @@ import com.breens.beetablescompose.utils.extractMembers * @param rowTextStyle The text style to apply to the data cells in the table rows, by default it will be [MaterialTheme.typography.bodySmall]. * @param tableElevation The elevation of the entire table (Card elevation) in DP, by default it will be "6.dp". * @param shape The shape of the table's corners, by default it will be "RoundedCornerShape(4.dp)". + * @param disableVerticalDividers show or hide the vertical dividers between the table cells. If not set, by default the vertical dividers will be shown. + * @param horizontalDividerThickness The thickness of the horizontal dividers in DP, by default it will be "1.dp". Note: This will only be visible if [disableVerticalDividers] is set to true. + * @param horizontalDividerColor The color of the horizontal dividers, by default it will be [Color.LightGray]. Note: This will only be visible if [disableVerticalDividers] is set to true. + * @param contentAlignment The alignment of the content in the table cells, by default it will be [Alignment.Center]. + * @param textAlign The alignment of the text in the table cells, by default it will be [TextAlign.Center]. */ @Composable inline fun BeeTablesCompose( @@ -56,30 +62,56 @@ inline fun BeeTablesCompose( enableTableHeaderTitles: Boolean = true, headerTableTitles: List, headerTitlesBorderColor: Color = Color.LightGray, - headerTitlesBorderWidth: Dp = 0.4.dp, headerTitlesTextStyle: TextStyle = MaterialTheme.typography.bodySmall, headerTitlesBackGroundColor: Color = Color.White, tableRowColors: List = listOf(Color.White, Color.White), rowBorderColor: Color = Color.LightGray, - rowBorderWidth: Dp = 0.4.dp, rowTextStyle: TextStyle = MaterialTheme.typography.bodySmall, - tableElevation: Dp = 6.dp, + tableElevation: Dp = 0.dp, shape: RoundedCornerShape = RoundedCornerShape(4.dp), + borderStroke: BorderStroke = BorderStroke( + width = 1.dp, + color = Color.LightGray, + ), + disableVerticalDividers: Boolean = false, + dividerThickness: Dp = 1.dp, + horizontalDividerColor: Color = Color.LightGray, + contentAlignment: Alignment = Alignment.Center, + textAlign: TextAlign = TextAlign.Center, + tablePadding: Dp = 0.dp, + columnToIndexIncreaseWidth: Int? = null, ) { - Card(elevation = CardDefaults.cardElevation(defaultElevation = tableElevation)) { - Column( - modifier = Modifier - .clip(shape = shape) - .verticalScroll(rememberScrollState()), - ) { + OutlinedCard( + elevation = CardDefaults.cardElevation(defaultElevation = tableElevation), + shape = shape, + border = borderStroke, + ) { + Column { if (enableTableHeaderTitles) { - TableHeaderComponent( - headerTableTitles = headerTableTitles, - headerTitlesBorderColor = headerTitlesBorderColor, - headerTitlesBorderWidth = headerTitlesBorderWidth, - headerTitlesTextStyle = headerTitlesTextStyle, - headerTitlesBackGroundColor = headerTitlesBackGroundColor, - ) + if (disableVerticalDividers) { + TableHeaderComponentWithoutColumnDividers( + headerTableTitles = headerTableTitles, + headerTitlesTextStyle = headerTitlesTextStyle, + headerTitlesBackGroundColor = headerTitlesBackGroundColor, + dividerThickness = dividerThickness, + contentAlignment = contentAlignment, + textAlign = textAlign, + tablePadding = tablePadding, + columnToIndexIncreaseWidth = columnToIndexIncreaseWidth, + ) + } else { + TableHeaderComponent( + headerTableTitles = headerTableTitles, + headerTitlesBorderColor = headerTitlesBorderColor, + headerTitlesTextStyle = headerTitlesTextStyle, + headerTitlesBackGroundColor = headerTitlesBackGroundColor, + contentAlignment = contentAlignment, + textAlign = textAlign, + tablePadding = tablePadding, + dividerThickness = dividerThickness, + columnToIndexIncreaseWidth = columnToIndexIncreaseWidth, + ) + } } data.forEachIndexed { index, data -> @@ -94,13 +126,31 @@ inline fun BeeTablesCompose( tableRowColors[1] } - TableRowComponent( - data = rowData, - rowBorderColor = rowBorderColor, - rowBorderWidth = rowBorderWidth, - rowTextStyle = rowTextStyle, - rowBackGroundColor = tableRowBackgroundColor, - ) + if (disableVerticalDividers) { + TableRowComponentWithoutDividers( + data = rowData, + rowTextStyle = rowTextStyle, + rowBackGroundColor = tableRowBackgroundColor, + dividerThickness = dividerThickness, + horizontalDividerColor = horizontalDividerColor, + contentAlignment = contentAlignment, + textAlign = textAlign, + tablePadding = tablePadding, + columnToIndexIncreaseWidth = columnToIndexIncreaseWidth, + ) + } else { + TableRowComponent( + data = rowData, + rowBorderColor = rowBorderColor, + dividerThickness = dividerThickness, + rowTextStyle = rowTextStyle, + rowBackGroundColor = tableRowBackgroundColor, + contentAlignment = contentAlignment, + textAlign = textAlign, + tablePadding = tablePadding, + columnToIndexIncreaseWidth = columnToIndexIncreaseWidth, + ) + } } } } diff --git a/BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableHeaderComponent.kt b/BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableHeaderComponent.kt index ae18abb..2b9a080 100644 --- a/BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableHeaderComponent.kt +++ b/BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableHeaderComponent.kt @@ -21,6 +21,7 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -39,24 +40,30 @@ import androidx.compose.ui.unit.dp fun TableHeaderComponent( headerTableTitles: List, headerTitlesBorderColor: Color, - headerTitlesBorderWidth: Dp, headerTitlesTextStyle: TextStyle, headerTitlesBackGroundColor: Color, + contentAlignment: Alignment, + textAlign: TextAlign, + tablePadding: Dp, + columnToIndexIncreaseWidth: Int?, + dividerThickness: Dp, ) { Row( Modifier .fillMaxWidth() - .background(headerTitlesBackGroundColor), + .background(headerTitlesBackGroundColor) + .padding(horizontal = tablePadding), ) { - headerTableTitles.forEach { title -> + headerTableTitles.forEachIndexed { index, title -> + val weight = if (index == columnToIndexIncreaseWidth) 8f else 2f Box( modifier = Modifier - .weight(.3f) + .weight(weight) .border( - width = headerTitlesBorderWidth, + width = dividerThickness, color = headerTitlesBorderColor, ), - contentAlignment = Alignment.Center, + contentAlignment = contentAlignment, ) { Text( text = title, @@ -65,7 +72,7 @@ fun TableHeaderComponent( modifier = Modifier .height(38.dp) .wrapContentHeight(), - textAlign = TextAlign.Center, + textAlign = textAlign, ) } } @@ -76,33 +83,15 @@ fun TableHeaderComponent( @Preview(showBackground = true) fun TableHeaderComponentPreview() { val titles = listOf("Team", "Home", "Away", "Points") - - Row( - Modifier - .fillMaxWidth() - .background(Color.White), - ) { - titles.forEach { title -> - Box( - modifier = Modifier - .weight(.3f) - .border( - width = 0.4.dp, - color = Color.LightGray, - ), - contentAlignment = Alignment.Center, - ) { - Text( - text = title, - style = MaterialTheme.typography.bodySmall, - color = Color.Black, - overflow = TextOverflow.Ellipsis, - modifier = Modifier - .height(38.dp) - .wrapContentHeight(), - textAlign = TextAlign.Center, - ) - } - } - } + TableHeaderComponent( + headerTableTitles = titles, + headerTitlesBorderColor = Color.Black, + headerTitlesTextStyle = MaterialTheme.typography.labelMedium, + headerTitlesBackGroundColor = Color.LightGray, + contentAlignment = Alignment.Center, + textAlign = TextAlign.Center, + tablePadding = 0.dp, + columnToIndexIncreaseWidth = null, + dividerThickness = 1.dp, + ) } diff --git a/BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableHeaderComponentWithoutColumnDividers.kt b/BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableHeaderComponentWithoutColumnDividers.kt new file mode 100644 index 0000000..4eef107 --- /dev/null +++ b/BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableHeaderComponentWithoutColumnDividers.kt @@ -0,0 +1,101 @@ +/* + * Copyright 2023 Breens Mbaka + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.breens.beetablescompose.components + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.wrapContentHeight +import androidx.compose.material3.Divider +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.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.TextStyle +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp + +@Composable +fun TableHeaderComponentWithoutColumnDividers( + headerTableTitles: List, + headerTitlesTextStyle: TextStyle, + headerTitlesBackGroundColor: Color, + dividerThickness: Dp, + contentAlignment: Alignment, + textAlign: TextAlign, + tablePadding: Dp, + columnToIndexIncreaseWidth: Int?, +) { + Column { + Row( + Modifier + .fillMaxWidth() + .background(headerTitlesBackGroundColor) + .padding(horizontal = tablePadding), + ) { + headerTableTitles.forEachIndexed { index, title -> + val weight = if (index == columnToIndexIncreaseWidth) 8f else 2f + Box( + modifier = Modifier + .weight(weight), + contentAlignment = contentAlignment, + ) { + Text( + text = title, + style = headerTitlesTextStyle, + overflow = TextOverflow.Ellipsis, + modifier = Modifier + .height(38.dp) + .wrapContentHeight(), + textAlign = textAlign, + ) + } + } + } + Divider( + modifier = Modifier + .fillMaxWidth() + .height(dividerThickness) + .background(headerTitlesBackGroundColor), + ) + } +} + +@Composable +@Preview(showBackground = true) +fun TableHeaderComponentWithoutColumnDividersPreview() { + val titles = listOf("Team", "Home", "Away", "Points") + + TableHeaderComponentWithoutColumnDividers( + headerTableTitles = titles, + headerTitlesTextStyle = MaterialTheme.typography.bodySmall, + headerTitlesBackGroundColor = Color.White, + dividerThickness = 1.dp, + contentAlignment = Alignment.Center, + textAlign = TextAlign.Center, + tablePadding = 0.dp, + columnToIndexIncreaseWidth = null, + ) +} diff --git a/BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableRowComponent.kt b/BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableRowComponent.kt index dec1e79..f1212b2 100644 --- a/BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableRowComponent.kt +++ b/BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableRowComponent.kt @@ -21,6 +21,7 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -39,24 +40,30 @@ import androidx.compose.ui.unit.dp fun TableRowComponent( data: List, rowBorderColor: Color, - rowBorderWidth: Dp, rowTextStyle: TextStyle, rowBackGroundColor: Color, + contentAlignment: Alignment, + textAlign: TextAlign, + tablePadding: Dp, + columnToIndexIncreaseWidth: Int?, + dividerThickness: Dp, ) { Row( Modifier .fillMaxWidth() - .background(rowBackGroundColor), + .background(rowBackGroundColor) + .padding(tablePadding), ) { - data.forEach { title -> + data.forEachIndexed { index, title -> + val weight = if (index == columnToIndexIncreaseWidth) 8f else 2f Box( modifier = Modifier - .weight(.3f) + .weight(weight) .border( - width = rowBorderWidth, + width = dividerThickness, color = rowBorderColor, ), - contentAlignment = Alignment.Center, + contentAlignment = contentAlignment, ) { Text( text = title, @@ -64,8 +71,9 @@ fun TableRowComponent( overflow = TextOverflow.Ellipsis, modifier = Modifier .height(38.dp) - .wrapContentHeight(), - textAlign = TextAlign.Center, + .wrapContentHeight() + .padding(end = 8.dp), + textAlign = textAlign, ) } } @@ -77,32 +85,15 @@ fun TableRowComponent( fun TableRowComponentPreview() { val titles = listOf("Man Utd", "26", "7", "95") - Row( - Modifier - .fillMaxWidth() - .background(Color.White), - ) { - titles.forEach { title -> - Box( - modifier = Modifier - .weight(.3f) - .border( - width = 0.4.dp, - color = Color.LightGray, - ), - contentAlignment = Alignment.Center, - ) { - Text( - text = title, - style = MaterialTheme.typography.bodySmall, - color = Color.Black, - overflow = TextOverflow.Ellipsis, - modifier = Modifier - .height(38.dp) - .wrapContentHeight(), - textAlign = TextAlign.Center, - ) - } - } - } + TableRowComponent( + data = titles, + rowBorderColor = Color.LightGray, + rowTextStyle = MaterialTheme.typography.bodySmall, + rowBackGroundColor = Color.White, + contentAlignment = Alignment.Center, + textAlign = TextAlign.Center, + tablePadding = 0.dp, + columnToIndexIncreaseWidth = null, + dividerThickness = 1.dp, + ) } diff --git a/BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableRowComponentWithoutVerticalDividers.kt b/BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableRowComponentWithoutVerticalDividers.kt new file mode 100644 index 0000000..5ee9766 --- /dev/null +++ b/BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableRowComponentWithoutVerticalDividers.kt @@ -0,0 +1,105 @@ +/* + * Copyright 2023 Breens Mbaka + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.breens.beetablescompose.components + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.wrapContentHeight +import androidx.compose.material3.Divider +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.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.TextStyle +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp + +@Composable +fun TableRowComponentWithoutDividers( + data: List, + rowTextStyle: TextStyle, + rowBackGroundColor: Color, + dividerThickness: Dp, + horizontalDividerColor: Color, + contentAlignment: Alignment, + textAlign: TextAlign, + tablePadding: Dp, + columnToIndexIncreaseWidth: Int?, +) { + Column( + modifier = Modifier.padding(horizontal = tablePadding), + ) { + Row( + Modifier + .fillMaxWidth() + .background(rowBackGroundColor), + ) { + data.forEachIndexed { index, title -> + val weight = if (index == columnToIndexIncreaseWidth) 8f else 2f + Box( + modifier = Modifier + .weight(weight), + contentAlignment = contentAlignment, + ) { + Text( + text = title, + style = rowTextStyle, + overflow = TextOverflow.Ellipsis, + modifier = Modifier + .height(38.dp) + .wrapContentHeight() + .padding(end = 8.dp), + textAlign = textAlign, + ) + } + } + } + Divider( + modifier = Modifier + .fillMaxWidth() + .height(dividerThickness) + .background(horizontalDividerColor), + ) + } +} + +@Composable +@Preview(showBackground = true) +fun TableRowComponentWithoutDividersPreview() { + val titles = listOf("Man Utd", "26", "7", "95") + + TableRowComponentWithoutDividers( + data = titles, + rowTextStyle = MaterialTheme.typography.bodySmall, + rowBackGroundColor = Color.White, + dividerThickness = 1.dp, + horizontalDividerColor = Color.LightGray, + contentAlignment = Alignment.Center, + textAlign = TextAlign.Center, + tablePadding = 0.dp, + columnToIndexIncreaseWidth = null, + ) +} diff --git a/app/src/main/java/com/breens/beetablescompose/MainActivity.kt b/app/src/main/java/com/breens/beetablescompose/MainActivity.kt index 91abbd8..3afd623 100644 --- a/app/src/main/java/com/breens/beetablescompose/MainActivity.kt +++ b/app/src/main/java/com/breens/beetablescompose/MainActivity.kt @@ -18,12 +18,27 @@ package com.breens.beetablescompose import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material3.Checkbox +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Slider +import androidx.compose.material3.Switch +import androidx.compose.material3.Text +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.breens.beetablescompose.utils.premierLeagueTeams import com.breens.beetablescompose.utils.titles @@ -32,17 +47,215 @@ class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { - Box( - modifier = Modifier - .fillMaxSize() - .padding(14.dp), - contentAlignment = Alignment.Center, - ) { - BeeTablesCompose( - data = premierLeagueTeams, - headerTableTitles = titles, - tableRowColors = listOf(Color.White, Color(0XFFE9AB17)), - ) + var disableVerticalDividers by remember { + mutableStateOf(false) + } + var horizontalDividerThickness by remember { + mutableStateOf(0.6f) + } + + var enableHeaderTitles by remember { + mutableStateOf(false) + } + + var centerContent by remember { + mutableStateOf(false) + } + + var centerTextAlignment by remember { + mutableStateOf(false) + } + + var increaseColumnWidth by remember { + mutableStateOf(null) + } + + LazyColumn(contentPadding = PaddingValues(16.dp)) { + item { + BeeTablesCompose( + data = premierLeagueTeams, + enableTableHeaderTitles = enableHeaderTitles, + disableVerticalDividers = disableVerticalDividers, + dividerThickness = horizontalDividerThickness.dp, + columnToIndexIncreaseWidth = increaseColumnWidth?.minus(1), + headerTableTitles = titles, + headerTitlesBackGroundColor = Color(0XFFE9AB17), + tableRowColors = listOf( + MaterialTheme.colorScheme.surface, + MaterialTheme.colorScheme.surface, + ), + contentAlignment = if (centerContent) Alignment.Center else Alignment.CenterStart, + textAlign = if (centerTextAlignment) TextAlign.Center else TextAlign.Start, + ) + + Spacer(modifier = Modifier.padding(12.dp)) + } + + item { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text( + text = "Enable Table Header Titles", + style = MaterialTheme.typography.bodyMedium, + ) + Switch( + checked = enableHeaderTitles, + onCheckedChange = { + enableHeaderTitles = it + }, + ) + } + + Spacer(modifier = Modifier.padding(12.dp)) + } + item { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text( + text = "Hide Vertical Divider", + style = MaterialTheme.typography.bodyMedium, + ) + Switch( + checked = disableVerticalDividers, + onCheckedChange = { + disableVerticalDividers = it + }, + ) + } + + Spacer(modifier = Modifier.padding(8.dp)) + } + + item { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text( + text = "Divider Thickness", + style = MaterialTheme.typography.bodyMedium, + ) + + Slider(value = horizontalDividerThickness, onValueChange = { + horizontalDividerThickness = it + }) + } + } + + item { + Spacer(modifier = Modifier.padding(12.dp)) + + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text( + text = "Center Content", + style = MaterialTheme.typography.bodyMedium, + ) + Switch( + checked = centerContent, + onCheckedChange = { + centerContent = it + }, + ) + } + + Spacer(modifier = Modifier.padding(12.dp)) + } + + item { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text( + text = "Text Alignment Center", + style = MaterialTheme.typography.bodyMedium, + ) + Switch( + checked = centerTextAlignment, + onCheckedChange = { + centerTextAlignment = it + }, + ) + } + + Spacer(modifier = Modifier.padding(12.dp)) + } + + item { + Column { + Text( + text = "The Column To Increase Width", + style = MaterialTheme.typography.bodyMedium, + ) + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + Text(text = "1", style = MaterialTheme.typography.bodySmall) + Checkbox( + checked = increaseColumnWidth == 1, + onCheckedChange = { + increaseColumnWidth = if (it) 1 else null + }, + ) + } + + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + Text(text = "2", style = MaterialTheme.typography.bodySmall) + Checkbox( + checked = increaseColumnWidth == 2, + onCheckedChange = { + increaseColumnWidth = if (it) 2 else null + }, + ) + } + + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + Text(text = "3", style = MaterialTheme.typography.bodySmall) + Checkbox( + checked = increaseColumnWidth == 3, + onCheckedChange = { + increaseColumnWidth = if (it) 3 else null + }, + ) + } + + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + Text(text = "4", style = MaterialTheme.typography.bodySmall) + Checkbox( + checked = increaseColumnWidth == 4, + onCheckedChange = { + increaseColumnWidth = if (it) 4 else null + }, + ) + } + } + } } } } diff --git a/app/src/main/java/com/breens/beetablescompose/utils/Teams.kt b/app/src/main/java/com/breens/beetablescompose/utils/Teams.kt index 4260864..3049fc9 100644 --- a/app/src/main/java/com/breens/beetablescompose/utils/Teams.kt +++ b/app/src/main/java/com/breens/beetablescompose/utils/Teams.kt @@ -23,10 +23,12 @@ data class Teams( ) val premierLeagueTeams = listOf( - Teams("Arsenal", "4", "2", "14"), - Teams("Chelsea", "5", "3", "18"), - Teams("Manchester United", "6", "1", "19"), - Teams("Liverpool", "4", "4", "16"), + Teams("Manchester United", "1", "2", "14"), + Teams("Manchester City", "5", "3", "18"), + Teams("Chelsea", "22", "1", "19"), + Teams("Arsenal", "4", "4", "23"), + Teams("Liverpool", "21", "1", "23"), + Teams("Tottenham", "1", "1", "3"), // Add more teams as needed ) diff --git a/build.gradle.kts b/build.gradle.kts index aaa3032..3e51c3d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,8 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id("com.android.application") version "8.1.0-beta02" apply false + id("com.android.application") version "8.1.4" apply false id("org.jetbrains.kotlin.android") version "1.8.10" apply false - id("com.android.library") version "8.1.0-beta02" apply false + id("com.android.library") version "8.1.4" apply false id("com.diffplug.spotless") version "6.19.0" apply false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1e24ec1..924295f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Thu Jul 27 02:22:27 EAT 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists