compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

Reduce variety of Preview annotations

Open igordmn opened this issue 1 year ago • 3 comments

We have 3 Previews:

  • androidx.compose.ui.tooling.preview.Preview
    • for androidMain
    • supported in Android Studio/IDEA
    • build.gradle should have implementation(compose.preview)
  • androidx.compose.desktop.ui.tooling.preview.Preview
    • for desktopMain
    • supported in Android Studio/IDEA
    • needed a separated installed IDE plugin
    • is available by default, no need extra lines in build.gradle
  • org.jetbrains.compose.ui.tooling.preview.Preview
    • for commonMain/androidMain/desktopMain
    • supported by Fleet
    • build.gradle should have implementation(compose.components.uiToolingPreview)

We should reduce the count, and make consistent guidelines/templates.

igordmn avatar May 24 '24 16:05 igordmn

Sub-issue: project created by kmp.jetbrains.com doesn't support Preview in IDEA/Android Studio https://github.com/JetBrains/compose-multiplatform/issues/4839

igordmn avatar May 24 '24 16:05 igordmn

I agree that we have to either use the Android one for compability or the one from Jetbrains compose multiplatform as it's more future proof.

EchoEllet avatar May 24 '24 16:05 EchoEllet

Preview an UI in commonMain on IntelliJ IDEA that is what I want.

akexorcist avatar May 24 '24 19:05 akexorcist

+1 Getting multiplatform compose previews to work in different places is currently a hassle.

malbanese avatar Jun 02 '24 06:06 malbanese

A report in Kotlin IDEA plugin tracker: https://youtrack.jetbrains.com/issue/KTIJ-30072

igordmn avatar Jun 03 '24 11:06 igordmn

For anyone else who finds this, I've found a solution that fits my needs while waiting for better preview support in Compose Multiplatform and Android Studio.

I was able to use the new Compose Preview Screenshot Testing library inside fully KMP / Compose multiplatform modules.

Previews work inside Android Studio under the proper package, and this (mostly) solves my screenshot testing needs as well. Obviously there are some requirements like putting previews in the screenshotTesting source directory, require an Android target with AGP 8.5.0, and only being able to pull from the common/android sources.

Here's the Gradle convention plugin I'm using to apply to the relevant modules: https://gist.github.com/malbanese/6f015e0390ee767c4bc0acb87f697755

malbanese avatar Jun 06 '24 02:06 malbanese

Preview an UI in commonMain on IntelliJ IDEA that is what I want.

Let's move this into a separate task: https://github.com/JetBrains/compose-multiplatform/issues/5078

igordmn avatar Jul 08 '24 12:07 igordmn

Parent task: https://github.com/JetBrains/compose-multiplatform/issues/2045

igordmn avatar Jul 08 '24 12:07 igordmn

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

okushnikov avatar Aug 26 '24 13:08 okushnikov