Repository: Breens-Mbaka/Jetpack-Compose-Tables Branch: develop Commit: 0a6c23615d22 Files: 49 Total size: 84.5 KB Directory structure: gitextract_yme_lbv7/ ├── .github/ │ ├── ISSUE_TEMPLATE/ │ │ ├── bug_report.md │ │ ├── feature_request.md │ │ └── pull_request_template.md │ └── workflows/ │ └── android.yml ├── .gitignore ├── BeeTablesCompose/ │ ├── .gitignore │ ├── build.gradle.kts │ ├── consumer-rules.pro │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── breens/ │ │ └── beetablescompose/ │ │ └── ExampleInstrumentedTest.kt │ ├── main/ │ │ ├── AndroidManifest.xml │ │ └── java/ │ │ └── com/ │ │ └── breens/ │ │ └── beetablescompose/ │ │ ├── BeeTablesCompose.kt │ │ ├── components/ │ │ │ ├── TableHeaderComponent.kt │ │ │ ├── TableHeaderComponentWithoutColumnDividers.kt │ │ │ ├── TableRowComponent.kt │ │ │ └── TableRowComponentWithoutVerticalDividers.kt │ │ └── utils/ │ │ ├── ColorUtils.kt │ │ └── DataClassToList.kt │ └── test/ │ └── java/ │ └── com/ │ └── breens/ │ └── beetablescompose/ │ └── ExampleUnitTest.kt ├── README.md ├── app/ │ ├── .gitignore │ ├── build.gradle.kts │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── breens/ │ │ └── beetablescompose/ │ │ └── ExampleInstrumentedTest.kt │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── breens/ │ │ │ └── beetablescompose/ │ │ │ ├── MainActivity.kt │ │ │ ├── ui/ │ │ │ │ └── theme/ │ │ │ │ ├── Color.kt │ │ │ │ ├── Theme.kt │ │ │ │ └── Type.kt │ │ │ └── utils/ │ │ │ └── Teams.kt │ │ └── res/ │ │ ├── drawable/ │ │ │ └── ic_launcher_background.xml │ │ ├── drawable-v24/ │ │ │ └── ic_launcher_foreground.xml │ │ ├── mipmap-anydpi-v26/ │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── values/ │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── themes.xml │ │ └── xml/ │ │ ├── backup_rules.xml │ │ └── data_extraction_rules.xml │ └── test/ │ └── java/ │ └── com/ │ └── breens/ │ └── beetablescompose/ │ └── ExampleUnitTest.kt ├── build.gradle.kts ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── jitpack.yml ├── settings.gradle.kts └── spotless/ └── copyright.kt ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/ISSUE_TEMPLATE/bug_report.md ================================================ --- name: Bug report about: Create a report to help us improve title: '' labels: '' assignees: '' --- **Describe the bug** A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See error **Expected behavior** A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - OS: [e.g. iOS] - Browser [e.g. chrome, safari] - Version [e.g. 22] **Smartphone (please complete the following information):** - Device: [e.g. iPhone6] - OS: [e.g. iOS8.1] - Browser [e.g. stock browser, safari] - Version [e.g. 22] **BeeTablesCompose Library Version** - Library version: [1.0.0] **Additional context** Add any other context about the problem here. ================================================ FILE: .github/ISSUE_TEMPLATE/feature_request.md ================================================ --- name: Feature request about: Suggest an idea for this project title: '' labels: '' assignees: '' --- **Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] **Describe the solution you'd like** A clear and concise description of what you want to happen. **Describe alternatives you've considered** A clear and concise description of any alternative solutions or features you've considered. **Additional context** Add any other context or screenshots about the feature request here. ================================================ FILE: .github/ISSUE_TEMPLATE/pull_request_template.md ================================================ ### 🎯 Goal Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue. ### 🛠 Implementation details Describe the implementation details for this Pull Request. ### ✍️ Explain examples Explain examples with code for this updates. ### 🔠 Naming pull requests 1. If its a new feature: [feature/*] 2. If its a bug fix: [bugFix/*] 3. If its a documentation update: [documentation/*] ### Preparing a pull request for review 1. Before pushing your changes makes sure to run **"./gradlew spotlessCheck"** and **"./gradlewSpotlessApply"**. If there are any linting issues please fix them before creating a pull request. 2. Your pull request must pass the CI workflow before request a review to any of the maintainers, if not fix the issue first: 3. 🚨Always make a pull request against the develop branch. 4. Always have descriptive commit messages explaining what you did. 5. Always have a description for your pull request to explain what you did in depth, it will be great if you include video recording or screenshots if possible. 6. If you need help with the above please feel to reach out to me and I will help you out. ## Code reviews All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult [GitHub Help](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) for more information on using pull requests. ================================================ FILE: .github/workflows/android.yml ================================================ name: Android CI on: push: branches: [ master ] pull_request: branches: [ '*' ] jobs: lint: name: Spotless check runs-on: ubuntu-latest steps: - name: Check out code uses: actions/checkout@v3.1.0 - name: Set up JDK uses: actions/setup-java@v3.5.1 with: distribution: 'zulu' java-version: 17 - name: spotless run: ./gradlew spotlessCheck build: name: Build and Tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v3.1.0 - name: set up JDK uses: actions/setup-java@v3.5.1 with: distribution: 'zulu' java-version: 17 - name: Cache Gradle and wrapper uses: actions/cache@v2 with: path: | ~/.gradle/caches ~/.gradle/wrapper key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} restore-keys: | ${{ runner.os }}-gradle- - name: Make Gradle executable run: chmod +x ./gradlew - name: Build with Gradle run: ./gradlew --scan --stacktrace - name: Run unit tests run: | ./gradlew --scan --stacktrace \ testDebugUnitTest ================================================ FILE: .gitignore ================================================ *.iml .gradle /local.properties /.idea/caches /.idea/libraries /.idea/modules.xml /.idea/workspace.xml /.idea/navEditor.xml /.idea/assetWizardSettings.xml .DS_Store /build /captures .externalNativeBuild .cxx local.properties .idea ================================================ FILE: BeeTablesCompose/.gitignore ================================================ /build ================================================ FILE: BeeTablesCompose/build.gradle.kts ================================================ /* * 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. */ plugins { id("com.android.library") id("org.jetbrains.kotlin.android") id("maven-publish") id("org.jetbrains.kotlin.plugin.compose") } android { namespace = "com.breens.beetablescompose" compileSdk = 33 defaultConfig { minSdk = 21 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") } buildTypes { release { isMinifyEnabled = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", ) } } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = "1.8" } packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } } buildFeatures { compose = true } } dependencies { implementation("androidx.core:core-ktx:1.9.0") implementation("androidx.appcompat:appcompat:1.6.1") implementation(platform("androidx.compose:compose-bom:2023.03.00")) implementation("androidx.compose.ui:ui") implementation("androidx.compose.ui:ui-graphics") implementation("androidx.compose.ui:ui-tooling-preview") implementation("androidx.compose.material3:material3") testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00")) androidTestImplementation("androidx.compose.ui:ui-test-junit4") debugImplementation("androidx.compose.ui:ui-tooling") debugImplementation("androidx.compose.ui:ui-test-manifest") implementation(kotlin("reflect")) } afterEvaluate { publishing { publications { create("release") { from(components["release"]) groupId = "com.breens.beetablescompose" artifactId = "bee-tables-compose" version = "1.0.2" } } } } ================================================ FILE: BeeTablesCompose/consumer-rules.pro ================================================ ================================================ FILE: BeeTablesCompose/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the # proguardFiles setting in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} # Uncomment this to preserve the line number information for # debugging stack traces. #-keepattributes SourceFile,LineNumberTable # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile ================================================ FILE: BeeTablesCompose/src/androidTest/java/com/breens/beetablescompose/ExampleInstrumentedTest.kt ================================================ /* * 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 import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry import org.junit.Assert.assertEquals import org.junit.Test import org.junit.runner.RunWith /** * Instrumented test, which will execute on an Android device. * * See [testing documentation](http://d.android.com/tools/testing). */ @RunWith(AndroidJUnit4::class) class ExampleInstrumentedTest { @Test fun useAppContext() { // Context of the app under test. val appContext = InstrumentationRegistry.getInstrumentation().targetContext assertEquals("com.breens.beetablescompose.test", appContext.packageName) } } ================================================ FILE: BeeTablesCompose/src/main/AndroidManifest.xml ================================================ ================================================ FILE: BeeTablesCompose/src/main/java/com/breens/beetablescompose/BeeTablesCompose.kt ================================================ /* * 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 import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.layout.Column import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.CardDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedCard import androidx.compose.runtime.Composable 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 import com.breens.beetablescompose.utils.lightColor import com.breens.beetablescompose.utils.lightGray /** * 🐝 A Compose UI data table library. * * @param data The list of data items to display in the table. * @param enableTableHeaderTitles show or hide the table header titles. If not set, by default the table header titles will be shown. * @param headerTableTitles The list of header titles to display at the top of the table. * @param headerTitlesBorderColor The color of the border for the header titles, by default it will be [Color.LightGray]. * @param headerTitlesBorderWidth The width of the border for the header titles in DP, by default it will be "0.4.dp". * @param headerTitlesTextStyle The text style to apply to the header titles, by default it will be [MaterialTheme.typography.bodySmall]. * @param headerTitlesBackGroundColor The background color for the header titles, by default it will be [Color.White]. * @param tableRowColors The list of background colors to alternate between rows in the table, by default it will be a list of: [Color.White], [Color.White]. * @param rowBorderColor The color of the border for the table rows, by default it will be [Color.LightGray]. * @param rowBorderWidth The width of the border for the table rows in DP, by default it will be "0.4.dp". * @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( data: List, enableTableHeaderTitles: Boolean = true, headerTableTitles: List, headerTitlesBorderColor: Color = lightGray(), headerTitlesTextStyle: TextStyle = MaterialTheme.typography.bodySmall, headerTitlesBackGroundColor: Color = lightColor(), tableRowColors: List = 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 = lightGray(), ), disableVerticalDividers: Boolean = false, dividerThickness: Dp = 1.dp, horizontalDividerColor: Color = lightGray(), contentAlignment: Alignment = Alignment.Center, textAlign: TextAlign = TextAlign.Center, tablePadding: Dp = 0.dp, columnToIndexIncreaseWidth: Int? = null, ) { OutlinedCard( elevation = CardDefaults.cardElevation(defaultElevation = tableElevation), shape = shape, border = borderStroke, ) { Column { if (enableTableHeaderTitles) { 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 -> val rowData = extractMembers(data).map { it.second // getting the value from the returned Pair } // alternate background colors between rows val tableRowBackgroundColor = if (index % 2 == 0) { tableRowColors[0] } else { tableRowColors[1] } 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, ) } } } } } ================================================ FILE: BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableHeaderComponent.kt ================================================ /* * 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.border 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 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 import com.breens.beetablescompose.utils.darkColor import com.breens.beetablescompose.utils.lightGray @Composable fun TableHeaderComponent( headerTableTitles: List, headerTitlesBorderColor: Color, headerTitlesTextStyle: TextStyle, headerTitlesBackGroundColor: Color, contentAlignment: Alignment, textAlign: TextAlign, tablePadding: Dp, columnToIndexIncreaseWidth: Int?, dividerThickness: Dp, ) { 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) .border( width = dividerThickness, color = headerTitlesBorderColor, ), contentAlignment = contentAlignment, ) { Text( text = title, style = headerTitlesTextStyle, overflow = TextOverflow.Ellipsis, modifier = Modifier .height(38.dp) .wrapContentHeight(), textAlign = textAlign, ) } } } } @Composable @Preview(showBackground = true) fun TableHeaderComponentPreview() { val titles = listOf("Team", "Home", "Away", "Points") TableHeaderComponent( headerTableTitles = titles, headerTitlesBorderColor = darkColor(), headerTitlesTextStyle = MaterialTheme.typography.labelMedium, headerTitlesBackGroundColor = lightGray(), contentAlignment = Alignment.Center, textAlign = TextAlign.Center, tablePadding = 0.dp, columnToIndexIncreaseWidth = null, dividerThickness = 1.dp, ) } ================================================ FILE: BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableHeaderComponentWithoutColumnDividers.kt ================================================ /* * 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 import com.breens.beetablescompose.utils.lightColor @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 = lightColor(), dividerThickness = 1.dp, contentAlignment = Alignment.Center, textAlign = TextAlign.Center, tablePadding = 0.dp, columnToIndexIncreaseWidth = null, ) } ================================================ FILE: BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableRowComponent.kt ================================================ /* * 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.border 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 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 import com.breens.beetablescompose.utils.lightColor import com.breens.beetablescompose.utils.lightGray @Composable fun TableRowComponent( data: List, rowBorderColor: Color, rowTextStyle: TextStyle, rowBackGroundColor: Color, contentAlignment: Alignment, textAlign: TextAlign, tablePadding: Dp, columnToIndexIncreaseWidth: Int?, dividerThickness: Dp, ) { Row( Modifier .fillMaxWidth() .background(rowBackGroundColor) .padding(tablePadding), ) { data.forEachIndexed { index, title -> val weight = if (index == columnToIndexIncreaseWidth) 8f else 2f Box( modifier = Modifier .weight(weight) .border( width = dividerThickness, color = rowBorderColor, ), contentAlignment = contentAlignment, ) { Text( text = title, style = rowTextStyle, overflow = TextOverflow.Ellipsis, modifier = Modifier .height(38.dp) .wrapContentHeight() .padding(end = 8.dp), textAlign = textAlign, ) } } } } @Composable @Preview(showBackground = true) fun TableRowComponentPreview() { val titles = listOf("Man Utd", "26", "7", "95") TableRowComponent( data = titles, rowBorderColor = lightGray(), rowTextStyle = MaterialTheme.typography.bodySmall, rowBackGroundColor = lightColor(), contentAlignment = Alignment.Center, textAlign = TextAlign.Center, tablePadding = 0.dp, columnToIndexIncreaseWidth = null, dividerThickness = 1.dp, ) } ================================================ FILE: BeeTablesCompose/src/main/java/com/breens/beetablescompose/components/TableRowComponentWithoutVerticalDividers.kt ================================================ /* * 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 import com.breens.beetablescompose.utils.lightGray @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 = MaterialTheme.colorScheme.background, dividerThickness = 1.dp, horizontalDividerColor = lightGray(), contentAlignment = Alignment.Center, textAlign = TextAlign.Center, tablePadding = 0.dp, columnToIndexIncreaseWidth = null, ) } ================================================ FILE: BeeTablesCompose/src/main/java/com/breens/beetablescompose/utils/ColorUtils.kt ================================================ /* * 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 ================================================ FILE: BeeTablesCompose/src/main/java/com/breens/beetablescompose/utils/DataClassToList.kt ================================================ /* * 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 kotlin.reflect.KProperty1 import kotlin.reflect.full.primaryConstructor inline fun extractMembers(instance: T): List> { val members = mutableListOf>() // Get the primary constructor of the data class val constructor = T::class.primaryConstructor // Get the parameter names in the constructor declaration order val parameterNames = constructor?.parameters?.map { it.name } ?: emptyList() // Get all properties of the class val properties = T::class.members.filterIsInstance>() // Filter and sort properties based on constructor parameter order val sortedProperties = properties.filter { it.name in parameterNames } .sortedBy { parameterNames.indexOf(it.name) } sortedProperties.forEach { member -> val name = member.name val value = member.get(instance)?.toString() ?: "---" members.add(name to value) } return members } ================================================ FILE: BeeTablesCompose/src/test/java/com/breens/beetablescompose/ExampleUnitTest.kt ================================================ /* * 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 import org.junit.Assert.assertEquals import org.junit.Test /** * Example local unit test, which will execute on the development machine (host). * * See [testing documentation](http://d.android.com/tools/testing). */ class ExampleUnitTest { @Test fun addition_isCorrect() { assertEquals(4, 2 + 2) } } ================================================ FILE: README.md ================================================

