Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion .github/workflows/pre-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ jobs:
uses: gradle/actions/setup-gradle@v4

- name: Check formatting and assemble
run: ./gradlew spotlessCheck :uikit-core:assembleRelease :uikit-components:assembleRelease :uikit-components-foundation:assembleRelease --continue
run: >-
./gradlew spotlessCheck --continue
:uikit-core:assemble :uikit-components:assemble :uikit-components-foundation:assemble

- name: Test (JVM)
run: ./gradlew :uikit-core:jvmTest

# Both flavors compare against the same goldens in sample/src/test/snapshots.
- name: Verify screenshots (Material3 backend)
Expand All @@ -45,3 +50,26 @@ jobs:
**/build/reports/
sample/build/outputs/roborazzi/
if-no-files-found: warn

ios:
runs-on: macos-latest
if: ${{ !contains(github.event.head_commit.message, 'ci skip') }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Compile iOS and run iOS tests
run: >-
./gradlew
:uikit-core:iosSimulatorArm64Test
:uikit-components:compileKotlinIosSimulatorArm64
:uikit-components-foundation:compileKotlinIosSimulatorArm64
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ permissions:

jobs:
publish-library:
runs-on: ubuntu-latest
# iOS klibs only build on macOS.
runs-on: macos-latest
environment: release
if: ${{ !contains(github.event.head_commit.message, 'ci skip') }}
steps:
Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Defaults live in `UikitCheckboxDefaults`, `UikitRadioButtonDefaults`, `UikitButtonDefaults`,
`UikitBottomSheetDefaults` and `UikitDatePickerDefaults.Title` / `.Headline`.
- Both backends render pixel-identically; CI verifies each against the same screenshot goldens.
- Kotlin Multiplatform: all three artifacts now publish for Android, iOS (`iosArm64`, `iosSimulatorArm64`),
JVM desktop, `js` and `wasmJs`. Android consumers keep the same coordinates; Gradle module metadata picks the
Android variant.
- The Material3 backend uses androidx Material3 1.4.0 on Android (unchanged) and JetBrains Compose
Multiplatform Material3 on the other targets. The foundation backend is pure Compose Foundation everywhere.

### Changed (breaking)
- `Slider`: the `thumb`/`track`/`startThumb`/`endThumb` slot lambdas now receive the library's own
`UikitSliderState` / `UikitRangeSliderState` instead of Material3 `SliderState` / `RangeSliderState`.
- `DatePicker`: `rememberDatePickerState(selectableDates = …)` and `DatePickerState.selectableDates` now use
the library's own `SelectableDates` interface (with `UikitDatePickerDefaults.AllDates` / `.YearRange`)
instead of Material3's `SelectableDates` / `DatePickerDefaults`.
- Dates are `kotlinx.datetime.LocalDate` instead of `java.time.LocalDate`: `rememberDatePickerState`,
`DatePickerState.selectedDate`, `onDateConfirm`, the `headline` slot and `UikitDatePickerDefaults.Headline`.
- Android resource ids in the date picker configuration are replaced by composable lambdas:
`TextFieldDatePickerConfiguration.leadingIcon/trailingIcon/errorIcon`, `InlineDatePickerConfiguration.icon`
(`@Composable () -> Painter`) and `ModalDatePickerConfiguration.title/confirmButtonText/cancelButtonText`
(`@Composable () -> String`). Migration:
```kotlin
// before
TextFieldDatePickerConfiguration(leadingIconRes = R.drawable.ic_calendar, /* … */)
ModalDatePickerConfiguration(titleRes = R.string.pick_date, /* … */)
rememberDatePickerState(initialSelectedDate = java.time.LocalDate.of(2026, 1, 15))
// after
TextFieldDatePickerConfiguration(leadingIcon = { painterResource(R.drawable.ic_calendar) }, /* … */)
ModalDatePickerConfiguration(title = { stringResource(R.string.pick_date) }, /* … */)
rememberDatePickerState(initialSelectedDate = kotlinx.datetime.LocalDate(2026, 1, 15))
```

### Deprecated
- `ModalBottomSheet(showHandle = …)`: use `dragHandle` (`null` hides the handle).
Expand All @@ -39,6 +60,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The foundation sliders size the thumb gap from `SliderConfiguration`, not from a custom `thumb` slot, and draw
no step ticks (the Material3 backend draws none with the current configuration either).

### Notes
- The libraries no longer enable core library desugaring themselves. kotlinx-datetime uses `java.time` on
Android, so apps with `minSdk < 26` need `coreLibraryDesugaring` enabled.
- No `iosX64` (Intel simulator) target: Compose Multiplatform 1.11 no longer publishes it.

## 0.2.0

### Added
Expand Down
32 changes: 27 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,27 @@

[![Maven Central][mavenbadge-svg]][mavencentral]

A library of commonly used UI components built on [Jetpack Compose](https://developer.android.com/compose).
A library of commonly used UI components built on [Jetpack Compose](https://developer.android.com/compose)
and [Compose Multiplatform](https://www.jetbrains.com/compose-multiplatform/).

| Target | Compose | Material3 backend uses |
|---|---|---|
| Android | Jetpack Compose | androidx Material3 |
| iOS (`iosArm64`, `iosSimulatorArm64`) | Compose Multiplatform | Compose Multiplatform Material3 |
| JVM desktop | Compose Multiplatform | Compose Multiplatform Material3 |
| Web (`js`, `wasmJs`) | Compose Multiplatform | Compose Multiplatform Material3 |

## Usage

Add the dependency for **one** backend (see [Choose a backend](#choose-a-backend)):
Add the dependency for **one** backend (see [Choose a backend](#choose-a-backend)) — to an Android module's
`dependencies`, or to `commonMain.dependencies` in a Kotlin Multiplatform module:
```groovy
implementation "ru.kode.uikit:uikit-components:$version" // Material3 backend
// or
implementation "ru.kode.uikit:uikit-components-foundation:$version" // Compose Foundation backend
```
Android apps with `minSdk < 26` need [core library desugaring](https://developer.android.com/studio/write/java8-support#library-desugaring)
enabled: dates are `kotlinx.datetime.LocalDate`, which uses `java.time` on Android.
Set up the configuration. It's best to do this as high in the component hierarchy as possible
(app theme, Activity):
```kotlin
Expand All @@ -26,13 +37,24 @@ CompositionLocalProvider(
```
That completes the setup — you can now use any of the components.

Icons and texts in the date picker configuration are composable lambdas, so they work with any resource system:
```kotlin
// Android resources
TextFieldDatePickerConfiguration(leadingIcon = { painterResource(R.drawable.ic_calendar) }, /* … */)
ModalDatePickerConfiguration(title = { stringResource(R.string.pick_date) }, /* … */)
// Compose Multiplatform resources (org.jetbrains.compose.resources)
TextFieldDatePickerConfiguration(leadingIcon = { painterResource(Res.drawable.ic_calendar) }, /* … */)
ModalDatePickerConfiguration(title = { stringResource(Res.string.pick_date) }, /* … */)
```
The library itself does not depend on Compose Multiplatform resources.

## Choose a backend
The library ships as three artifacts:

| Artifact | Contains | Depends on |
|---|---|---|
| `uikit-core` | configuration, shared state types, `TextField`, `TextFieldArea`, `PageIndicator`, shimmer | Compose UI/Foundation |
| `uikit-components` | Material3 backend: `Button`, `Checkbox`, `RadioButton`, sliders, `DatePicker`, `ModalBottomSheet` | `uikit-core`, Material3 |
| `uikit-core` | configuration, shared state types, `TextField`, `TextFieldArea`, `PageIndicator`, shimmer | Compose UI/Foundation, kotlinx-datetime |
| `uikit-components` | Material3 backend: `Button`, `Checkbox`, `RadioButton`, sliders, `DatePicker`, `ModalBottomSheet` | `uikit-core`, Material3 (androidx on Android, Compose Multiplatform elsewhere) |
| `uikit-components-foundation` | the same components, drawn with Compose Foundation | `uikit-core`, `material-ripple` |

Both backends expose the same API in `ru.kode.uikit.components`, so switching is a one-line dependency change.
Expand Down Expand Up @@ -97,7 +119,7 @@ Releases run automatically through GitHub Actions (`.github/workflows/release.ym
git tag 0.1.3
git push origin 0.1.3
```
The workflow runs `./gradlew publishAndReleaseToMavenCentral`. It requires the following secrets in the
The workflow runs `./gradlew publishAndReleaseToMavenCentral` on macOS (iOS klibs only build there). It requires the following secrets in the
`release` environment: `NEXUS_USERTOKEN_NAME`, `NEXUS_USERTOKEN_PASSWORD`, `SIGNING_KEY_ID`,
`SIGNING_PASSWORD`, `SIGNING_SECRET_KEY_RING_FILE_BASE64`.

Expand Down
11 changes: 2 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
alias(libs.plugins.kotlinCompose) apply false
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.androidKmpLibrary) apply false
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.vanniktech.maven.publish) apply false
Expand Down Expand Up @@ -55,12 +54,6 @@ spotless {
}

subprojects {
tasks.withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}

pluginManager.withPlugin("com.vanniktech.maven.publish") {
configure<MavenPublishBaseExtension> {
publishToMavenCentral()
Expand Down
16 changes: 15 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ agp = "9.2.1"
coroutines = "1.11.0"
compose = "1.11.4"
composeMaterial3 = "1.4.0"
# JetBrains Compose Multiplatform 1.11.x = Jetpack Compose 1.11; CMP material3 1.9.0 = androidx material3 1.4.0.
cmp = "1.11.1"
cmpMaterial3 = "1.9.0"
kotlinxDatetime = "0.7.1"
androidxAnnotation = "1.9.1"
spotless = "8.8.0"
ktlint = "1.8.0"
androidJdkDesugar = "2.1.5"
Expand All @@ -24,6 +29,14 @@ compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "
compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" }
compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "composeMaterial3" }
compose-material-ripple = { module = "androidx.compose.material:material-ripple", version.ref = "compose" }
cmp-ui = { module = "org.jetbrains.compose.ui:ui", version.ref = "cmp" }
cmp-runtime = { module = "org.jetbrains.compose.runtime:runtime", version.ref = "cmp" }
cmp-foundation = { module = "org.jetbrains.compose.foundation:foundation", version.ref = "cmp" }
cmp-material-ripple = { module = "org.jetbrains.compose.material:material-ripple", version.ref = "cmp" }
cmp-material3 = { module = "org.jetbrains.compose.material3:material3", version.ref = "cmpMaterial3" }
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinxDatetime" }
androidx-annotation = { module = "androidx.annotation:annotation", version.ref = "androidxAnnotation" }
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
android-jdk-desugar = { module = "com.android.tools:desugar_jdk_libs", version.ref = "androidJdkDesugar" }
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
showkase = { module = "com.airbnb.android:showkase", version.ref = "showkase" }
Expand All @@ -47,8 +60,9 @@ compose = [
]

[plugins]
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
androidKmpLibrary = { id = "com.android.kotlin.multiplatform.library", version.ref = "agp" }
kotlinCompose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
androidApplication = { id = "com.android.application", version.ref = "agp" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.DpSize
Expand Down Expand Up @@ -211,9 +213,9 @@ private fun previewSliderConfiguration() = SliderConfiguration(

private fun previewDatePickerConfiguration() = DatePickerConfiguration(
textField = TextFieldDatePickerConfiguration(
leadingIconRes = android.R.drawable.ic_menu_my_calendar,
trailingIconRes = android.R.drawable.arrow_down_float,
errorIconRes = android.R.drawable.ic_dialog_alert,
leadingIcon = { painterResource(android.R.drawable.ic_menu_my_calendar) },
trailingIcon = { painterResource(android.R.drawable.arrow_down_float) },
errorIcon = { painterResource(android.R.drawable.ic_dialog_alert) },
shape = PreviewTokens.fieldShape,
contentPadding = PaddingValues(horizontal = 16.dp, vertical = 14.dp),
textStyle = PreviewTokens.bodyStyle,
Expand Down Expand Up @@ -241,17 +243,17 @@ private fun previewDatePickerConfiguration() = DatePickerConfiguration(
disabledTrailingIconColor = PreviewTokens.disabled,
),
inline = InlineDatePickerConfiguration(
iconRes = android.R.drawable.ic_menu_my_calendar,
icon = { painterResource(android.R.drawable.ic_menu_my_calendar) },
textStyle = PreviewTokens.bodyStyle,
textColor = PreviewTokens.onSurface,
disabledTextColor = PreviewTokens.disabled,
iconColor = PreviewTokens.primary,
disabledIconColor = PreviewTokens.disabled,
),
modal = ModalDatePickerConfiguration(
titleRes = android.R.string.untitled,
confirmButtonTextRes = android.R.string.ok,
cancelButtonTextRes = android.R.string.cancel,
title = { stringResource(android.R.string.untitled) },
confirmButtonText = { stringResource(android.R.string.ok) },
cancelButtonText = { stringResource(android.R.string.cancel) },
bottomButtonsTextStyle = PreviewTokens.labelStyle,
containerColor = PreviewTokens.surface,
titleContentColor = PreviewTokens.onSurfaceVariant,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.airbnb.android.showkase.annotation.ShowkaseComposable
import kotlinx.datetime.LocalDate
import ru.kode.uikit.components.TextFieldDatePicker
import ru.kode.uikit.components.rememberDatePickerState
import ru.kode.uikit.sample.PreviewTheme
import java.time.LocalDate

private const val GROUP = "Date"

// Fixed date keeps screenshots stable across days.
internal val PreviewDate: LocalDate = LocalDate.of(2026, 1, 15)
internal val PreviewDate: LocalDate = LocalDate(2026, 1, 15)

@ShowkaseComposable(name = "TextFieldDatePicker — states", group = GROUP)
@Preview
Expand Down
59 changes: 34 additions & 25 deletions uikit-components-foundation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,39 +1,48 @@
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl

plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidKmpLibrary)
alias(libs.plugins.kotlinCompose)
alias(libs.plugins.androidLibrary)
alias(libs.plugins.vanniktech.maven.publish)
}

android {
namespace = "ru.kode.uikit.components.foundation"
compileSdk = 36
kotlin {
jvmToolchain(17)

defaultConfig {
android {
namespace = "ru.kode.uikit.components.foundation"
compileSdk = 36
minSdk = 21
aarMetadata {
minCompileSdk = 21
}
val versionName: String by project
version = versionName
}
jvm()
iosArm64()
iosSimulatorArm64()
js { browser { testTask { enabled = false } } }

buildFeatures {
compose = true
}
@OptIn(ExperimentalWasmDsl::class)
wasmJs { browser { testTask { enabled = false } } }

compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
// Every non-Android target shares the plain sheet dialog (nonAndroidMain).
applyDefaultHierarchyTemplate {
common {
group("nonAndroid") {
withJvm()
withIos()
withJs()
withWasmJs()
}
}
}

kotlin {
jvmToolchain(17)
sourceSets {
commonMain.dependencies {
api(project(":uikit-core"))
implementation(libs.cmp.material.ripple)
implementation(libs.androidx.annotation)
}
androidMain.dependencies {
implementation(libs.compose.material.ripple)
}
}
}

dependencies {
api(project(":uikit-core"))
implementation(libs.compose.material.ripple)
coreLibraryDesugaring(libs.android.jdk.desugar)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ru.kode.uikit.components.internal

import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.text.PlatformTextStyle
import androidx.compose.ui.window.DialogProperties
import androidx.compose.ui.window.DialogWindowProvider

@Suppress("DEPRECATION")
internal actual val NoFontPaddingTextStyle: PlatformTextStyle? = PlatformTextStyle(includeFontPadding = false)

internal actual fun sheetDialogProperties() = DialogProperties(
usePlatformDefaultWidth = false,
dismissOnClickOutside = false,
decorFitsSystemWindows = false,
)

// Match the Material3 sheet window: full-screen, no platform dim (the sheet's scrim is the only dim).
@Composable
internal actual fun SheetDialogWindowSetup() {
val dialogWindow = (LocalView.current.parent as? DialogWindowProvider)?.window
SideEffect {
dialogWindow?.setDimAmount(0f)
dialogWindow?.setLayout(MATCH_PARENT, MATCH_PARENT)
}
}
Loading
Loading