JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.24k stars 1.11k forks source link

Reduce variety of Preview annotations #4869

Open igordmn opened 1 month ago

igordmn commented 1 month ago

We have 3 Previews:

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

igordmn commented 1 month ago

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

ellet0 commented 1 month ago

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.

akexorcist commented 1 month ago

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

malbanese commented 3 weeks ago

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

igordmn commented 3 weeks ago

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

malbanese commented 2 weeks ago

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