BeeTablesCompose


License API Build Status Build Status


:bee: A Compose UI data table library which allows developers to seamless integrate visually appealing and customizable tables to their Android apps or IOS apps.


https://github.com/Breens-Mbaka/BeeTablesCompose/assets/72180010/996cb574-766e-45f8-b459-6e7245da17bc # Features 🌟 - Display tabular data with ease: The library allows you to display a list of data items in a well-organized table format. - Customizable header titles: Customize the appearance of header titles with options for border color, width, text style, and background color. - Alternating row colors: Easily set up alternating background colors for rows, enhancing the visual presentation of your data. - Styling options: Customize the appearance of table rows, including border color, width, and text style. - Table elevation: Control the elevation of the entire table with a customizable elevation value. - Rounded corners: Set the shape of the table's corners, with a default rounded corner shape for a sleek look. # Getting Started 🦺 To use the BeeTablesCompose library, follow these steps: - Add this to either your **project build.gradle** file or **setting.gradle**, depending with what version of Android Studio you are using; ```gradle repositories { ... maven(url = "https://jitpack.io") } ``` - Add the dependency: Include the library in your project's dependencies; ```gradle dependencies { implementation("com.github.Breens-Mbaka:BeeTablesCompose:1.2.0") } ``` # Usage - Import the library: Import the BeeTablesCompose function into your Compose-based project. - Prepare your data: Organize your data in a list of objects to be displayed in the table. - Define the header titles: Create a list of header titles that will be displayed at the top of the table. - Use the BeeTablesCompose function: Invoke the BeeTablesCompose function with your data and header titles as parameters to generate the data table.

