Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose Desktop IDE Plugin doesn't show when using Jetbrains Preview annotation #4839

Open
ellet0 opened this issue May 20, 2024 · 1 comment · May be fixed by #4979
Open

Compose Desktop IDE Plugin doesn't show when using Jetbrains Preview annotation #4839

ellet0 opened this issue May 20, 2024 · 1 comment · May be fixed by #4979
Labels
enhancement New feature or request ide IDE related issue preview

Comments

@ellet0
Copy link

ellet0 commented May 20, 2024

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
image

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:

  1. Create a new Compose Desktop project (either by kmp.jetbrains.com or Compose Multiplatform Desktop template)
  2. 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
  3. 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:

image

It shows up after using Preview annotation from Androidx Import:
image

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.

@ellet0 ellet0 added bug Something isn't working submitted labels May 20, 2024
@ellet0 ellet0 changed the title Compose Multiplatform IDE Plugin doesn't show when using Jetbrains Preview annotation Compose Desktop IDE Plugin doesn't show when using Jetbrains Preview annotation May 20, 2024
@igordmn
Copy link
Collaborator

igordmn commented May 24, 2024

We have inconsistency with Preview annotations, which will be solved in #4869. Please, vote for it.

@igordmn igordmn added enhancement New feature or request ide IDE related issue and removed bug Something isn't working labels May 24, 2024
sergeshustoff added a commit to sergeshustoff/compose-multiplatform that referenced this issue Jun 16, 2024
… annotation (JetBrains#4839)

Allows desktop preview to work with org.jetbrains.compose.ui.tooling.preview.Preview annotation in addition to desktop preview annotation. That allows using preview in common code (JetBrains#2045), though only with desktop target enabled

Fixes JetBrains#4839, JetBrains#2045
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ide IDE related issue preview
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants