Skip to content

Commit 4d96c30

Browse files
committed
Merge branch 'main' into release
v0.4.0 release
2 parents 8e7d834 + a4c2c93 commit 4d96c30

File tree

178 files changed

+4438
-801
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+4438
-801
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.gradle
2+
.kotlin
23
build
34
local.properties
45

CHANGELOG.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Change log
2+
3+
## v0.4.0 / 2024-10-24
4+
5+
* fix a bug that a dependent project might crash on Android and add the Android target explicitly for all modules
6+
* no longer publish the legacy module
7+
* 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
8+
9+
### Common
10+
11+
* add `Arrangement.spacedBy`
12+
* Move `LoadingState` here from [Compose HTML Material](https://github.com/huanshankeji/compose-html-material)
13+
* add color parameters to the text composables
14+
* rename `InlineText` to `TaglessText`
15+
* add the `alpha` modifiers
16+
* add a `hidden` modifier
17+
* add the `clickable` modifier and replace `onClick` with it
18+
* add the `PaddingValues` type
19+
* add a `BoxWithConstraints` layout composable that's still buggy on JS DOM
20+
* add `flex-basis: 0` to the weight modifiers on JS DOM to make them consistent with the `androidx.compose` behavior
21+
* split the `padding` modifiers into `outerPadding` and `innerPadding`
22+
* add the `VerticalScrollBox` and `HorizontalScrollBox` composables as (better) alternatives to the `*Scroll` modifiers
23+
24+
### Material 2
25+
26+
* 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
27+
* fix bugs that the action buttons don't show and their `onClick` callbacks are not passed on JS DOM
28+
* add the `SnackbarHost` (the Material 3 snackbar is not available in Material Web yet)
29+
* add `RadioGroupColumn` and improve `RadioRow` on JS DOM
30+
* 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"
31+
32+
### Material 3
33+
34+
* add the menu composables `DropdownMenu`, `DropdownMenuItem`, `ExposedDropdownMenuBox`, and `ExposedDropdownMenuWithTextField`
35+
* add the progress indicator composables `LinearProgressIndicator` and `CircularProgressIndicator`
36+
* 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
37+
* make multiline text fields work on JS DOM
38+
* add an `isInteractiveJsDom` parameter to ListItemComponents
39+
40+
### Navigation
41+
42+
* initially support navigation
43+
44+
### ViewModel
45+
46+
* initially support ViewModel which delegates to raw UI state on Compose HTML / JS DOM
47+
48+
### Demo
49+
50+
* make the demo UI friendly on mobile
51+
52+
## v0.3.0 / 2024-5-10
53+
54+
Support Material 3. See the Updated README.md for more details.
55+
56+
## v0.2.0 / 2024-4-17
57+
58+
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.

README.md

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Compose Multiplatform Material: unified Compose Multiplatform common extensions and Material wrappers for `androidx.compose` and Compose HTML
1+
# Compose Multiplatform Material (better name pending): unified Compose Multiplatform common extensions and Material wrappers for `androidx.compose` and Compose HTML
22

33
[![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-*)
44
![Kotlin version](https://kotlin-version.aws.icerock.dev/kotlin-version?group=com.huanshankeji&name=compose-multiplatform-material3)
@@ -21,19 +21,23 @@ This project is still in development and has not reached the stable state yet. S
2121

2222
##### `ext` components
2323

24-
- `InlineBasicText`
24+
- `TaglessBasicText`
2525

2626
##### Layouts
2727

28-
- `Box`
29-
- `Column` (via flexbox on JS)
30-
- `Row` (via flexbox on JS)
28+
- `Box` (based on Kobweb)
29+
- `Column` (via flexbox on JS, based on Kobweb)
30+
- `Row` (via flexbox on JS, based on Kobweb)
3131
- `Spacer`
3232

33+
###### `ext` layouts
34+
35+
- `BoxWithConstraints`
36+
3337
##### Lazy
3438

35-
- `LazyColumn`
36-
- `LazyRow`
39+
- `LazyColumn` (via flexbox on JS, based on Kobweb)
40+
- `LazyRow` (via flexbox on JS, based on Kobweb)
3741

3842
#### Material 2 components
3943

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

@@ -52,7 +57,7 @@ This project is still in development and has not reached the stable state yet. S
5257
- `IconButton`
5358
- `RadioRow`, `RadioGroupRow`
5459
- `SwitchWithLabel`
55-
- `MaterialText`, `InlineText`
60+
- `MaterialText`, `TaglessText`
5661
- `TextField`, `OutlinedTextField`
5762
- `TopAppBarScaffold`
5863

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

7480
##### `ext` components
7581

7682
- `Button` (`FilledButton`), `ElevatedButton`, `FilledTonalButton`, `OutlinedButton`, `TextButton`
7783
- `Card` (`FilledCard`), `ElevatedCard`, `OutlinedCard`
84+
- `DropdownMenu`, `DropdownMenuItem`
85+
- `ExposedDropdownMenuBox`, `ExposedDropdownMenuBoxScope.ExposedDropdownMenuBoxTextField`, `ExposedDropdownMenuBoxScope.ExposedDropdownMenu`, `ExposedDropdownMenuWithTextField`
7886
- `FloatingActionButton`, `SmallFloatingActionButton`, `LargeFloatingActionButton`, `ExtendedFloatingActionButton`
7987
- `IconButton`, `IconToggleButton`, `FilledIconButton`, `FilledIconToggleButton`, `FilledTonalIconButton`, `FilledTonalIconToggleButton`, `OutlinedIconButton`, `OutlinedIconToggleButton`
8088
- `NavigationBar`, `NavigationBarItem`
81-
- `MaterialText`, `InlineText`
89+
- `MaterialText`, `TaglessText`
8290
- `TextField`, `OutlinedTextField`
8391

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

9098
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.
9199

100+
#### About parameter names
101+
102+
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
103+
`androidx.compose` platforms.
104+
105+
#### Material Icons
106+
107+
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).
108+
92109
### Modifiers
93110

111+
- `alpha`
94112
- size modifiers
95113
- `size`, `sizeIn`, `fillMaxSize`
96114
- `width`, `widthIn`, `fillMaxWidth`
@@ -106,6 +124,26 @@ The components in the `ext` packages don't follow the `androidx.compose` APIs ex
106124
- `outerBorder`
107125
- `roundedCornerBackgroundAndOuterBorder`
108126

127+
### Other APIs
128+
129+
- `Alignment`
130+
- `Arrangement`
131+
- `KeyboardOptions`
132+
- `KeyboardActions`
133+
- `PaddingValues`
134+
135+
### ViewModel
136+
137+
The ViewModel module currently supports a small subset of the Compose ViewModel APIs, and delegates to raw UI state on
138+
Compose HTML / JS DOM. These APIs are highly experimental now.
139+
140+
### Navigation
141+
142+
The navigation module currently supports a small subset of the Compose Navigation APIs, which does not support
143+
transition or animation on Compose HTML / JS DOM. These APIs are also highly experimental now.
144+
See [CMP-4966](https://youtrack.jetbrains.com/issue/CMP-4966) for a bug to avoid. Also, ViewModel-related functions
145+
are not implemented yet on Compose HTML / JS DOM.
146+
109147
## Add the libraries to your dependency
110148

111149
Maven coordinate:
@@ -114,6 +152,14 @@ Maven coordinate:
114152
"com.huanshankeji:compose-multiplatform-$module:$version"
115153
```
116154

155+
More specifically:
156+
```kotlin
157+
"com.huanshankeji:compose-multiplatform-common:$version"
158+
"com.huanshankeji:compose-multiplatform-material-icons-core:$version"
159+
"com.huanshankeji:compose-multiplatform-material2:$version"
160+
"com.huanshankeji:compose-multiplatform-material3:$version"
161+
```
162+
117163
For example, depend on the Material 3 module with Gradle:
118164

119165
```kotlin

buildSrc/build.gradle.kts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@ plugins {
33
}
44

55
repositories {
6-
//mavenLocal()
6+
mavenLocal() // TODO comment out when not needed
77
gradlePluginPortal()
88
google()
9-
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
109
mavenCentral()
1110
}
1211

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

3-
val projectVersion = "0.3.0"
4+
val projectVersion = "0.4.0"
5+
6+
val commonDependencies = CommonDependencies()
47

58
object DependencyVersions {
69
const val composeMultiplatform = ComposeBuildConfig.composeVersion // for "ui-unit"
7-
val kobweb = "0.17.3"
8-
val huanshankejiComposeHtml = "0.3.0"
10+
val kobweb = "0.19.2"
11+
val huanshankejiComposeHtml = "0.4.0" // don't use a snapshot version in a main branch
912
val kmdc = "0.1.2"
10-
val materialSymbols = "0.17.4"
11-
12-
object Androidx {
13-
val activityCompose = "1.9.0"
14-
val compose = "1.6.6"
15-
}
13+
val materialSymbols = "0.25.1"
1614
}

buildSrc/src/main/kotlin/common-conventions.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
33

44
plugins {
55
kotlin("multiplatform")
6+
kotlin("plugin.compose")
67
id("org.jetbrains.compose")
78
}
89

910
repositories {
1011
mavenLocal()
1112
mavenCentral()
1213
google()
13-
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
1414
maven("https://us-central1-maven.pkg.dev/varabyte-repos/public") // for Kobweb
1515
}
1616

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
2+
3+
plugins {
4+
id("common-conventions")
5+
id("com.huanshankeji.kotlin-multiplatform-conventional-targets")
6+
id("com.android.library")
7+
}
8+
9+
kotlin {
10+
androidTarget {
11+
publishLibraryVariants("release", "debug")
12+
}
13+
14+
// move to `common-conventions` if necessary
15+
16+
@OptIn(ExperimentalKotlinGradlePluginApi::class)
17+
applyDefaultHierarchyTemplate {
18+
common {
19+
group("androidxCommon") {
20+
withJvm()
21+
withAndroidTarget()
22+
group("ios")
23+
withWasmJs()
24+
}
25+
}
26+
}
27+
28+
/*
29+
sourceSets {
30+
val androidxCommonMain by creating { dependsOn(commonMain.get()) }
31+
jvmMain { dependsOn(androidxCommonMain) }
32+
iosMain { dependsOn(androidxCommonMain) }
33+
named("wasmJsMain") { dependsOn(androidxCommonMain) }
34+
}
35+
*/
36+
}
37+
38+
android {
39+
namespace = group as String
40+
41+
compileSdk = androidSdkVersion
42+
}
Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,4 @@
1-
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
2-
31
plugins {
4-
id("common-conventions")
5-
// TODO: `id("com.android.library") version "7.2.2"`?
6-
id("com.huanshankeji.kotlin-multiplatform-jvm-and-js-browser-conventions")
2+
id("lib-conventions-without-publishing")
73
id("com.huanshankeji.kotlin-multiplatform-sonatype-ossrh-publish-conventions")
8-
//id("com.android.library") // not used yet, the `jvm` target seems to be enough
9-
}
10-
11-
kotlin {
12-
// move to `common-conventions` if necessary
13-
14-
@OptIn(ExperimentalKotlinGradlePluginApi::class)
15-
applyDefaultHierarchyTemplate {
16-
common {
17-
group("androidxCommon") {
18-
withJvm()
19-
group("ios")
20-
withWasm()
21-
}
22-
}
23-
}
24-
25-
/*
26-
sourceSets {
27-
val androidxCommonMain by creating { dependsOn(commonMain.get()) }
28-
jvmMain { dependsOn(androidxCommonMain) }
29-
iosMain { dependsOn(androidxCommonMain) }
30-
named("wasmJsMain") { dependsOn(androidxCommonMain) }
31-
}
32-
*/
334
}

0 commit comments

Comments
 (0)