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
11 changes: 10 additions & 1 deletion .github/workflows/pre-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@ jobs:
uses: gradle/actions/setup-gradle@v4

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

# Both flavors compare against the same goldens in sample/src/test/snapshots.
- name: Verify screenshots (Material3 backend)
run: ./gradlew :sample:verifyRoborazziMaterial3Debug

- name: Verify screenshots (foundation backend)
if: always()
run: ./gradlew :sample:verifyRoborazziFoundationDebug

- name: Upload Gradle Reports
if: always()
Expand All @@ -35,4 +43,5 @@ jobs:
name: test-reports
path: |
**/build/reports/
sample/build/outputs/roborazzi/
if-no-files-found: warn
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
echo "signing.secretKeyRingFile=${keyring_file}"
} >> "${HOME}/.gradle/gradle.properties"

# Publishes ru.kode.uikit:uikit-components to Maven Central (Central Portal) via the
# Publishes ru.kode.uikit:uikit-core, uikit-components and uikit-components-foundation to Maven Central (Central Portal) via the
# vanniktech maven-publish plugin. The version is taken from `versionName` in gradle.properties.
- name: Publish library to Maven Central
run: >-
Expand Down
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,40 @@ All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.3.0

### Added
- The library is split into three artifacts. Pick **one** backend; both depend on `uikit-core` and expose the
same API in `ru.kode.uikit.components`, so switching is a one-line dependency change:
- `uikit-core`: configuration (`UikitConfiguration`, all `*Configuration` classes), shared state types and the
Material3-free components (`TextField`, `TextFieldArea`, `PageIndicator`, shimmer).
- `uikit-components`: the Material3 backend (same artifact id as before, so existing apps just bump the version).
- `uikit-components-foundation`: a Compose Foundation backend with no Material3 or Accompanist dependency.
Adding both backends fails the build with duplicate classes.
- Slots for overriding a component's visual part on either backend:
`Checkbox(box = { state: CheckboxSlotState -> … })`, `RadioButton(indicator = { state: RadioButtonSlotState -> … })`,
`Button(loadingIndicator = { … })`, `ModalBottomSheet(dragHandle = { … } or null)`,
`TextFieldDatePicker(title = { configuration -> … }, headline = { date -> … })`.
Defaults live in `UikitCheckboxDefaults`, `UikitRadioButtonDefaults`, `UikitButtonDefaults`,
`UikitBottomSheetDefaults` and `UikitDatePickerDefaults.Title` / `.Headline`.
- Both backends render pixel-identically; CI verifies each against the same screenshot goldens.

### 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`.

### Deprecated
- `ModalBottomSheet(showHandle = …)`: use `dragHandle` (`null` hides the handle).

### Known differences
- The foundation `ModalBottomSheet` does not provide Material3's `LocalContentColor`, so Material3 `Text` without
an explicit color renders black inside it.
- 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).

## 0.2.0