# NOTE ⚠️🚨 - Before building a release APK of your app, if you have enabled minification, make sure to annotate your table data classes with @Keep. This will prevent the class from being removed at runtime. ```kotlin @Keep data class User( val name: String, val email: Int, val city: String ) ``` # Want a new shiny feature 🪩✨ - If you want to request a new feature please first read this [short guide](https://github.com/Breens-Mbaka/BeeTablesCompose/blob/master/.github/ISSUE_TEMPLATE/feature_request.md) # Want to report a bug 🐞 - If you want to report a bug please first read this [short guide](https://github.com/Breens-Mbaka/BeeTablesCompose/blob/master/.github/ISSUE_TEMPLATE/bug_report.md) # Want to contribute 🛠 - If you want to contribute please first read this [short guide](https://github.com/Breens-Mbaka/BeeTablesCompose/blob/master/.github/ISSUE_TEMPLATE/pull_request_template.md) # Find this repository useful? :heart: Support it by joining _ _[stargazers](https://github.com/Breens-Mbaka/BeeTablesCompose/stargazers)__ for this repository. :star:
Also __[follow](https://github.com/Breens-Mbaka)__ me for my next creations! 🤩

# License ```xml Designed and developed by 2024 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. ``` ================================================ FILE: app/.gitignore ================================================ /build ================================================ FILE: app/build.gradle.kts ================================================ /* * 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. */ plugins { id("com.android.application") id("org.jetbrains.kotlin.android") id("org.jetbrains.kotlin.plugin.compose") } android { namespace = "com.breens.beetablescompose" compileSdk = 33 defaultConfig { applicationId = "com.breens.beetablescompose" minSdk = 21 targetSdk = 33 versionCode = 1 versionName = "1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary = true } } buildTypes { release { isMinifyEnabled = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", ) signingConfig = signingConfigs.getByName("debug") } } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = "1.8" } packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } } buildFeatures { compose = true } } dependencies { implementation("androidx.core:core-ktx:1.9.0") implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1") implementation("androidx.activity:activity-compose:1.7.2") implementation(platform("androidx.compose:compose-bom:2023.03.00")) implementation("androidx.compose.ui:ui") implementation("androidx.compose.ui:ui-graphics") implementation("androidx.compose.ui:ui-tooling-preview") implementation("androidx.compose.material3:material3") implementation(project(":BeeTablesCompose")) testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00")) androidTestImplementation("androidx.compose.ui:ui-test-junit4") debugImplementation("androidx.compose.ui:ui-tooling") debugImplementation("androidx.compose.ui:ui-test-manifest") } ================================================ FILE: app/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the # proguardFiles setting in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} # Uncomment this to preserve the line number information for # debugging stack traces. #-keepattributes SourceFile,LineNumberTable # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile ================================================ FILE: app/src/androidTest/java/com/breens/beetablescompose/ExampleInstrumentedTest.kt ================================================ /* * 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 import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry import org.junit.Assert.assertEquals import org.junit.Test import org.junit.runner.RunWith /** * Instrumented test, which will execute on an Android device. * * See [testing documentation](http://d.android.com/tools/testing). */ @RunWith(AndroidJUnit4::class) class ExampleInstrumentedTest { @Test fun useAppContext() { // Context of the app under test. val appContext = InstrumentationRegistry.getInstrumentation().targetContext assertEquals("com.breens.beetablescompose", appContext.packageName) } } ================================================ FILE: app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: app/src/main/java/com/breens/beetablescompose/MainActivity.kt ================================================ /* * 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 import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent 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.fillMaxSize 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.Surface import androidx.compose.material3.Switch import androidx.compose.material3.Text import androidx.compose.runtime.Composable 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.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.breens.beetablescompose.ui.theme.BeeTablesComposeTheme import com.breens.beetablescompose.utils.premierLeagueTeams import com.breens.beetablescompose.utils.titles class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { BeeTablesComposeTheme { MainUi() } } } } @Composable fun MainUi(modifier: Modifier = Modifier) { Surface( color = MaterialTheme.colorScheme.background, modifier = modifier.fillMaxSize(), ) { 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, ) } 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 }, ) } } } } } } @Preview @Composable private fun MainUiPreview() { BeeTablesComposeTheme { MainUi() } } ================================================ FILE: app/src/main/java/com/breens/beetablescompose/ui/theme/Color.kt ================================================ /* * 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.ui.theme import androidx.compose.ui.graphics.Color val Purple80 = Color(0xFFD0BCFF) val PurpleGrey80 = Color(0xFFCCC2DC) val Pink80 = Color(0xFFEFB8C8) val Purple40 = Color(0xFF6650a4) val PurpleGrey40 = Color(0xFF625b71) val Pink40 = Color(0xFF7D5260) ================================================ FILE: app/src/main/java/com/breens/beetablescompose/ui/theme/Theme.kt ================================================ /* * 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.ui.theme import android.app.Activity import android.os.Build import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.MaterialTheme import androidx.compose.material3.darkColorScheme import androidx.compose.material3.dynamicDarkColorScheme import androidx.compose.material3.dynamicLightColorScheme import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable import androidx.compose.runtime.SideEffect import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalView import androidx.core.view.WindowCompat private val DarkColorScheme = darkColorScheme( primary = Purple80, secondary = PurpleGrey80, tertiary = Pink80, ) private val LightColorScheme = lightColorScheme( primary = Purple40, secondary = PurpleGrey40, tertiary = Pink40, /* Other default colors to override background = Color(0xFFFFFBFE), surface = Color(0xFFFFFBFE), onPrimary = Color.White, onSecondary = Color.White, onTertiary = Color.White, onBackground = Color(0xFF1C1B1F), onSurface = Color(0xFF1C1B1F), */ ) @Composable fun BeeTablesComposeTheme( darkTheme: Boolean = isSystemInDarkTheme(), // Dynamic color is available on Android 12+ dynamicColor: Boolean = true, content: @Composable () -> Unit, ) { val colorScheme = when { dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { val context = LocalContext.current if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) } darkTheme -> DarkColorScheme else -> LightColorScheme } val view = LocalView.current if (!view.isInEditMode) { SideEffect { val window = (view.context as Activity).window window.statusBarColor = colorScheme.primary.toArgb() WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme } } MaterialTheme( colorScheme = colorScheme, typography = Typography, content = content, ) } ================================================ FILE: app/src/main/java/com/breens/beetablescompose/ui/theme/Type.kt ================================================ /* * 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.ui.theme import androidx.compose.material3.Typography import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.sp // Set of Material typography styles to start with val Typography = Typography( bodyLarge = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Normal, fontSize = 16.sp, lineHeight = 24.sp, letterSpacing = 0.5.sp, ), /* Other default text styles to override titleLarge = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Normal, fontSize = 22.sp, lineHeight = 28.sp, letterSpacing = 0.sp ), labelSmall = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Medium, fontSize = 11.sp, lineHeight = 16.sp, letterSpacing = 0.5.sp ) */ ) ================================================ FILE: app/src/main/java/com/breens/beetablescompose/utils/Teams.kt ================================================ /* * 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 data class Teams( val name: String, val homeWins: String, val awayWins: String, val totalPoints: String, ) val premierLeagueTeams = listOf( 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 ) val titles = listOf("Team", "Home", "Away", "Points") ================================================ FILE: app/src/main/res/drawable/ic_launcher_background.xml ================================================ ================================================ FILE: app/src/main/res/drawable-v24/ic_launcher_foreground.xml ================================================ ================================================ FILE: app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml ================================================ ================================================ FILE: app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml ================================================ ================================================ FILE: app/src/main/res/values/colors.xml ================================================ #FFBB86FC #FF6200EE #FF3700B3 #FF03DAC5 #FF018786 #FF000000 #FFFFFFFF ================================================ FILE: app/src/main/res/values/strings.xml ================================================ BeeTablesCompose ================================================ FILE: app/src/main/res/values/themes.xml ================================================