Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
v0.4.0 release
  • Loading branch information
ShreckYe committed Oct 24, 2024
2 parents 8e7d834 + a4c2c93 commit 4d96c30
Show file tree
Hide file tree
Showing 178 changed files with 4,438 additions and 801 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.gradle
.kotlin
build
local.properties

Expand Down
58 changes: 58 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Change log

## v0.4.0 / 2024-10-24

* fix a bug that a dependent project might crash on Android and add the Android target explicitly for all modules
* no longer publish the legacy module
* bump Kotlin to 2.0.10, Compose Multiplatform to 1.7.0, Kobweb to 0.19.2, and our Compose HTML Material to 0.4.0

### Common

* add `Arrangement.spacedBy`
* Move `LoadingState` here from [Compose HTML Material](https://github.com/huanshankeji/compose-html-material)
* add color parameters to the text composables
* rename `InlineText` to `TaglessText`
* add the `alpha` modifiers
* add a `hidden` modifier
* add the `clickable` modifier and replace `onClick` with it
* add the `PaddingValues` type
* add a `BoxWithConstraints` layout composable that's still buggy on JS DOM
* add `flex-basis: 0` to the weight modifiers on JS DOM to make them consistent with the `androidx.compose` behavior
* split the `padding` modifiers into `outerPadding` and `innerPadding`
* add the `VerticalScrollBox` and `HorizontalScrollBox` composables as (better) alternatives to the `*Scroll` modifiers

### Material 2

* revamp `TopAppBarScaffold` to take a bottom bar, a floating action bottom, and a snackbar host, and fix some of its display issues on JS DOM
* fix bugs that the action buttons don't show and their `onClick` callbacks are not passed on JS DOM
* add the `SnackbarHost` (the Material 3 snackbar is not available in Material Web yet)
* add `RadioGroupColumn` and improve `RadioRow` on JS DOM
* add a platform-specific implementation for `com.huanshankeji.compose.material2.ext.IconButton` on JS DOM that's more idiomatic, and fix a bug that in some scenarios icons are not shown, by always importing "material-icons/iconfont/material-icons.css"

### Material 3

* add the menu composables `DropdownMenu`, `DropdownMenuItem`, `ExposedDropdownMenuBox`, and `ExposedDropdownMenuWithTextField`
* add the progress indicator composables `LinearProgressIndicator` and `CircularProgressIndicator`
* fix a bug in the text fields on JS DOM that causes the caret to be reset to the start whenever the value changes if the `type` attribute is set
* make multiline text fields work on JS DOM
* add an `isInteractiveJsDom` parameter to ListItemComponents

### Navigation

* initially support navigation

### ViewModel

* initially support ViewModel which delegates to raw UI state on Compose HTML / JS DOM

### Demo

* make the demo UI friendly on mobile

## v0.3.0 / 2024-5-10

Support Material 3. See the Updated README.md for more details.

## v0.2.0 / 2024-4-17

The project now depends on Kobweb Silk on Kotlin/JS (Compose HTML) and there is a universal multiplatform interface for `Modifier`, scopes, etc. akin to those in `androidx.compose`. Obsolete code including `ModifierOrAttrsScope` is moved to a legacy module.
64 changes: 55 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Compose Multiplatform Material: unified Compose Multiplatform common extensions and Material wrappers for `androidx.compose` and Compose HTML
# Compose Multiplatform Material (better name pending): unified Compose Multiplatform common extensions and Material wrappers for `androidx.compose` and Compose HTML

[![Maven Central](https://img.shields.io/maven-central/v/com.huanshankeji/compose-multiplatform-material3)](https://search.maven.org/search?q=g:com.huanshankeji%20AND%20a:compose-multiplatform-*)
![Kotlin version](https://kotlin-version.aws.icerock.dev/kotlin-version?group=com.huanshankeji&name=compose-multiplatform-material3)
Expand All @@ -21,19 +21,23 @@ This project is still in development and has not reached the stable state yet. S

##### `ext` components

- `InlineBasicText`
- `TaglessBasicText`

##### Layouts

- `Box`
- `Column` (via flexbox on JS)
- `Row` (via flexbox on JS)
- `Box` (based on Kobweb)
- `Column` (via flexbox on JS, based on Kobweb)
- `Row` (via flexbox on JS, based on Kobweb)
- `Spacer`

###### `ext` layouts

- `BoxWithConstraints`

##### Lazy

- `LazyColumn`
- `LazyRow`
- `LazyColumn` (via flexbox on JS, based on Kobweb)
- `LazyRow` (via flexbox on JS, based on Kobweb)

#### Material 2 components

Expand All @@ -43,6 +47,7 @@ This project is still in development and has not reached the stable state yet. S
- `Divider` (not working properly on JS yet)
- `Icon`
- `IconButton`
- `Snackbar` (inconsistent, not recommended), `SnackBarHost` (recommended)
- `Switch`
- `Text`

Expand All @@ -52,7 +57,7 @@ This project is still in development and has not reached the stable state yet. S
- `IconButton`
- `RadioRow`, `RadioGroupRow`
- `SwitchWithLabel`
- `MaterialText`, `InlineText`
- `MaterialText`, `TaglessText`
- `TextField`, `OutlinedTextField`
- `TopAppBarScaffold`

Expand All @@ -68,17 +73,20 @@ This project is still in development and has not reached the stable state yet. S
- `FloatingActionButton`, `SmallFloatingActionButton`, `LargeFloatingActionButton`, `ExtendedFloatingActionButton`
- `Icon`
- `IconButton`, `IconToggleButton`, `FilledIconButton`, `FilledIconToggleButton`, `FilledTonalIconButton`, `FilledTonalIconToggleButton`, `OutlinedIconButton`, `OutlinedIconToggleButton`
- `LinearProgressIndicator`, `CircularProgressIndicator`
- `Switch`
- `Text`

##### `ext` components

- `Button` (`FilledButton`), `ElevatedButton`, `FilledTonalButton`, `OutlinedButton`, `TextButton`
- `Card` (`FilledCard`), `ElevatedCard`, `OutlinedCard`
- `DropdownMenu`, `DropdownMenuItem`
- `ExposedDropdownMenuBox`, `ExposedDropdownMenuBoxScope.ExposedDropdownMenuBoxTextField`, `ExposedDropdownMenuBoxScope.ExposedDropdownMenu`, `ExposedDropdownMenuWithTextField`
- `FloatingActionButton`, `SmallFloatingActionButton`, `LargeFloatingActionButton`, `ExtendedFloatingActionButton`
- `IconButton`, `IconToggleButton`, `FilledIconButton`, `FilledIconToggleButton`, `FilledTonalIconButton`, `FilledTonalIconToggleButton`, `OutlinedIconButton`, `OutlinedIconToggleButton`
- `NavigationBar`, `NavigationBarItem`
- `MaterialText`, `InlineText`
- `MaterialText`, `TaglessText`
- `TextField`, `OutlinedTextField`

##### `lazy.ext` components
Expand All @@ -89,8 +97,18 @@ This project is still in development and has not reached the stable state yet. S

The components in the `ext` packages don't follow the `androidx.compose` APIs exactly, but rather provide wrappers are more idiomatic and conventional on both kinds of targets, wrapping different APIs which can't be unified following the `androidx.compose` APIs.

#### About parameter names

The parameter names with suffixes such as "JsDom" or "AndroidxCommon" are platform-specific, and only apply on their respective platform(s), Compose HTML / JS DOM or
`androidx.compose` platforms.

#### Material Icons

The `com.huanshankeji.compose.material.icons.Icon` class delegates to both kinds of targets, but only a few Material Icons are added as PoC. You need to add your concrete icon implementations following the style of the existing ones in `com.huanshankeji.compose.material.icons` to use the icons you need. Track the progress of full icon support in [#4](/../../issues/4).

### Modifiers

- `alpha`
- size modifiers
- `size`, `sizeIn`, `fillMaxSize`
- `width`, `widthIn`, `fillMaxWidth`
Expand All @@ -106,6 +124,26 @@ The components in the `ext` packages don't follow the `androidx.compose` APIs ex
- `outerBorder`
- `roundedCornerBackgroundAndOuterBorder`

### Other APIs

- `Alignment`
- `Arrangement`
- `KeyboardOptions`
- `KeyboardActions`
- `PaddingValues`

### ViewModel

The ViewModel module currently supports a small subset of the Compose ViewModel APIs, and delegates to raw UI state on
Compose HTML / JS DOM. These APIs are highly experimental now.

### Navigation

The navigation module currently supports a small subset of the Compose Navigation APIs, which does not support
transition or animation on Compose HTML / JS DOM. These APIs are also highly experimental now.
See [CMP-4966](https://youtrack.jetbrains.com/issue/CMP-4966) for a bug to avoid. Also, ViewModel-related functions
are not implemented yet on Compose HTML / JS DOM.

## Add the libraries to your dependency

Maven coordinate:
Expand All @@ -114,6 +152,14 @@ Maven coordinate:
"com.huanshankeji:compose-multiplatform-$module:$version"
```

More specifically:
```kotlin
"com.huanshankeji:compose-multiplatform-common:$version"
"com.huanshankeji:compose-multiplatform-material-icons-core:$version"
"com.huanshankeji:compose-multiplatform-material2:$version"
"com.huanshankeji:compose-multiplatform-material3:$version"
```

For example, depend on the Material 3 module with Gradle:

```kotlin
Expand Down
15 changes: 9 additions & 6 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ plugins {
}

repositories {
//mavenLocal()
mavenLocal() // TODO comment out when not needed
gradlePluginPortal()
google()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
mavenCentral()
}

dependencies {
implementation(kotlin("gradle-plugin", "1.9.23"))
implementation("org.jetbrains.compose:compose-gradle-plugin:1.6.2")
implementation("com.huanshankeji.team:gradle-plugins:0.5.1")
implementation("com.android.tools.build:gradle:8.2.2")
// With Kotlin 2.0.20, a "Could not parse POM" build error occurs in the JVM projects of some dependent projects.
val kotlinVersion = "2.0.10"
implementation(kotlin("gradle-plugin", kotlinVersion))
implementation("org.jetbrains.kotlin:compose-compiler-gradle-plugin:$kotlinVersion")
implementation("org.jetbrains.compose:compose-gradle-plugin:1.7.0")
implementation("com.huanshankeji.team:gradle-plugins:0.6.0") // don't use a snapshot version in a main branch
implementation("com.android.tools.build:gradle:8.5.2")
implementation("com.huanshankeji:common-gradle-dependencies:0.8.0-20241016") // don't use a snapshot version in a main branch
}
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/Android.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
val androidSdkVersion = 34 // bump to 35 when AGP and Kotlin are bumped
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/Constants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const val FOR_COMPOSE_TARGETS_IN_TITLE = "for `androidx.compose` and Compose HTML"
const val FOR_COMPOSE_TARGETS_IN_DESCRIPTION =
"for `androidx.compose` (Android, desktop (JVM), iOS, and web (Kotlin/Wasm)) and Compose HTML"
16 changes: 7 additions & 9 deletions buildSrc/src/main/kotlin/VersionsAndDependencies.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import com.huanshankeji.CommonDependencies
import org.jetbrains.compose.ComposeBuildConfig

val projectVersion = "0.3.0"
val projectVersion = "0.4.0"

val commonDependencies = CommonDependencies()

object DependencyVersions {
const val composeMultiplatform = ComposeBuildConfig.composeVersion // for "ui-unit"
val kobweb = "0.17.3"
val huanshankejiComposeHtml = "0.3.0"
val kobweb = "0.19.2"
val huanshankejiComposeHtml = "0.4.0" // don't use a snapshot version in a main branch
val kmdc = "0.1.2"
val materialSymbols = "0.17.4"

object Androidx {
val activityCompose = "1.9.0"
val compose = "1.6.6"
}
val materialSymbols = "0.25.1"
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/common-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
kotlin("multiplatform")
kotlin("plugin.compose")
id("org.jetbrains.compose")
}

repositories {
mavenLocal()
mavenCentral()
google()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven("https://us-central1-maven.pkg.dev/varabyte-repos/public") // for Kobweb
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi

plugins {
id("common-conventions")
id("com.huanshankeji.kotlin-multiplatform-conventional-targets")
id("com.android.library")
}

kotlin {
androidTarget {
publishLibraryVariants("release", "debug")
}

// move to `common-conventions` if necessary

@OptIn(ExperimentalKotlinGradlePluginApi::class)
applyDefaultHierarchyTemplate {
common {
group("androidxCommon") {
withJvm()
withAndroidTarget()
group("ios")
withWasmJs()
}
}
}

/*
sourceSets {
val androidxCommonMain by creating { dependsOn(commonMain.get()) }
jvmMain { dependsOn(androidxCommonMain) }
iosMain { dependsOn(androidxCommonMain) }
named("wasmJsMain") { dependsOn(androidxCommonMain) }
}
*/
}

android {
namespace = group as String

compileSdk = androidSdkVersion
}
31 changes: 1 addition & 30 deletions buildSrc/src/main/kotlin/lib-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,33 +1,4 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi

plugins {
id("common-conventions")
// TODO: `id("com.android.library") version "7.2.2"`?
id("com.huanshankeji.kotlin-multiplatform-jvm-and-js-browser-conventions")
id("lib-conventions-without-publishing")
id("com.huanshankeji.kotlin-multiplatform-sonatype-ossrh-publish-conventions")
//id("com.android.library") // not used yet, the `jvm` target seems to be enough
}

kotlin {
// move to `common-conventions` if necessary

@OptIn(ExperimentalKotlinGradlePluginApi::class)
applyDefaultHierarchyTemplate {
common {
group("androidxCommon") {
withJvm()
group("ios")
withWasm()
}
}
}

/*
sourceSets {
val androidxCommonMain by creating { dependsOn(commonMain.get()) }
jvmMain { dependsOn(androidxCommonMain) }
iosMain { dependsOn(androidxCommonMain) }
named("wasmJsMain") { dependsOn(androidxCommonMain) }
}
*/
}
21 changes: 19 additions & 2 deletions compose-multiplatform-common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import com.huanshankeji.team.`Shreck Ye`
import com.huanshankeji.team.pomForTeamDefaultOpenSource
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi

plugins {
`lib-conventions`
}

kotlin {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
applyDefaultHierarchyTemplate {
common {
group("androidxCommon") {
group("androidxCommonExceptAndroid") {
withJvm()
group("ios")
withWasmJs()
}
}
withAndroidTarget()
}
}


sourceSets {
/*
Use `api`. See:
Expand All @@ -31,6 +47,7 @@ kotlin {
androidxCommonMain {
dependencies {
api(compose.foundation)
implementation(compose.ui)
}
}
jsMain {
Expand All @@ -47,8 +64,8 @@ kotlin {
publishing.publications.withType<MavenPublication> {
pomForTeamDefaultOpenSource(
project,
"Compose Multiplatform common wrappers",
"Common wrappers of components (including layouts) and styles for Compose Multiplatform on (desktop/Android and web)"
"Unified Compose Multiplatform common wrappers $FOR_COMPOSE_TARGETS_IN_TITLE",
"Common wrappers of components (including layouts) and modifiers $FOR_COMPOSE_TARGETS_IN_DESCRIPTION"
) {
`Shreck Ye`()
}
Expand Down
Loading

0 comments on commit 4d96c30

Please sign in to comment.