@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)
Make sure to replace import androidx.compose.desktop.ui.tooling.preview.Preview with import org.jetbrains.compose.ui.tooling.preview.Preview or try out both
You will notice the preview button only shows up when using import androidx.compose.desktop.ui.tooling.preview.Preview and 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, 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
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:
The preview button![image](https://github.com/JetBrains/compose-multiplatform/assets/73608287/df3638e4-17a2-494f-985b-4d540e2f432b)
Will only show up when the import of
@Preview
is fromandroidx.compose.desktop.ui.tooling.preview.Preview
and notorg.jetbrains.compose.ui.tooling.preview.Preview
(the compose desktop template that is a little bit outdated is usingandroidx.compose.desktop.ui.tooling.preview.Preview
and notorg.jetbrains.compose.ui.tooling.preview.Preview
(which is the default when using (kmp.jetbrains.com to create the compose desktop project)Affected platforms
Versions
To Reproduce Steps to reproduce the behavior:
import androidx.compose.desktop.ui.tooling.preview.Preview
withimport org.jetbrains.compose.ui.tooling.preview.Preview
or try out bothimport androidx.compose.desktop.ui.tooling.preview.Preview
and 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, 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![image](https://github.com/JetBrains/compose-multiplatform/assets/73608287/4d363a7a-4f33-40ed-a061-497e9e6a8175)
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.