Skip to content

Compose previews#104

Merged
opatry merged 1 commit intomainfrom
compose-previews
May 5, 2025
Merged

Compose previews#104
opatry merged 1 commit intomainfrom
compose-previews

Conversation

@opatry
Copy link
Copy Markdown
Owner

@opatry opatry commented May 5, 2025

Description

  • Refactor some composable to make them preview friendly
  • Adjust some composable contract
  • Clean already defined previews & tooling not really used
  • Add previews for components & screens when possible & relevant

Note

The way to enable previews in commonMain seems to be blurry.
There are work in progress but doesn't seem to work or is partial (no @PreviewLightDark for instance or @Preview(showBackground) or @Preview(uiMode).
Using implementation(compose.components.uiToolingPreview) in commonMain allows compiling previews but they don't show up.
See https://youtrack.jetbrains.com/issue/CMP-4869

Checklist

  • I have read the CONTRIBUTING guide
  • Code compiles correctly
  • Created tests which fail without the change (if possible)
  • All tests passing

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented May 5, 2025

©️ Stale credits for :tasks-app-android

diff --git a/tasks-app-android/src/main/assets/licenses_android.json b/tasks-app-android/src/main/assets/licenses_android.json
index b790ff3..60fc796 100644
--- a/tasks-app-android/src/main/assets/licenses_android.json
+++ b/tasks-app-android/src/main/assets/licenses_android.json
@@ -202,7 +202,7 @@
"name": "The Android Open Source Project"
}
],
- "artifactVersion": "1.8.0-rc03",
+ "artifactVersion": "1.8.0",
"description": "Compose animation library",
"name": "Compose Animation",
"licenses": [
@@ -219,7 +219,7 @@
"name": "The Android Open Source Project"
}
],
- "artifactVersion": "1.8.0-rc03",
+ "artifactVersion": "1.8.0",
"description": "Animation engine and animation primitives that are the building blocks of the Compose animation library",
"name": "Compose Animation Core",
"licenses": [
@@ -236,7 +236,7 @@
"name": "The Android Open Source Project"
}
],
- "artifactVersion": "1.8.0-rc03",
+ "artifactVersion": "1.8.0",
"description": "Higher level abstractions of the Compose UI primitives. This library is design system agnostic, providing the high-level building blocks for both application and design-system developers",
"name": "Compose Foundation",
"licenses": [
@@ -253,7 +253,7 @@
"name": "The Android Open Source Project"
}
],
- "artifactVersion": "1.8.0-rc03",
+ "artifactVersion": "1.8.0",
"description": "Compose layout implementations",
"name": "Compose Layouts",
"licenses": [
@@ -314,6 +314,23 @@
"name": "The Android Open Source Project"
}
},
+ {
+ "uniqueId": "androidx.compose.material:material",
+ "developers": [
+ {
+ "name": "The Android Open Source Project"
+ }
+ ],
+ "artifactVersion": "1.6.0",
+ "description": "Compose Material Design Components library",
+ "name": "Compose Material Components",
+ "licenses": [
+ "Apache-2.0"
+ ],
+ "organization": {
+ "name": "The Android Open Source Project"
+ }
+ },
{
"uniqueId": "androidx.compose.material:material-icons-core",
"developers": [
@@ -355,7 +372,7 @@
"name": "The Android Open Source Project"
}
],
- "artifactVersion": "1.8.0-rc03",
+ "artifactVersion": "1.8.0",
"description": "Tree composition support for code generated by the Compose compiler plugin and corresponding public API",
"name": "Compose Runtime",
"licenses": [
@@ -372,7 +389,7 @@
"name": "The Android Open Source Project"
}
],
- "artifactVersion": "1.8.0-rc03",
+ "artifactVersion": "1.8.0",
"description": "Compose components that allow saving and restoring the local ui state",
"name": "Compose Saveable",
"licenses": [
@@ -389,7 +406,7 @@
"name": "The Android Open Source Project"
}
],
- "artifactVersion": "1.8.0-rc03",
+ "artifactVersion": "1.8.0",
"description": "Compose UI primitives. This library contains the primitives that form the Compose UI Toolkit, such as drawing, measurement and layout.",
"name": "Compose UI",
"licenses": [
@@ -406,7 +423,7 @@
"name": "The Android Open Source Project"
}
],
- "artifactVersion": "1.8.0-rc03",
+ "artifactVersion": "1.8.0",
"description": "Compose classes related to dimensions without units",
"name": "Compose Geometry",
"licenses": [
@@ -423,7 +440,7 @@
"name": "The Android Open Source Project"
}
],
- "artifactVersion": "1.8.0-rc03",
+ "artifactVersion": "1.8.0",
"description": "Compose graphics",
"name": "Compose Graphics",
"licenses": [
@@ -440,7 +457,7 @@
"name": "The Android Open Source Project"
}
],
- "artifactVersion": "1.8.0-rc03",
+ "artifactVersion": "1.8.0",
"description": "Compose Text primitives and utilities",
"name": "Compose UI Text",
"licenses": [
@@ -450,6 +467,57 @@
"name": "The Android Open Source Project"
}
},
+ {
+ "uniqueId": "androidx.compose.ui:ui-tooling",
+ "developers": [
+ {
+ "name": "The Android Open Source Project"
+ }
+ ],
+ "artifactVersion": "1.8.0",
+ "description": "Compose tooling library. This library exposes information to our tools for better IDE support.",
+ "name": "Compose Tooling",
+ "licenses": [
+ "Apache-2.0"
+ ],
+ "organization": {
+ "name": "The Android Open Source Project"
+ }
+ },
+ {
+ "uniqueId": "androidx.compose.ui:ui-tooling-data",
+ "developers": [
+ {
+ "name": "The Android Open Source Project"
+ }
+ ],
+ "artifactVersion": "1.8.0",
+ "description": "Compose tooling library data. This library provides data about compose for different tooling purposes.",
+ "name": "Compose Tooling Data",
+ "licenses": [
+ "Apache-2.0"
+ ],
+ "organization": {
+ "name": "The Android Open Source Project"
+ }
+ },
+ {
+ "uniqueId": "androidx.compose.ui:ui-tooling-preview",
+ "developers": [
+ {
+ "name": "The Android Open Source Project"
+ }
+ ],
+ "artifactVersion": "1.8.0",
+ "description": "Compose tooling library API. This library provides the API required to declare @Preview composables in user apps.",
+ "name": "Compose UI Preview Tooling",
+ "licenses": [
+ "Apache-2.0"
+ ],
+ "organization": {
+ "name": "The Android Open Source Project"
+ }
+ },
{
"uniqueId": "androidx.compose.ui:ui-unit",
"developers": [
@@ -457,7 +525,7 @@
"name": "The Android Open Source Project"
}
],
- "artifactVersion": "1.8.0-rc03",
+ "artifactVersion": "1.8.0",
"description": "Compose classes for simple units",
"name": "Compose Unit",
"licenses": [
@@ -474,7 +542,7 @@
"name": "The Android Open Source Project"
}
],
- "artifactVersion": "1.8.0-rc03",
+ "artifactVersion": "1.8.0",
"description": "Internal Compose utilities used by other modules",
"name": "Compose Util",
"licenses": [
@@ -2556,6 +2624,20 @@
"Apache-2.0"
]
},
+ {
+ "uniqueId": "org.jetbrains.compose.ui:ui-tooling-preview",
+ "developers": [
+ {
+ "name": "Compose Multiplatform Team"
+ }
+ ],
+ "artifactVersion": "1.8.0-rc01",
+ "description": "Compose tooling library API. This library provides the API required to declare @Preview composables in user apps.",
+ "name": "Compose UI Preview Tooling",
+ "licenses": [
+ "Apache-2.0"
+ ]
+ },
{
"uniqueId": "org.jetbrains.compose.ui:ui-unit",
"developers": [

Run ./gradlew :tasks-app-android:exportLibraryDefinitions and commit resulting diff to fix the issue.

@opatry opatry force-pushed the compose-previews branch from e94fd9a to 4886a74 Compare May 5, 2025 19:32
This is less convenient than having it right after composable, but better than nothing.
Need to evaluate state of the art regarding UI tooling in Android Studio and CMP.
@opatry opatry force-pushed the compose-previews branch from 4886a74 to 9d3bc96 Compare May 5, 2025 20:05
@opatry opatry merged commit f87c9db into main May 5, 2025
2 checks passed
@opatry opatry deleted the compose-previews branch May 5, 2025 20:12
@opatry opatry linked an issue May 12, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add @Composable @Preview 👓

1 participant