Skip to content

Commit

Permalink
Merge pull request #5 from sunny-chung/feature/multiplatform
Browse files Browse the repository at this point in the history
#4 Compose Multiplatform
  • Loading branch information
sunny-chung authored Feb 11, 2024
2 parents 88fb69c + 2585caa commit 16b3d68
Show file tree
Hide file tree
Showing 72 changed files with 4,609 additions and 49 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@
.externalNativeBuild
.cxx
local.properties

**/build/
xcuserdata
!src/**/build/
#.idea
captures
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcodeproj/project.xcworkspace/
!*.xcworkspace/contents.xcworkspacedata
**/xcshareddata/WorkspaceSettings.xcsettings
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

8 changes: 8 additions & 0 deletions .idea/artifacts/composable_table_desktop.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/composable_table_desktop_1_2_0.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/composable_table_jvm.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/composable_table_wasm_js.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/composable_table_wasm_js_1_2_0.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/multiplatform_app_desktop.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/multiplatform_app_wasm_js.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 17 additions & 4 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 27 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Composable Table

[![JitPack Release](https://jitpack.io/v/sunny-chung/composable-table.svg)](https://jitpack.io/#sunny-chung/composable-table)
![Maven Central](https://img.shields.io/maven-central/v/io.github.sunny-chung/composable-table)

An Android Jetpack Compose library that provides a `@Composable` table
A multiplaform Jetpack Compose library that provides a `@Composable` table
with automatic layouts.

![Demo Video](media/composable-table-demo.gif)
Expand All @@ -20,21 +20,29 @@ with automatic layouts.
- Lazy cells
- Grid lines (have to be implemented by users themselves inside cells)

## Supported Platforms
- Android
- Desktop (JVM - Windows/MacOS/Linux)
- iOS
- WASM (JS)

## Setup

1. Add the JitPack maven repository.
For multiplatform:
```kotlin
repositories {
// ...
maven(url = "https://jitpack.io")
}
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.sunny-chung:composable-table:<version>")

// ...
```

2. Add this library as a dependency.
For single platform:
```kotlin
dependencies {
// ...
implementation("com.github.sunny-chung:composable-table:<version>")
implementation("io.github.sunny-chung:composable-table:<version>")
}
```

Expand All @@ -49,7 +57,16 @@ Below shows an example of minimal usage.
}
```

Please read the [demo app](demo-app/src/main/java/com/sunnychung/lib/android/composabletable/demo/ux/AppView.kt) for a practical usage example.
Please read the [demo app](demo/multiplatform-app/shared/src/commonMain/kotlin/com/sunnychung/lib/android/composabletable/demo/ux/AppView.kt) for a practical usage example.
There is a demo app for each platform.

## Migration notes
Since v1.2.0, Composable Table moves to Maven Central to provide multiplatform support.
Dependency identifier is changed from `com.github.sunny-chung:composable-table` to
`io.github.sunny-chung:composable-table`.

Users using old version can stay at v1.1.0 because no other change is introduced. You can upgrade to
v1.2.0 by changing the dependency identifier and version name to enjoy multiplatform support.

## Troubleshooting

Expand Down
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
val androidGradlePluginVersion = "8.1.0"
val kotlinVersion = "1.8.21"
val kotlinVersion = "1.9.22"
val composeVersion = "1.6.0-beta02"

id("com.android.application") version androidGradlePluginVersion apply false
id("com.android.library") version androidGradlePluginVersion apply false
kotlin("android") version kotlinVersion apply false
kotlin("plugin.serialization") version kotlinVersion apply false

kotlin("multiplatform") version kotlinVersion apply false
id("org.jetbrains.compose") version composeVersion apply false
}
72 changes: 47 additions & 25 deletions composable-table/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,51 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
id("com.android.library")
kotlin("android")
id("maven-publish")
id("sunnychung.publication")
}

group = "io.github.sunny-chung"
version = "1.2.0"

kotlin {
jvm(name = "desktop") {
jvmToolchain(17)
}

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
moduleName = "composable-table"
browser()
}

androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
publishLibraryVariants = listOf("release")
}

val iosTargets = listOf(
iosArm64(),
iosSimulatorArm64(),
iosX64(),
)

sourceSets {
val desktopMain by getting

commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
implementation(compose.ui)
}
}
}

android {
Expand All @@ -20,32 +64,10 @@ android {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.4.7"
}
}

dependencies {
implementation("androidx.compose.ui:ui:${libs.versions.jetpack.compose.get()}")
implementation("androidx.compose.foundation:foundation:${libs.versions.jetpack.compose.get()}")
}

publishing {
publications {
create<MavenPublication>("maven") {
groupId = "com.github.sunny-chung"
artifactId = "composable-table"
version = "1.1.0"

afterEvaluate {
from(components["release"])
}
}
kotlinCompilerExtensionVersion = "1.5.9"
}
}
11 changes: 11 additions & 0 deletions convention-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
}

kotlin {
jvmToolchain(17)
}
Loading

0 comments on commit 16b3d68

Please sign in to comment.