### Added
Expand Down
35 changes: 30 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ A library of commonly used UI components built on [Jetpack Compose](https://deve

## Usage

Add the dependency:
Add the dependency for **one** backend (see [Choose a backend](#choose-a-backend)):
```groovy
implementation "ru.kode.uikit:uikit-components:$version"
implementation "ru.kode.uikit:uikit-components:$version" // Material3 backend
// or
implementation "ru.kode.uikit:uikit-components-foundation:$version" // Compose Foundation backend
```
Set up the configuration. It's best to do this as high in the component hierarchy as possible
(app theme, Activity):
Expand All @@ -24,6 +26,32 @@ CompositionLocalProvider(
```
That completes the setup — you can now use any of the components.

## 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-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.
Depend on exactly one: adding both fails the build with duplicate classes. `uikit-core` comes in transitively.

Pick `uikit-components` if your app already uses Material3, or you need Material3's exact look.
Pick `uikit-components-foundation` to keep Material3 out of your APK. It renders the same as the Material3
backend (CI checks both against the same screenshots); see the CHANGELOG for the few known differences.

To change one visual part without forking, override its slot. Slots work the same on both backends:
```kotlin
Checkbox(checked = checked, onClick = onClick, box = { state -> MyCheckboxBox(state.checked, state.enabled) })
ModalBottomSheet(onDismissRequest = onDismiss, dragHandle = null) { /* content */ }
```
Available slots: `Checkbox.box`, `RadioButton.indicator`, the sliders' `thumb`/`track`,
`Button.loadingIndicator`, `ModalBottomSheet.dragHandle` and `TextFieldDatePicker.title`/`headline`. Their
defaults are in `UikitCheckboxDefaults`, `UikitRadioButtonDefaults`, `UikitButtonDefaults`,
`UikitBottomSheetDefaults` and `UikitDatePickerDefaults`.

## Components
- Button
- Checkbox
Expand Down Expand Up @@ -77,8 +105,5 @@ To verify the artifact build locally: `./gradlew publishToMavenLocal`.

See [CHANGELOG.md](CHANGELOG.md) for the release history.

## TODO
- Remove the dependency on Material3

[mavenbadge-svg]: https://maven-badges.herokuapp.com/maven-central/ru.kode.uikit/uikit-components/badge.svg
[mavencentral]: https://mvnrepository.com/artifact/ru.kode.uikit/uikit-components
51 changes: 50 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

Expand All @@ -22,7 +23,7 @@ allprojects {
spotless {
kotlin {
target("**/*.kt")
targetExclude("!**/build/**/*.*")
targetExclude("**/build/**", ".claude/**")
ktlint(libs.versions.ktlint.get())
.editorConfigOverride(
mapOf(
Expand All @@ -39,6 +40,7 @@ spotless {

kotlinGradle {
target("**/*.gradle.kts")
targetExclude(".claude/**")
ktlint(libs.versions.ktlint.get())
.editorConfigOverride(
mapOf(
Expand All @@ -58,4 +60,51 @@ subprojects {
jvmTarget.set(JvmTarget.JVM_17)
}
}

pluginManager.withPlugin("com.vanniktech.maven.publish") {
configure<MavenPublishBaseExtension> {
publishToMavenCentral()
signAllPublications()

val versionName: String by project
val pomGroupId: String by project
// Artifact id = module name: uikit-core, uikit-components, uikit-components-foundation.
coordinates(pomGroupId, project.name, versionName)

pom {
val pomDescription: String by project
val pomUrl: String by project
val pomName: String by project
name.set(pomName)
description.set(pomDescription)
url.set(pomUrl)
scm {
val pomScmUrl: String by project
val pomScmConnection: String by project
val pomScmDevConnection: String by project
url.set(pomScmUrl)
connection.set(pomScmConnection)
developerConnection.set(pomScmDevConnection)
}
licenses {
license {
val pomLicenseName: String by project
val pomLicenseUrl: String by project
val pomLicenseDist: String by project
name.set(pomLicenseName)
url.set(pomLicenseUrl)
distribution.set(pomLicenseDist)
}
}
developers {
developer {
val pomDeveloperId: String by project
val pomDeveloperName: String by project
id.set(pomDeveloperId)
name.set(pomDeveloperName)
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android.useAndroidX=true
org.gradle.parallel=true
org.gradle.caching=true

versionName=0.2.0
versionName=0.3.0
pomGroupId=ru.kode.uikit
pomDescription=Shared UI-kit components
pomUrl=https://github.com/appKODE/uikit
Expand Down
22 changes: 17 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,46 @@ agp = "9.2.1"
coroutines = "1.11.0"
compose = "1.11.4"
composeMaterial3 = "1.4.0"
accompanist = "0.36.0"
spotless = "8.8.0"
ktlint = "1.8.0"
androidJdkDesugar = "2.1.5"
vanniktechMavenPublish = "0.37.0"
ksp = "2.3.9"
showkase = "1.0.5"
activityCompose = "1.13.0"
roborazzi = "1.78.0"
robolectric = "4.17"
composablePreviewScanner = "0.10.0"
junit = "4.13.2"

[libraries]
coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
compose-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose" }
compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" }
compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "composeMaterial3" }
accompanist-placeholder = { module = "com.google.accompanist:accompanist-placeholder", version.ref = "accompanist" }
compose-material-ripple = { module = "androidx.compose.material:material-ripple", version.ref = "compose" }
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" }
showkase-annotation = { module = "com.airbnb.android:showkase-annotation", version.ref = "showkase" }
showkase-processor = { module = "com.airbnb.android:showkase-processor", version.ref = "showkase" }
roborazzi = { module = "io.github.takahirom.roborazzi:roborazzi", version.ref = "roborazzi" }
roborazzi-compose = { module = "io.github.takahirom.roborazzi:roborazzi-compose", version.ref = "roborazzi" }
roborazzi-junit-rule = { module = "io.github.takahirom.roborazzi:roborazzi-junit-rule", version.ref = "roborazzi" }
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
composable-preview-scanner = { module = "io.github.sergio-sastre.ComposablePreviewScanner:android", version.ref = "composablePreviewScanner" }
junit = { module = "junit:junit", version.ref = "junit" }
compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" }
compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" }

[bundles]
compose = [
"compose-ui",
"compose-tooling",
"compose-runtime",
"compose-material3",
"accompanist-placeholder"
"compose-foundation",
"compose-material-ripple"
]

[plugins]
Expand All @@ -42,3 +53,4 @@ 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" }
vanniktech-maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktechMavenPublish" }
roborazzi = { id = "io.github.takahirom.roborazzi", version.ref = "roborazzi" }
28 changes: 27 additions & 1 deletion sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
alias(libs.plugins.androidApplication)
alias(libs.plugins.kotlinCompose)
alias(libs.plugins.ksp)
alias(libs.plugins.roborazzi)
}

android {
Expand All @@ -17,6 +18,18 @@ android {
versionName = "1.0"
}

// One sample per backend; both read/write the same goldens in src/test/snapshots, so
// verifyRoborazziFoundationDebug checks foundation against goldens recorded on material3.
flavorDimensions += "backend"
productFlavors {
create("material3") { dimension = "backend" }
create("foundation") { dimension = "backend" }
}

testOptions {
unitTests.isIncludeAndroidResources = true
}

buildFeatures {
compose = true
}
Expand All @@ -33,13 +46,26 @@ android {
}

dependencies {
implementation(project(":uikit-components"))
"material3Implementation"(project(":uikit-components"))
"foundationImplementation"(project(":uikit-components-foundation"))
implementation(libs.bundles.compose)
// The foundation backend has no M3; the sample still uses it for its own theme/scaffolding and previews.
implementation(libs.compose.material3)
implementation(libs.compose.tooling)
implementation(libs.androidx.activity.compose)

implementation(libs.showkase)
implementation(libs.showkase.annotation)
ksp(libs.showkase.processor)

coreLibraryDesugaring(libs.android.jdk.desugar)

testImplementation(libs.junit)
testImplementation(libs.robolectric)
testImplementation(libs.roborazzi)
testImplementation(libs.roborazzi.compose)
testImplementation(libs.roborazzi.junit.rule)
testImplementation(libs.composable.preview.scanner)
testImplementation(libs.compose.ui.test.junit4)
debugImplementation(libs.compose.ui.test.manifest)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,34 @@ import com.airbnb.android.showkase.annotation.ShowkaseComposable
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)

@ShowkaseComposable(name = "TextFieldDatePicker — states", group = GROUP)
@Preview
@Composable
fun TextFieldDatePickerPreview() {
PreviewTheme {
Column(verticalArrangement = Arrangement.spacedBy(16.dp)) {
TextFieldDatePicker(
state = rememberDatePickerState(),
state = rememberDatePickerState(initialSelectedDate = PreviewDate),
onDateConfirm = {},
label = "Birth date",
helper = "Tap to choose",
)
TextFieldDatePicker(
state = rememberDatePickerState(),
state = rememberDatePickerState(initialSelectedDate = PreviewDate),
onDateConfirm = {},
label = "Birth date",
helper = "Required field",
error = true,
)
TextFieldDatePicker(
state = rememberDatePickerState(),
state = rememberDatePickerState(initialSelectedDate = PreviewDate),
onDateConfirm = {},
label = "Birth date",
enabled = false,
Expand Down
Loading
Loading