Compose Desktop IDE Plugin doesn't show when using Jetbrains Preview annotation
Describe the bug When creating a project in Kotlin Multiplatform Wizard (since Compose Multiplatform Desktop template is a little bit outdated, doesn't use Gradle Version catalog by default for example)
When using Compose Multiplatform IDE Support (which is for Compose desktop but the name indicates it's for Compose Multiplatform)
Let's say you have the following code snippet:
@Composable
@Preview
fun App() {
var text by remember { mutableStateOf("Hello, World!") }
MaterialTheme {
Button(onClick = {
text = "Hello, Desktop!"
}) {
Text(text)
}
}
}
The preview button
Will only show up when the import of @Preview is from androidx.compose.desktop.ui.tooling.preview.Preview and not org.jetbrains.compose.ui.tooling.preview.Preview (the compose desktop template that is a little bit outdated is using androidx.compose.desktop.ui.tooling.preview.Preview and not org.jetbrains.compose.ui.tooling.preview.Preview (which is the default when using (kmp.jetbrains.com to create the compose desktop project)
Affected platforms
- Desktop (Windows, Linux, macOS)
Versions
- Libraries:
- Compose Multiplatform version: 1.6.6
- Compose Desktop Gradle plugin version: 1.6.2
- ...
- Kotlin version: 1.9.23
- OS architecture (x86 or arm64): arm64
To Reproduce Steps to reproduce the behavior:
- Create a new Compose Desktop project (either by kmp.jetbrains.com or Compose Multiplatform Desktop template)
- Make sure to replace
import androidx.compose.desktop.ui.tooling.preview.Previewwithimport org.jetbrains.compose.ui.tooling.preview.Previewor try out both - You will notice the preview button only shows up when using
import androidx.compose.desktop.ui.tooling.preview.Previewand not the new one from Jetbrains (which is designed for Compose Multiplatform and I believe it's used in Fleet IDE)
Expected behavior Compose desktop and Compose multiplatform have a great future, but maybe we should make the process less confusing and exclude anything related to Android. this doesn't require any breaking changes, we can support both and use the one from JetBrains as a default
Screenshots If applicable, add screenshots to help explain your problem.
The preview button doesn't show up:
It shows up after using Preview annotation from Androidx Import:
Additional information Not related to the issue, but maybe you should consider making the process easier since now we have multiple ways and places to create a Compose Desktop or Compose Multiplatform project, and each one has a default code that has advantages over the other, creating a CLI and add support for it in IDE would make the process much easier, like other frameworks (Flutter, React, etc)) which makes it more beginner-friendly and less confusing, I even created a very quick CLI utility (kmp-cli) just so I use it for creating Compose projects quickly
Thank you.
We have inconsistency with Preview annotations, which will be solved in https://github.com/JetBrains/compose-multiplatform/issues/4869. Please, vote for it.
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.