Skip to content

Commit

Permalink
Merge pull request #16 from joelkanyi/master
Browse files Browse the repository at this point in the history
FIX: Table isn't quite visible when user changes to dark theme
  • Loading branch information
Breens-Mbaka authored May 27, 2024
2 parents d369b3c + 518a419 commit 8d28fc9
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 199 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import com.breens.beetablescompose.components.TableHeaderComponentWithoutColumnD
import com.breens.beetablescompose.components.TableRowComponent
import com.breens.beetablescompose.components.TableRowComponentWithoutDividers
import com.breens.beetablescompose.utils.extractMembers
import com.breens.beetablescompose.utils.lightColor
import com.breens.beetablescompose.utils.lightGray

/**
* 🐝 A Compose UI data table library.
Expand Down Expand Up @@ -61,21 +63,24 @@ inline fun <reified T : Any> BeeTablesCompose(
data: List<T>,
enableTableHeaderTitles: Boolean = true,
headerTableTitles: List<String>,
headerTitlesBorderColor: Color = Color.LightGray,
headerTitlesBorderColor: Color = lightGray(),
headerTitlesTextStyle: TextStyle = MaterialTheme.typography.bodySmall,
headerTitlesBackGroundColor: Color = Color.White,
tableRowColors: List<Color> = listOf(Color.White, Color.White),
rowBorderColor: Color = Color.LightGray,
headerTitlesBackGroundColor: Color = lightColor(),
tableRowColors: List<Color> = listOf(
lightColor(),
lightColor(),
),
rowBorderColor: Color = lightGray(),
rowTextStyle: TextStyle = MaterialTheme.typography.bodySmall,
tableElevation: Dp = 0.dp,
shape: RoundedCornerShape = RoundedCornerShape(4.dp),
borderStroke: BorderStroke = BorderStroke(
width = 1.dp,
color = Color.LightGray,
color = lightGray(),
),
disableVerticalDividers: Boolean = false,
dividerThickness: Dp = 1.dp,
horizontalDividerColor: Color = Color.LightGray,
horizontalDividerColor: Color = lightGray(),
contentAlignment: Alignment = Alignment.Center,
textAlign: TextAlign = TextAlign.Center,
tablePadding: Dp = 0.dp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ 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
import com.breens.beetablescompose.utils.darkColor
import com.breens.beetablescompose.utils.lightGray

@Composable
fun TableHeaderComponent(
Expand Down Expand Up @@ -85,9 +87,9 @@ fun TableHeaderComponentPreview() {
val titles = listOf("Team", "Home", "Away", "Points")
TableHeaderComponent(
headerTableTitles = titles,
headerTitlesBorderColor = Color.Black,
headerTitlesBorderColor = darkColor(),
headerTitlesTextStyle = MaterialTheme.typography.labelMedium,
headerTitlesBackGroundColor = Color.LightGray,
headerTitlesBackGroundColor = lightGray(),
contentAlignment = Alignment.Center,
textAlign = TextAlign.Center,
tablePadding = 0.dp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ 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
import com.breens.beetablescompose.utils.lightColor

@Composable
fun TableHeaderComponentWithoutColumnDividers(
Expand Down Expand Up @@ -91,7 +92,7 @@ fun TableHeaderComponentWithoutColumnDividersPreview() {
TableHeaderComponentWithoutColumnDividers(
headerTableTitles = titles,
headerTitlesTextStyle = MaterialTheme.typography.bodySmall,
headerTitlesBackGroundColor = Color.White,
headerTitlesBackGroundColor = lightColor(),
dividerThickness = 1.dp,
contentAlignment = Alignment.Center,
textAlign = TextAlign.Center,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ 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
import com.breens.beetablescompose.utils.lightColor
import com.breens.beetablescompose.utils.lightGray

@Composable
fun TableRowComponent(
Expand Down Expand Up @@ -87,9 +89,9 @@ fun TableRowComponentPreview() {

TableRowComponent(
data = titles,
rowBorderColor = Color.LightGray,
rowBorderColor = lightGray(),
rowTextStyle = MaterialTheme.typography.bodySmall,
rowBackGroundColor = Color.White,
rowBackGroundColor = lightColor(),
contentAlignment = Alignment.Center,
textAlign = TextAlign.Center,
tablePadding = 0.dp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ 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
import com.breens.beetablescompose.utils.lightGray

@Composable
fun TableRowComponentWithoutDividers(
Expand Down Expand Up @@ -94,9 +95,9 @@ fun TableRowComponentWithoutDividersPreview() {
TableRowComponentWithoutDividers(
data = titles,
rowTextStyle = MaterialTheme.typography.bodySmall,
rowBackGroundColor = Color.White,
rowBackGroundColor = MaterialTheme.colorScheme.background,
dividerThickness = 1.dp,
horizontalDividerColor = Color.LightGray,
horizontalDividerColor = lightGray(),
contentAlignment = Alignment.Center,
textAlign = TextAlign.Center,
tablePadding = 0.dp,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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.utils

import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable

@Composable
fun lightGray() = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.12f)

@Composable
fun darkColor() = MaterialTheme.colorScheme.onBackground

@Composable
fun lightColor() = MaterialTheme.colorScheme.background
Loading

0 comments on commit 8d28fc9

Please sign in to comment.